Torque2D Reference
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Stream Class Referenceabstract

Base stream class for streaming data across a specific media. More...

#include <stream.h>

+ Inheritance diagram for Stream:

Public Types

enum  Status {
  Ok = 0, IOError, EOS, IllegalCall,
  Closed, UnknownError
}
 Status constantants for the stream. More...
 
enum  Capability { StreamWrite = BIT(0), StreamRead = BIT(1), StreamPosition = BIT(2) }
 

Public Member Functions

 Stream ()
 
virtual ~Stream ()
 
Stream::Status getStatus () const
 Gets the status of the stream. More...
 
virtual bool hasCapability (const Capability) const =0
 Checks to see if this stream has the capability of a given function. More...
 
virtual U32 getPosition () const =0
 Gets the position in the stream. More...
 
virtual bool setPosition (const U32 in_newPosition)=0
 Sets the position of the stream. Returns if the new position is valid or not. More...
 
virtual U32 getStreamSize ()=0
 Gets the size of the stream. More...
 
void readLine (U8 *buffer, U32 bufferSize)
 
void writeLine (U8 *buffer)
 writes a line to the stream More...
 
const char * readSTString (bool casesens=false)
 
virtual void readString (char stringBuf[256])
 Reads a string of maximum 255 characters long. More...
 
void readLongString (U32 maxStringLen, char *stringBuf)
 
void writeLongString (U32 maxStringLen, const char *string)
 
bool Put (char character)
 
virtual void writeString (const char *stringBuf, S32 maxLen=255)
 Writes a string to the stream. More...
 
bool writeFormattedBuffer (const char *format,...)
 
bool writeStringBuffer (const char *buffer)
 Writes a NULL terminated string buffer. More...
 
bool write (const ColorI &)
 Write an integral color to the stream. More...
 
bool write (const ColorF &)
 Write a floating point color to the stream. More...
 
bool read (ColorI *)
 Read an integral color from the stream. More...
 
bool read (ColorF *)
 Read a floating point color from the stream. More...
 
bool read (const U32 in_numBytes, void *out_pBuffer)
 
bool write (const U32 in_numBytes, const void *in_pBuffer)
 
bool read (bool *out_pRead)
 
bool write (const bool &in_rWrite)
 
bool copyFrom (Stream *other)
 Copy the contents of another stream into this one. More...
 
void writeTabs (U32 count)
 Write a number of tabs to this stream. More...
 

Static Public Member Functions

static const char * getStatusString (const Status in_status)
 Gets a printable string form of the status. More...
 

Protected Member Functions

void setStatus (const Status in_newStatus)
 
virtual bool _read (const U32 in_numBytes, void *out_pBuffer)=0
 
virtual bool _write (const U32 in_numBytes, const void *in_pBuffer)=0
 

Detailed Description

Base stream class for streaming data across a specific media.

Member Enumeration Documentation

enum Capability
Enumerator
StreamWrite 

Can this stream write?

StreamRead 

Can this stream read?

StreamPosition 

Can this stream position?

enum Status

Status constantants for the stream.

Enumerator
Ok 

Ok!

IOError 

Read or Write error.

EOS 

End of Stream reached (mostly for reads)

IllegalCall 

An unsupported operation used. Always w/ accompanied by AssertWarn.

Closed 

Tried to operate on a closed stream (or detached filter)

UnknownError 

Catchall.

Constructor & Destructor Documentation

Stream ( )
~Stream ( )
virtual

Member Function Documentation

virtual bool _read ( const U32  in_numBytes,
void *  out_pBuffer 
)
protectedpure virtual
virtual bool _write ( const U32  in_numBytes,
const void *  in_pBuffer 
)
protectedpure virtual
bool copyFrom ( Stream other)

Copy the contents of another stream into this one.

virtual U32 getPosition ( ) const
pure virtual
Stream::Status getStatus ( ) const
inline

Gets the status of the stream.

const char * getStatusString ( const Status  in_status)
static

Gets a printable string form of the status.

virtual U32 getStreamSize ( )
pure virtual

Gets the size of the stream.

Implemented in BitStream, ZipSubWStream, ZipSubRStream, FileStream, BufferStream, ResizeFilterStream, MemStream, and FilterStream.

virtual bool hasCapability ( const Capability  ) const
pure virtual

Checks to see if this stream has the capability of a given function.

Implemented in BitStream, ZipSubWStream, FileStream, ZipSubRStream, BufferStream, MemStream, and FilterStream.

bool Put ( char  character)
inline
bool read ( ColorI pColor)

Read an integral color from the stream.

bool read ( ColorF pColor)

Read a floating point color from the stream.

bool read ( const U32  in_numBytes,
void *  out_pBuffer 
)
inline
bool read ( bool *  out_pRead)
inline
void readLine ( U8 *  buffer,
U32  bufferSize 
)

Reads a line from the stream.

Parameters
bufferbuffer to be read into
bufferSizemax size of the buffer. Will not read more than the "bufferSize"
void readLongString ( U32  maxStringLen,
char *  stringBuf 
)

Reads a string that could potentially be more than 255 characters long.

Parameters
maxStringLenMaximum length to read. If the string is longer than maxStringLen, only maxStringLen bytes will be read.
stringBufbuffer where data is read into
void readString ( char  stringBuf[256])
virtual

Reads a string of maximum 255 characters long.

Reimplemented in BitStream.

const char * readSTString ( bool  casesens = false)

Reads a string and inserts it into the StringTable

See Also
StringTable
virtual bool setPosition ( const U32  in_newPosition)
pure virtual

Sets the position of the stream. Returns if the new position is valid or not.

Implemented in BitStream, ZipSubWStream, FileStream, ZipSubRStream, ZipTempStream, BufferStream, ResizeFilterStream, ZipCryptRStream, MemStream, and FilterStream.

void setStatus ( const Status  in_newStatus)
inlineprotected
bool write ( const ColorI rColor)

Write an integral color to the stream.

bool write ( const ColorF rColor)

Write a floating point color to the stream.

bool write ( const U32  in_numBytes,
const void *  in_pBuffer 
)
inline
bool write ( const bool &  in_rWrite)
inline
bool writeFormattedBuffer ( const char *  format,
  ... 
)

Writes a formatted buffer to the stream. NOTE: A maximum string length of 4K is allowed.

void writeLine ( U8 *  buffer)

writes a line to the stream

void writeLongString ( U32  maxStringLen,
const char *  string 
)

Writes a string to the stream. This function is slightly unstable. Only use this if you have a valid string that is not empty. writeString is safer.

void writeString ( const char *  stringBuf,
S32  maxLen = 255 
)
virtual

Writes a string to the stream.

Reimplemented in BitStream.

bool writeStringBuffer ( const char *  buffer)
inline

Writes a NULL terminated string buffer.

void writeTabs ( U32  count)
inline

Write a number of tabs to this stream.


The documentation for this class was generated from the following files: