Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXStream Class Reference

A stream is a way to serialize data and objects into a byte stream. More...

#include <FXStream.h>

Inheritance diagram for FX::FXStream:

FX::FXFileStream FX::FXMemoryStream List of all members.

Public Member Functions

 FXStream (const FXObject *cont=NULL)
bool open (FXStreamDirection save_or_load, FXuval size=8192, FXuchar *data=NULL)
virtual bool flush ()
virtual bool close ()
FXuval getSpace () const
void setSpace (FXuval sp)
FXStreamStatus status () const
bool eof () const
void setError (FXStreamStatus err)
FXStreamDirection direction () const
const FXObjectcontainer () const
FXlong position () const
virtual bool position (FXlong offset, FXWhence whence=FXFromStart)
void swapBytes (bool s)
bool swapBytes () const
void setBigEndian (bool big)
bool isBigEndian () const
FXStreamoperator<< (const FXuchar &v)
FXStreamoperator<< (const FXchar &v)
FXStreamoperator<< (const FXushort &v)
FXStreamoperator<< (const FXshort &v)
FXStreamoperator<< (const FXuint &v)
FXStreamoperator<< (const FXint &v)
FXStreamoperator<< (const FXfloat &v)
FXStreamoperator<< (const FXdouble &v)
FXStreamoperator<< (const FXlong &v)
FXStreamoperator<< (const FXulong &v)
FXStreamsave (const FXuchar *p, FXuval n)
FXStreamsave (const FXchar *p, FXuval n)
FXStreamsave (const FXushort *p, FXuval n)
FXStreamsave (const FXshort *p, FXuval n)
FXStreamsave (const FXuint *p, FXuval n)
FXStreamsave (const FXint *p, FXuval n)
FXStreamsave (const FXfloat *p, FXuval n)
FXStreamsave (const FXdouble *p, FXuval n)
FXStreamsave (const FXlong *p, FXuval n)
FXStreamsave (const FXulong *p, FXuval n)
FXStreamoperator>> (FXuchar &v)
FXStreamoperator>> (FXchar &v)
FXStreamoperator>> (FXushort &v)
FXStreamoperator>> (FXshort &v)
FXStreamoperator>> (FXuint &v)
FXStreamoperator>> (FXint &v)
FXStreamoperator>> (FXfloat &v)
FXStreamoperator>> (FXdouble &v)
FXStreamoperator>> (FXlong &v)
FXStreamoperator>> (FXulong &v)
FXStreamload (FXuchar *p, FXuval n)
FXStreamload (FXchar *p, FXuval n)
FXStreamload (FXushort *p, FXuval n)
FXStreamload (FXshort *p, FXuval n)
FXStreamload (FXuint *p, FXuval n)
FXStreamload (FXint *p, FXuval n)
FXStreamload (FXfloat *p, FXuval n)
FXStreamload (FXdouble *p, FXuval n)
FXStreamload (FXlong *p, FXuval n)
FXStreamload (FXulong *p, FXuval n)
FXStreamsaveObject (const FXObject *v)
FXStreamloadObject (FXObject *&v)
FXStreamaddObject (const FXObject *v)
virtual ~FXStream ()

Detailed Description

A stream is a way to serialize data and objects into a byte stream.

Each item of data that is saved or loaded from the stream may be byte-swapped, thus allowing little-endian machines to read data produced on big endian ones and vice-versa. Data is serialized exactly as-is. There are no tags or other markers inserted into the stream; thus, the stream may be used to save or load arbitrary binary data. Objects derived from FXObjects may be serialized also; whenever a reference to an object is serialized, a table is consulted to determine if the same object has been encountered previously; if not, the object is added to the table and then its contents are serialized. If the object has been encountered before, only a reference to the object is serialized. When loading back a serialized object, new instances are constructed using the default constructor, and subsequently the object's contents are loaded. A special container object may be passed in which is placed in the table as if it had been encountered before; this will cause only references to this object to be saved. The container object is typically the top-level document object which manages all objects contained by it. Additional objects may be added using addObject(); these will not be actually saved or loaded.

See also:


Constructor & Destructor Documentation

FX::FXStream::FXStream const FXObject cont = NULL  ) 
 

Construct stream with given container object.

The container object is an object that will itself not be saved to or loaded from the stream, but which may be referenced by other objects. These references will be properly saved and restored.

virtual FX::FXStream::~FXStream  )  [virtual]
 

Destructor.


Member Function Documentation

bool FX::FXStream::open FXStreamDirection  save_or_load,
FXuval  size = 8192,
FXuchar data = NULL
 

Open stream for reading (FXStreamLoad) or for writing (FXStreamSave).

An initial buffer size may be given, which must be at least 16 bytes. If data is not NULL, it is expected to point to an external data buffer of length size; otherwise stream will use an internally managed buffer.

Reimplemented in FX::FXMemoryStream.

virtual bool FX::FXStream::flush  )  [virtual]
 

Flush buffer.

virtual bool FX::FXStream::close  )  [virtual]
 

Close; return true if OK.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXuval FX::FXStream::getSpace  )  const
 

Get available buffer space.

void FX::FXStream::setSpace FXuval  sp  ) 
 

Set available buffer space.

FXStreamStatus FX::FXStream::status  )  const [inline]
 

Get status code.

bool FX::FXStream::eof  )  const [inline]
 

Return true if at end of file or error.

void FX::FXStream::setError FXStreamStatus  err  ) 
 

Set status code.

FXStreamDirection FX::FXStream::direction  )  const [inline]
 

Obtain stream direction.

const FXObject* FX::FXStream::container  )  const [inline]
 

Get parent object.

FXlong FX::FXStream::position  )  const [inline]
 

Get position.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

virtual bool FX::FXStream::position FXlong  offset,
FXWhence  whence = FXFromStart
[virtual]
 

Move to position relative to head, tail, or current location.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

void FX::FXStream::swapBytes bool  s  )  [inline]
 

Change swap bytes flag.

bool FX::FXStream::swapBytes  )  const [inline]
 

Get state of the swap bytes flag.

void FX::FXStream::setBigEndian bool  big  ) 
 

Set stream to big endian mode if true.

Byte swapping will be enabled if the machine native byte order is not equal to the desired byte order.

bool FX::FXStream::isBigEndian  )  const
 

Return true if big endian mode.

FXStream& FX::FXStream::operator<< const FXuchar v  ) 
 

Save single items to stream.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXchar v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXushort v  ) 
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXshort v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXuint v  ) 
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXint v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXfloat v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXdouble v  ) 
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXlong &  v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator<< const FXulong &  v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXuchar p,
FXuval  n
 

Save arrays of items to stream.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXchar p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXushort p,
FXuval  n
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXshort p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXuint p,
FXuval  n
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXint p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXfloat p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXdouble p,
FXuval  n
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXlong *  p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::save const FXulong *  p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXuchar v  ) 
 

Load single items from stream.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXchar v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXushort v  ) 
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXshort v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXuint v  ) 
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXint v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXfloat v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXdouble v  ) 
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXlong &  v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::operator>> FXulong &  v  )  [inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXuchar p,
FXuval  n
 

Load arrays of items from stream.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXchar p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXushort p,
FXuval  n
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXshort p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXuint p,
FXuval  n
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXint p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXfloat p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXdouble p,
FXuval  n
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXlong *  p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::load FXulong *  p,
FXuval  n
[inline]
 

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::saveObject const FXObject v  ) 
 

Save object.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::loadObject FXObject *&  v  ) 
 

Load object.

Reimplemented in FX::FXFileStream, and FX::FXMemoryStream.

FXStream& FX::FXStream::addObject const FXObject v  ) 
 

Add object without saving or loading.

Copyright © 1997-2005 Jeroen van der Zijp