[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LStream



Overview:

LStream is a PowerPlant class that is used for managing data streaming in PowerPlant. By abstracting low-level data sourcing and sinking away from objects, you can read and write data without regard to where it came from or is going to.

Methods :

The methods in this class are:

 

LStream()  
~LStream()  
AtEnd()  
GetBytes()  
GetLength()  
GetMarker()  
PeekData()  
PutBytes()  
ReadBlock()  
ReadCString()  
ReadData()  
ReadHandle()  
ReadPString()  
ReadPtr()  
SetLength()  
SetMarker()  
WriteBlock()  
WriteCString()  
WriteData()  
WriteHandle()  
WritePString()  
WritePtr()  
LStream& operator << ( TypeParameter )  
LStream& operator >> ( TypeParameter )  
LStream& operator =  
 

Data Members:

The data members in this class are:

 

mMarker  
mLength  

Operation:

The PowerPlant Book contains a detailed description of how to work with this class. Refer there for more information.

Source files:

(File & Stream Classes)

LStream.h

LStream.cp

LStream()

Purpose:

The constructor creates an object. There are two constructors for LStream. The first is the default constructor. The second is the copy constructor

Access :

Public

Prototype:

LStream();

LStream::LStream( const LStream& inOriginal )
Parameters:

None

~LStream()

Purpose:

The destructor destroys the LStream object.

Access :

Virtual, Public

Prototype:

virtual ~LStream();

AtEnd()

Purpose:

This method tells if the end of the stream has been reached.

Access :

Inline, Public

Prototype:

Boolean AtEnd() const;
Parameters:

None

Return:

Returns true if at the end of the stream.

GetBytes()

Purpose:

Read bytes from a Stream to a buffer. Subclasses must override this function to support reading.

Access :

Virtual, Public

Prototype:

ExceptionCode GetBytes(
  void* outBuffer,
  SInt32& ioByteCount)
Parameters:

 

void*  
outBuffer  
Pointer to the stream buffer  
SInt32&  
ioByteCount  
Number of bytes read  

Return:

Returns an error code and passes back the number of bytes actually read, which may be less than the number requested if an error occurred.

Remarks:

You should not throw an Exception out of this function.

GetLength()

Purpose:

Return the length, in bytes, of the Stream

Access :

Public, Virtual

Prototype:

SInt32 GetLength() const;
Parameters:

None

Return:

Size of streams in bytes.

GetMarker()

Purpose:

Return the Read/Write Marker position

Access :

Public, Virtual

Prototype:

SInt32 GetMarker() const;
Parameters:

None

Return:

Marker position

Remarks:

Position is a byte offset from the start of the Stream.

PeekData()

Purpose:

Read data from a Stream to a buffer, without moving the Marker

Access :

Public

Prototype:

SInt32 PeekData(
  void* outBuffer,
  SInt32 inByteCount)
Parameters:

 

void*  
outBuffer  
Pointer to the stream buffer  
SInt32  
inByteCount  
Number of bytes read  

Return:

The number of bytes actually read, which may be less than the number requested if an error occurred.

PutBytes()

Purpose:

Write bytes from a buffer to a Stream

Subclasses must override this function to support writing.

Access :

Public, Virtual

Prototype:

ExceptionCode PutBytes(
  const void* inBuffer,
  SInt32 &ioByteCount)
Parameters:

 

const void*  
inBuffer  
Pointer to the stream buffer  
SInt32  
&ioByteCount  
Number of bytes written  

Return:

Returns an error code and passes back the number of bytes actually written, which may be less than the number requested if an error occurred.

Remarks:

You should not throw an Exception out of this function.

ReadBlock()

Purpose:

Read data from a Stream to a buffer.

Access :

Public

Prototype:

void ReadBlock(
  void *outBuffer,
  SInt32 inByteCount);
Parameters:

 

void  
*inBuffer  
Pointer to the stream buffer  
SInt32  
inByteCount  
Number of bytes to read  

Return:

None

ReadCString()

Purpose:

Read a C string from a Stream

Access :

Public

Prototype:

SInt32 ReadCString(char *outString)
Parameters:

 

char  
*outString  
C string  

Return:

Returns the number of bytes read.

Remarks:

C string is stored as a 4-byte count followed by the characters. The null terminator is not stored and must be added afterwards.

ReadData()

Purpose:

Read bytes from a Stream to a buffer.

Access :

Public, Virtual

Prototype:

SInt32 ReadData(
  void *outBuffer,
  SInt32 inByteCount);
Parameters:

 

void  
*outBuffer  
Pointer to the stream buffer  
SInt32  
inByteCount  
Number of bytes to read  

Return:

Number of bytes actually read

ReadHandle()

Purpose:

Read data from a Stream into a newly created Handle block

Access :

Public

Prototype:

SInt32 ReadHandle(
  Handle &outHandle);
Parameters:

 

Handle  
&outHandle  
Address of Handle block  

Return:

Returns the number of bytes read.

Remarks:

A Handle block is stored in a Stream as a 4-byte count (size of the Handle), followed by the contents of the Handle block.

ReadPString()

Purpose:

Read a Pascal string from a Stream

Access :

Public

Prototype:

SInt32 ReadPString(
  Str255 outString);
Parameters:

 

Str255  
outString  
Pascal string to read  

Return:

Returns the number of bytes read.

ReadPtr()

Purpose:

Read data from a Stream into a newly created Ptr block

Access :

Public

Prototype:

SInt32 ReadPtr(
  Ptr &outPtr);
Parameters:

 

Ptr  
&outPtr  
Address of point block  

Return:

Returns the number of bytes read.

Remarks:

A Ptr block is stored in a Stream as a 4-byte count (size of the Ptr), followed by the contents of the Ptr block.

SetLength()

Purpose:

Set the length, in bytes, of the Stream.

Access :

Public, Virtual

Prototype:

void SetLength(
  SInt32 inLength;
Parameters:

 

SInt32  
inLength  
New stream length  

SI

Return:

None

SetMarker()

Purpose:

Place the Read/Write Marker at an offset from a specified position. inFromWhere can be streamFrom_Start, streamFrom_End, or streamFrom_Marker

Access :

Public, Virtual

Prototype:

void SetMarker(
  SInt32 inOffset,
  EStreamFrom inFromWhere);
Parameters:

 

SInt32  
inOffset  
Offset position in bytes  
EStreamFrom  
inFromWhere  
Marker position in Stream  

Return:

None

WriteBlock()

Purpose:

Write data, specified by a pointer and byte count, to a Stream

Access :

Public

Prototype:

void WriteBlock(
  const void *inBuffer,
  SInt32 inByteCount);
Parameters:

 

const void  
*inBuffer  
Pointer to a stream buffer  
SInt32  
inByteCount  
Number of bytes to write  

Return:

None

WriteCString()

Purpose:

Write a C string to a Stream

Access :

Public

Prototype:

SInt32 WriteCString(
  const char *inString);
Parameters:

 

const char  
*inString  
C string  

Return:

Returns the number of bytes written.

Remarks:

C string is written as a 4-byte count followed by the characters. The terminater is not written.

WriteData()

Purpose:

 

Access :

Public

Prototype:

SInt32 WriteData(
  const void *inBuffer,
  SInt32 inByteCount);
Parameters:

 

const void  
*inBuffer  
Pointer to a stream buffer  
SInt32  
inByteCount  
Number of bytes to write  

Return:

Number of bytes actually written.

Remarks:

Calls PutBytes().

WriteHandle()

Purpose:

Write a Toolbox Handle block to a Stream

Access :

Public

Prototype:

SInt32 WriteHandle(
  Handle inHandle);
Parameters:

 

Handle  
inHandle  
Handle block to write  

Return:

Returns the number of bytes written.

Remarks:

A Handle block is written as a 4-byte count (size of the Handle), followed by the contents of the Handle block.

WritePString()

Purpose:

Write a Pascal string to a Stream.

Access :

Public

Prototype:

SInt32 WritePString(
  ConstStringPtr inString);
Parameters:

 

ConstStringPtr  
inString  
Pascal string to write  

Return:

Returns the number of bytes written.

WritePtr()

Purpose:

Write a Toolbox Ptr block to a Stream.

Access :

Public

Prototype:

SInt32 WritePtr(
  Ptr inPtr);
Parameters:

 

Ptr  
inPtr  
Pointer block to write  

Return:

Returns the number of bytes written.

Remarks:

A Ptr block is written as a 4-byte count (size of the Ptr), followed by the contents of the Ptr block.

:

LStream& operator << ( TypeParameter )

Type Parameter:

double, float, unsigned long, long, unsigned short, short, char, unsigned char, signed char, char **, const Point&, const Rect&, const char*, const unsigned char*, double&, float&, unsigned long&, long&, unsigned short&, char&, unsigned char&, signed char&, char**&, Point&, Rect&, char*, unsigned char*

Purpose:

Public

Access :

Public

Prototype:

LStream& operator << (TypeParameter inNum);
Parameters:

Variable

Return:

None

LStream& operator >> ( TypeParameter )

Type Parameter:

double, float, unsigned long, long, unsigned short, short, char, unsigned char, signed char, char **, const Point&, const Rect&, const char*, const unsigned char*, double&, float&, unsigned long&, long&, unsigned short&, char&, unsigned char&, signed char&, char**&, Point&, Rect&, char*, unsigned char*

Purpose:

Public

Access :

Public

Prototype:

LStream& operator >> (TypeParameter inNum);
Parameters:

Variable

Return:

None

LStream& operator =

Purpose:

Assignment constructor.

Access :

Public

Prototype:

LStream& operator = (const LStream& inOriginal);
Parameters:

 

const LStream&  
inOriginal  
Address of original LStream object  

Return:

Returns address of LStream object.

Remarks:

operator = does not create a duplicate of the stream, but assigns a stream the same memory address as the original. If you delete one, you loose both. You have been warned.

mMarker

Purpose:

Marker position offset in bytes.

Access :

Protected

Prototype:

SInt32 mMarker;

mLength

Purpose:

Length of stream in bytes.

Access :

Protected

Prototype:

SInt32 mLength;

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000