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)
FXbool open (FXStreamDirection save_or_load, unsigned long size=8192, FXuchar *data=NULL)
virtual FXbool close ()
virtual FXbool flush ()
unsigned long getSpace () const
void setSpace (unsigned long sp)
FXStreamStatus status () const
FXbool eof () const
void setError (FXStreamStatus err)
FXStreamDirection direction () const
const FXObjectcontainer () const
unsigned long position () const
virtual FXbool position (long offset, FXWhence whence=FXFromStart)
void swapBytes (FXbool s)
FXbool swapBytes () 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)
FXStreamsave (const FXuchar *p, unsigned long n)
FXStreamsave (const FXchar *p, unsigned long n)
FXStreamsave (const FXushort *p, unsigned long n)
FXStreamsave (const FXshort *p, unsigned long n)
FXStreamsave (const FXuint *p, unsigned long n)
FXStreamsave (const FXint *p, unsigned long n)
FXStreamsave (const FXfloat *p, unsigned long n)
FXStreamsave (const FXdouble *p, unsigned long 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)
FXStreamload (FXuchar *p, unsigned long n)
FXStreamload (FXchar *p, unsigned long n)
FXStreamload (FXushort *p, unsigned long n)
FXStreamload (FXshort *p, unsigned long n)
FXStreamload (FXuint *p, unsigned long n)
FXStreamload (FXint *p, unsigned long n)
FXStreamload (FXfloat *p, unsigned long n)
FXStreamload (FXdouble *p, unsigned long n)
FXStreamsaveObject (const FXObject *v)
FXStreamloadObject (FXObject *&v)
virtual ~FXStream ()

Static Public Member Functions

FXbool isLittleEndian ()

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.

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

FXbool FX::FXStream::open FXStreamDirection  save_or_load,
unsigned long  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 FXbool FX::FXStream::close  )  [virtual]
 

Close; return TRUE if OK.

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

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

Flush buffer.

unsigned long FX::FXStream::getSpace  )  const
 

Get available buffer space.

void FX::FXStream::setSpace unsigned long  sp  ) 
 

Set available buffer space.

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

Get status code.

FXbool 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.

unsigned long FX::FXStream::position  )  const [inline]
 

Get position.

virtual FXbool FX::FXStream::position long  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 FXbool  s  )  [inline]
 

Change swap bytes flag.

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

Get state of the swap bytes flag.

FXbool FX::FXStream::isLittleEndian  )  [inline, static]
 

Return implementation's endianness.

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

Save single items to stream.

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

FXStream& FX::FXStream::save const FXuchar *  p,
unsigned long  n
 

Save arrays of items to stream.

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::load FXuchar *  p,
unsigned long  n
 

Load arrays of items from stream.

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.

Copyright © 1997-2004 Jeroen van der Zijp