WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
WXP::Buffer Class Reference

This class creates a generic buffer for data. More...

#include "../include/Buffer.h"

Public Member Functions

int initClass ()
int init (int rsize)
 Buffer ()
 Buffer (int rsize)
 ~Buffer ()
 Buffer (const Buffer &data)
Buffer operator= (const Buffer &data)
int copy (const Buffer &data)
int clear ()
int resize (int rsize)
int check (int rsize)
int add (unsigned char *dat, int rsize)
int insert (int loc, unsigned char *dat, int rsize)
int insert (int loc, const Buffer &data)
const unsigned char * get ()
unsigned char get (int ind)
int read (unsigned char *dat, int rsize)
int read (Buffer &buf)
int read (Buffer &buf, int rsize)
int readLine (unsigned char *dat, int rsize)
int skipLine ()
int clearUsed ()
int seek (int num)
int inc (int num)
int trunc (int num)
int equal (int off, const char *str)
int getInd ()
int getSize ()
int getAvail ()
int getMax ()
int print ()
int dump (int off, int num)
int dump (int num)
int dump ()

Friends

class File
class Zlib
class BZlib

Detailed Description

This class creates a generic buffer for data.

Author
Dan Vietor

Constructor & Destructor Documentation

◆ Buffer() [1/3]

Buffer::Buffer ( )

Constructor - Initializes the values.

References initClass().

Referenced by Buffer(), copy(), insert(), and operator=().

◆ Buffer() [2/3]

Buffer::Buffer ( int rsize)

Constructor - Size the arrays.

Parameters
rsizeThe max size of the buffer

References init(), and initClass().

◆ ~Buffer()

Buffer::~Buffer ( )

Destructor - deallocate buffer space

◆ Buffer() [3/3]

Buffer::Buffer ( const Buffer & buf)

Copy constructor.

Parameters
dataStrings class to copy from

References Buffer(), and copy().

Member Function Documentation

◆ add()

int Buffer::add ( unsigned char * dat,
int rsize )

Adds data to buffer

Parameters
datData to add
rsizeSize of data

References check().

◆ check()

int Buffer::check ( int rsize)

Checks to see if buffer is large enough to hold data, if not resizes

Parameters
rsizeThe size to check

References resize().

Referenced by add(), insert(), and insert().

◆ clear()

int Buffer::clear ( )

Clears the buffer

◆ clearUsed()

int Buffer::clearUsed ( )

Removes data already used

◆ copy()

int Buffer::copy ( const Buffer & buf)

Copy data.

Parameters
bufBuffer class to copy from

References Buffer(), and init().

Referenced by Buffer(), and operator=().

◆ dump() [1/3]

int WXP::Buffer::dump ( )
inline

Prints entire buffer

References dump().

Referenced by dump().

◆ dump() [2/3]

int WXP::Buffer::dump ( int num)
inline

Prints number of bytes from start of buffer

References dump().

Referenced by dump().

◆ dump() [3/3]

int Buffer::dump ( int off,
int num )

Prints the buffer contents

Parameters
offThe starting point
numThe number of bytes to dump

◆ equal()

int Buffer::equal ( int off,
const char * str )

Compares data in buffer to string

Parameters
offThe offset into buffer to start compare (<0 from end)
strThe string to compare against
Returns
1=equal, 0=not equal

◆ get() [1/2]

const unsigned char * WXP::Buffer::get ( )
inline

Return data starting at pointer

◆ get() [2/2]

unsigned char Buffer::get ( int i)

Gets a byte from the buffer

Parameters
iThe index to extract
Returns
The byte

◆ getAvail()

int WXP::Buffer::getAvail ( )
inline

Return the number of bytes available in buffer

◆ getInd()

int WXP::Buffer::getInd ( )
inline

Return the pointer index

◆ getMax()

int WXP::Buffer::getMax ( )
inline

Return the maximum size of buffer

◆ getSize()

int WXP::Buffer::getSize ( )
inline

Return the buffer size

◆ inc()

int Buffer::inc ( int num)

Increments the pointer in the buffer

Parameters
numThe number of bytes to increment pointer

◆ init()

int Buffer::init ( int rsize)

Initializes the values

Parameters
rsizeThe max size of the buffer

Referenced by Buffer(), and copy().

◆ initClass()

int Buffer::initClass ( )

Initializes the class values

Referenced by Buffer(), and Buffer().

◆ insert() [1/2]

int Buffer::insert ( int loc,
const Buffer & buf )

Insert another buffer

Parameters
locLocation in buffer to add new data
bufBuffer class to copy from

References Buffer(), and check().

◆ insert() [2/2]

int Buffer::insert ( int loc,
unsigned char * dat,
int rsize )

Insert data into buffer

Parameters
locLocation in buffer to add new data
datData to add
rsizeSize of data

References check().

◆ operator=()

Buffer Buffer::operator= ( const Buffer & buf)

Assignment operator. Used to overload copying

Parameters
dataString class to copy from

References Buffer(), and copy().

◆ print()

int Buffer::print ( )

Prints the values to standard output.

◆ read()

int Buffer::read ( unsigned char * dat,
int rsize )

Gets a line from the buffer

Parameters
datThe buffer to write to
rsizeThe size of the buffer
Returns
The number of bytes read

◆ readLine()

int Buffer::readLine ( unsigned char * dat,
int rsize )

Gets a line from the buffer

Parameters
datThe buffer to write to
rsizeThe size of the buffer
Returns
The number of bytes read

◆ resize()

int Buffer::resize ( int rsize)

Resizes the buffer.

Parameters
rsizeThe new maximum size

Referenced by check().

◆ seek()

int Buffer::seek ( int num)

Sets the pointer in the buffer

Parameters
numThe byte offset

◆ skipLine()

int Buffer::skipLine ( )

Skips a line from the buffer

Returns
1 if saw NL, 0 if not

◆ trunc()

int Buffer::trunc ( int num)

Truncates the data in the buffer

Parameters
numThe new size (num<0 - number of bytes to remove from end)

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