class CCL::Streamer

Overview

Typed stream reader/writer <> More…

#include <streamer.h>

class Streamer: public Core::IO::BinaryAccessor
{
public:
    // construction

    Streamer (IStream& stream, int byteOrder = kNativeByteOrder);

    // methods

    IStream& getStream () const;
    IStream* operator -> () const;
    virtual int read (void* buffer, int size);
    virtual int write (const void* buffer, int size);
    bool readCString (MutableCString& string);
    bool writeWithLength (CStringRef string);
    bool readWithLength (MutableCString& string);
    bool writeChar (uchar c);
    bool readChar (uchar& c);
    bool writeLine (StringRef line);
    bool writeString (StringRef string, bool terminate = true);
    bool writeString (const uchar* chars, bool terminate = true);
    bool writeWithLength (StringRef string);
    bool readString (String& string);
    bool readWithLength (String& string);
    bool write (FOURCC fcc);
    bool read (FOURCC& fcc);
    bool write (UIDRef uid);
    bool read (UIDBytes& uid);
};

Inherited Members

public:
    // fields

    static const uint16 kByteOrderMark = 0xFEFF;

    // methods

    bool isByteSwap () const;
    int getByteOrder () const;
    void setByteOrder (int byteOrder);
    bool writeByteOrder ();
    bool readByteOrder ();
    virtual int read (void* buffer, int size) = 0;
    virtual int write (const void* buffer, int size) = 0;

    template  <typename T>
    int readElements (T buffer [], int count);

    template  <typename T>
    int writeElements (const T buffer [], int count);

    bool write (int8 c);
    bool read (int8& c);
    bool write (uint8 uc);
    bool read (uint8& uc);
    bool write (int16 s);
    bool read (int16& s);
    bool write (uint16 us);
    bool read (uint16& us);
    bool write (int32 l);
    bool read (int32& l);
    bool write (uint32 ul);
    bool read (uint32& ul);
    bool write (int64 ll);
    bool read (int64& ll);
    bool write (uint64 ull);
    bool read (uint64& ull);
    bool writeVarLen (uint32 value);
    bool readVarLen (uint32& value);
    bool write (float f);
    bool read (float& f);
    bool write (double f);
    bool read (double& f);
    bool write (char c);
    bool read (char& c);
    bool writeCString (CStringPtr string, bool terminate = true);
    bool readCStringBuffer (char* charBuffer, int bufferSize);
    bool writeFCC (int32 fcc);
    bool readFCC (int32& fcc);

Detailed Documentation

Typed stream reader/writer <>

Methods

virtual int read (void* buffer, int size)

Read data from underlying storage, to be implemented by derived class.

virtual int write (const void* buffer, int size)

Write data to underlying storage, to be implemented by derived class.

bool readCString (MutableCString& string)

Read null-terminated C-String.

bool writeWithLength (CStringRef string)

Write C-String with preceding length field.

bool readWithLength (MutableCString& string)

Read C-String with preceding length field.

bool writeChar (uchar c)

Write a Unicode character.

bool readChar (uchar& c)

Read a Unicode character.

bool writeLine (StringRef line)

Write Unicode string with platform line ending.

bool writeString (StringRef string, bool terminate = true)

Write Unicode string with optional null-termination.

bool writeWithLength (StringRef string)

Write Unicode string with preceding length field.

bool readString (String& string)

Read null-terminated Unicode string.

bool readWithLength (String& string)

Read Unicode string with preceding length field.