GBytePipe Class Reference

Data storage class. More...

#include <GContainers.h>

Inheritance diagram for GBytePipe:

GStream GDom GStringPipe

List of all members.

Classes

struct  Block

Public Member Functions

 GBytePipe (int PreAlloc=0)
 Constructor.
virtual ~GBytePipe ()
 Desructor.
virtual bool IsEmpty ()
 Returns true if the container is empty.
virtual void Empty ()
 Empties the container freeing any memory used.
virtual void * New (int AddBytes=0)
virtual int64 Peek (uchar *Ptr, int Size)
virtual int64 Peek (GStreamI *Str, int Size)
int StringAt (char *Str)
int64 GetSize ()
 Gets the total bytes in the container.
int Read (void *Buffer, int Size, int Flags=0)
 Reads bytes off the start of the container.
int Write (void *Buffer, int Size, int Flags=0)
 Writes bytes to the end of the container.
int Pop (short &i)
 Reads a 2 byte integer from the start.
int Pop (int &i)
 Reads a 4 byte integer from the start.
int Pop (double &i)
 Reads a double from the start.
int Push (short i)
 Writes a 2 byte int to the end.
int Push (int i)
 Writes a 2 byte int to the end.
int Push (double i)
 Writes a double to the end.


Detailed Description

Data storage class.

Allows data to be buffered in separate memory blocks and then written to a continuous block for processing. Works as a first in first out que. You can (and should) provide a suitable PreAlloc size to the constructor. This can reduce the number of blocks of memory being used (and their associated alloc/free time and tracking overhead) in high volume situations.


Constructor & Destructor Documentation

GBytePipe::GBytePipe ( int  PreAlloc = 0  ) 

Constructor.

Parameters:
PreAlloc  Sets the block size, which means allocating ahead and then joining together smaller inserts into 1 continuous block.


Member Function Documentation

void * GBytePipe::New ( int  AddBytes = 0  )  [virtual]

Returns a dynamically allocated block that contains all the data in the container in a continuous block.

Parameters:
AddBytes  If this is > 0 then the function add's the specified number of bytes containing the value 0 on the end of the block. This is useful for NULL terminating strings or adding buffer space on the end of the block returned.

References GetSize(), and Read().

Referenced by Html2::GHtml2::GetSelection(), GHtml::GetSelection(), GMemStream::GMemStream(), LgiNewConvertCp(), GStringPipe::NewStr(), and GStringPipe::NewStrW().

int64 GBytePipe::Peek ( GStreamI *  Str,
int  Size 
) [virtual]

Reads data from the start of the container without removing it from the que. Returns the bytes copied.

Parameters:
Str  Buffer for output
Size  Bytes to look at

References GetSize(), GBytePipe::Block::Next, GBytePipe::Block::Ptr(), and GBytePipe::Block::Size.

int64 GBytePipe::Peek ( uchar *  Ptr,
int  Size 
) [virtual]

Reads data from the start of the container without removing it from the que. Returns the bytes copied.

Parameters:
Ptr  Buffer for output
Size  Bytes to look at

References GetSize(), GBytePipe::Block::Next, GBytePipe::Block::Ptr(), and GBytePipe::Block::Size.

int GBytePipe::StringAt ( char *  Str  ) 

Looks for a sub-string in the buffered data

Returns:
the index of the start of the string or -1 if not found

References GBytePipe::Block::Next, GBytePipe::Block::Ptr(), and GBytePipe::Block::Used.


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

Generated on Wed Dec 1 15:41:02 2010 for Lgi by  doxygen 1.5.7.1