Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GOStream Class Reference

Provides many functions for writing data to a stream. More...

#include <gauge3d/files/ostream.h>

Inherits GAUGE3D::GObject.

List of all members.

Public Types

enum  tSeekType { BEGINNING, CURRENT, END }
 Position to seek relative to. Used by Seek(). More...

enum  tWriteMode { BINARY, ASCII }
 Write mode specifiers for WriteMode(). More...

enum  tEndianness { BIG, LITTLE }
 Endianness specifiers for Endianness(). More...

enum  tNumberBase { OCT = 8, DEC = 10, HEX = 16 }
 Number base specifiers for NumberBase(). More...


Public Methods

 GOStream (pGRawOStream streamDest)
 Create a buffered output stream. More...

 GOStream (pGRawOStream streamDest,int bufferSize)
 Create a buffered output stream. More...

virtual ~GOStream ()
 Destructor.

void Seek (int pos,tSeekType seekType)
 Seek the stream position. More...

int TellPos ()
 Get the distance in bytes between the beginning of the stream and the current position.

int Write (const uint64 *source,int num=1)
 Write one or more uint64's from the source buffer. Returns the number successfully written.

int Write (const uint32 *source,int num=1)
 Write one or more uint32's from the source buffer. Returns the number successfully written.

int Write (const uint16 *source,int num=1)
 Write one or more uint16's from the source buffer. Returns the number successfully written.

int Write (const int64 *source,int num=1)
 Write one or more int64's from the source buffer. Returns the number successfully written.

int Write (const int32 *source,int num=1)
 Write one or more int32's from the source buffer. Returns the number successfully written.

int Write (const int16 *source,int num=1)
 Write one or more int16's from the source buffer. Returns the number successfully written.

int Write (const float64 *source,int num=1)
 Write one or more float64's from the source buffer. Returns the number successfully written.

int Write (const float32 *source,int num=1)
 Write one or more float32's from the source buffer. Returns the number successfully written.

int Write (const char *source,int num=1)
 Write one or more char's from the source buffer. Returns the number successfully written.

int Write (const char *source[],int num=1)
 Write one or more strings from the source buffer. Returns the number successfully written. More...

int Write (const GString *source,int num=1)
 Write one or more strings from the source buffer. Returns the number successfully written. More...

int Write (const void *source,int num)
 Write <u>num</u> bytes of raw data.

void Put (char c)
 Write a character to the stream. More...

int Flush ()
 Write any data that is in the buffer to the output stream. More...

void WriteMode (tWriteMode mode)
tWriteMode WriteMode ()
 Get the current write mode.

void Separator (char separator,bool enable)
 Specify a character to place after each item. More...

char Separator ()
 Get the current separator character.

void Endianness (tEndianness endianness)
 Set the endianness in which to write the output data. Only applies to binary streams.

tEndianness Endianness ()
 Get the endianness of the output data.

void NumberBase (tNumberBase base)
 Set the number base in which to write the output data. Only applies to text streams.

tNumberBase NumberBase ()
 Get the number base of the output data.

 operator void * ()
 Use to check if the last write operation succeeded.


Related Functions

(Note that these are not member functions.)

template<class tType> GOStream & operator<< (GOStream &os,const tType &source)
 The << operator works the same as it does for C++ ostreams.


Detailed Description

Provides many functions for writing data to a stream.

GOStream does not provide the stream destination itself. It wraps around a GRawOStream. GOStream provides many different ways to write the data, however, whereas GRawOStream only lets you write the data raw.

You can use a GOStream in either binary or text mode. Text mode works like regular C++ ostreams, where numbers are written as ASCII, human-readable numbers, etc. In binary mode, on the other hand, the numbers are written in actual binary code, where a 32-bit number will be exactly four bytes in size in the file. Also, when in binary mode you can set whether to write the data in big-endian or little-endian format. The data will automatically be converted from the host's endianness when written.


Member Enumeration Documentation

enum GAUGE3D::GOStream::tSeekType
 

Position to seek relative to. Used by Seek().

Enumeration values:
BEGINNING   Seek relative to the start of the stream.
CURRENT   Seek relative to the current position.
END   Seek relative to the end of the stream.

enum GAUGE3D::GOStream::tWriteMode
 

Write mode specifiers for WriteMode().

Enumeration values:
BINARY   Binary mode writing.
ASCII   ASCII text mode writing.

enum GAUGE3D::GOStream::tEndianness
 

Endianness specifiers for Endianness().

Enumeration values:
BIG   Big endian. Most significant byte comes first. PPC processors are big endian.
LITTLE   Little endian. Least significant byte comes first. Intel processors are little endian.

enum GAUGE3D::GOStream::tNumberBase
 

Number base specifiers for NumberBase().

Enumeration values:
OCT   Octal (base 8).
DEC   Decimal (base 10).
HEX   Hexidecimal (base 16).


Constructor & Destructor Documentation

GAUGE3D::GOStream::GOStream ( pGRawOStream streamDest )
 

Create a buffered output stream.

Parameters:
streamDest   A pointer to a GRawOStream to which to write data.

GAUGE3D::GOStream::GOStream ( pGRawOStream streamDest,
int bufferSize )
 

Create a buffered output stream.

Parameters:
streamDest   A pointer to a GRawOStream to which to write data.
bufferSize   The size of the internal buffer in bytes. You can set this to zero to create an unbuffered stream, but this will usually be slower unless you are writing data in large blocks. Also, only buffered streams can be used in text (non-binary) mode.


Member Function Documentation

void GAUGE3D::GOStream::Seek ( int pos,
tSeekType seekType )
 

Seek the stream position.

Parameters:
pos   Position to seek to, in bytes.
seekType   Point in the stream that pos is relative to.

int GAUGE3D::GOStream::Write ( const char * source[],
int num = 1 )
 

Write one or more strings from the source buffer. Returns the number successfully written.

Parameters:
source   An array of pointers to null-terminated character strings.
num   The number of strings to write.
Returns:
The number of strings successfully written.

int GAUGE3D::GOStream::Write ( const GString * source,
int num = 1 )
 

Write one or more strings from the source buffer. Returns the number successfully written.

Parameters:
source   An array of strings.
num   The number of strings to write.
Returns:
The number of strings successfully written.

void GAUGE3D::GOStream::Put ( char c )
 

Write a character to the stream.

Note:
This can only be done with buffered streams.

int GAUGE3D::GOStream::Flush ( )
 

Write any data that is in the buffer to the output stream.

Returns:
The number of bytes still in the buffer (should always be zero).

void GAUGE3D::GOStream::WriteMode ( tWriteMode mode )
 

\breif Set how to output the data in the stream (binary or text).

Parameters:
mode   One of tWriteMode.

void GAUGE3D::GOStream::Separator ( char separator,
bool enable )
 

Specify a character to place after each item.

Parameters:
separator   A character that should be placed after every item that is written.
enable   Whether or not to enable this functionality.
Remarks:
This allows you to output an array of numbers without getting them all mushed together.
Note:
This only applies to test i/o, not binary. The separator will not be used after Put() calls (as the other write calls use Put() for text output).


The documentation for this class was generated from the following file:
Generated at Tue Jan 30 17:07:34 2001 for gauge3d by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000