# class bufferStore

A generic container for an array of bytes. More...

Definition | `#include <bufferstore.h>`
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- bufferStore ()
- bufferStore (const unsigned char *, long)
- ~bufferStore ()
- bufferStore (const bufferStore &)
- bufferStore & operator = (const bufferStore &)
- unsigned long getLen () const
- unsigned char getByte (long pos = 0) const
- u_int16_t getWord (long pos = 0) const
- u_int32_t getDWord (long pos = 0) const
- const char * getString (long pos = 0) const
- void discardFirstBytes (int len = 0)
- friend std::ostream & operato ()
- bool empty () const
- void init ()
- void init (const unsigned char * buf, long len)
- void addByte (unsigned char c)
- void addWord (int)
- void addDWord (long dw)
- void addString (const char *s)
- void addStringT (const char *s)
- void addBytes (const unsigned char *buf, int len)
- void addBuff (const bufferStore &b, long maxLen = -1)
- void truncate (long newLen)
- void prependByte (unsigned char c)
- void prependWord (int)

## Detailed Description

A generic container for an array of bytes.

bufferStore provides an array of bytes which can be accessed using various types.

bufferStore ()

### bufferStore

Constructs a new bufferStore.

bufferStore (const unsigned char *, long)

### bufferStore

Constructs a new bufferStore and initializes its content.

Parameters:

buf | Pointer to data for initialization.
len | Length of data for initialization.

~bufferStore ()

### ~bufferStore

Destroys a bufferStore instance.

bufferStore (const bufferStore &)

### bufferStore

Constructs a new bufferStore and initializes its content.

Parameters:

b | A bufferStore, whose content is used for initialization.

bufferStore & operator = (const bufferStore &)

### operator =

Copies a bufferStore.

unsigned long getLen ()

### getLen

[const]

Retrieves the length of a bufferStore.

Returns: The current length of the contents in bytes.

unsigned char getByte (long pos = 0)

### getByte

[const]

Retrieves the byte at index pos.

Parameters:

pos | The index of the byte to retrieve.

Returns: The value of the byte at index pos

u_int16_t getWord (long pos = 0)

### getWord

[const]

Retrieves the word at index pos.

Parameters:

pos | The index of the word to retrieve.

Returns: The value of the word at index pos

u_int32_t getDWord (long pos = 0)

### getDWord

[const]

Retrieves the dword at index pos.

Parameters:

pos | The index of the dword to retrieve.

Returns: The value of the dword at index pos

const char * getString (long pos = 0)

### getString

[const]

Retrieves the characters at index pos.

Parameters:

pos | The index of the characters to retrieve.

Returns: A pointer to characters at index pos

void discardFirstBytes (int len = 0)

### discardFirstBytes

Removes bytes from the start of the buffer.

Parameters:

len | Number of bytes to remove.

friend std::ostream & operato ()

### operato

Prints a dump of the content.

Mainly used for debugging purposes.

Parameters:

s | The stream to write to.
b | The bufferStore do be dumped.

Returns: The stream.

bool empty ()

### empty

[const]

Tests if the bufferStore is empty.

Returns: true, if the bufferStore is empty. false, if it contains data.

void init ()

### init

Initializes the bufferStore.

All data is removed, the length is reset to 0.

void init (const unsigned char * buf, long len)

### init

Initializes the bufferStore with a given data.

Parameters:

buf | Pointer to data to initialize from.
len | Length of data.

void addByte (unsigned char c)

### addByte

Appends a byte to the content of this instance.

Parameters:

c | The byte to append.

void addWord (int)

### addWord

Appends a word to the content of this instance.

Parameters:

w | The word to append.

void addDWord (long dw)

### addDWord

Appends a dword to the content of this instance.

Parameters:

dw | The dword to append.

void addString (const char *s)

### addString

Appends a string to the content of this instance.

The trailing zero byte is not copied to the content.

Parameters:

s | The string to append.

void addStringT (const char *s)

### addStringT

Appends a string to the content of this instance.

The trailing zero byte is copied to the content.

Parameters:

s | The string to append.

void addBytes (const unsigned char *buf, int len)

### addBytes

Appends data to the content of this instance.

Parameters:

buf | The data to append.
len | Length of data.

void addBuff (const bufferStore &b, long maxLen = -1)

### addBuff

Appends data to the content of this instance.

Parameters:

b | The bufferStore whose content to append.
maxLen | Length of content to append. If `maxLen` is less than 0 or greater than the current length of `b` , then the whole content of `b` is appended.

void truncate (long newLen)

### truncate

Truncates the buffer. If the buffer is smaller, does nothing.

Parameters:

newLen | The new length of the buffer.

void prependByte (unsigned char c)

### prependByte

Prepends a byte to the content of this instance.

Parameters:

c | The byte to append.

void prependWord (int)

### prependWord

Prepends a word to the content of this instance.

Parameters:

w | The word to append.

Generated by: rrt on drom on Mon Nov 26 16:06:15 2007, using kdoc 2.0a54.