|
plptools
|
A generic container for an array of bytes. More...
#include <bufferstore.h>
Public Member Functions | |
| BufferStore () | |
| Constructs a new BufferStore. More... | |
| BufferStore (const unsigned char *buf, long len) | |
| Constructs a new BufferStore and initializes its content. More... | |
| ~BufferStore () | |
| Destroys a BufferStore instance. More... | |
| BufferStore (const BufferStore &b) | |
| Constructs a new BufferStore and initializes its content. More... | |
| BufferStore & | operator= (const BufferStore &) |
| Copies a BufferStore. More... | |
| unsigned long | getLen () const |
| Retrieves the length of a BufferStore. More... | |
| unsigned char | getByte (long pos=0) const |
| Retrieves the byte at index pos. More... | |
| uint16_t | getWord (long pos=0) const |
| Retrieves the word at index pos. More... | |
| uint32_t | getDWord (long pos=0) const |
| Retrieves the dword at index pos. More... | |
| int32_t | getSDWord (long pos=0) const |
| Retrieves the signed dword at index pos. More... | |
| const char * | getString (long pos=0) const |
| Retrieves the characters at index pos. More... | |
| void | discardFirstBytes (int len=0) |
| Removes bytes from the start of the buffer. More... | |
| bool | empty () const |
| Tests if the BufferStore is empty. More... | |
| void | init () |
| Initializes the BufferStore. More... | |
| void | init (const unsigned char *buf, long len) |
| Initializes the BufferStore with a given data. More... | |
| void | addByte (unsigned char c) |
| Appends a byte to the content of this instance. More... | |
| void | addWord (int w) |
| Appends a word to the content of this instance. More... | |
| void | addDWord (long dw) |
| Appends a dword to the content of this instance. More... | |
| void | addString (const char *s) |
| Appends a string to the content of this instance. More... | |
| void | addStringT (const char *s) |
| Appends a string to the content of this instance. More... | |
| void | addBytes (const unsigned char *buf, int len) |
| Appends data to the content of this instance. More... | |
| void | addBuff (const BufferStore &b, long maxLen=-1) |
| Appends data to the content of this instance. More... | |
| void | truncate (long newLen) |
| Truncates the buffer. More... | |
| void | prependByte (unsigned char c) |
| Prepends a byte to the content of this instance. More... | |
| void | prependWord (int w) |
| Prepends a word to the content of this instance. More... | |
Private Types | |
| enum | c { MIN_LEN = 300 } |
Private Member Functions | |
| void | checkAllocd (long newLen) |
Private Attributes | |
| long | len |
| long | lenAllocd |
| long | start |
| unsigned char * | buff |
Friends | |
| std::ostream & | operator<< (std::ostream &s, const BufferStore &m) |
| Prints a dump of the content. More... | |
A generic container for an array of bytes.
BufferStore provides an array of bytes which can be accessed using various types.
Definition at line 37 of file bufferstore.h.
|
private |
| Enumerator | |
|---|---|
| MIN_LEN | |
Definition at line 255 of file bufferstore.h.
| BufferStore::BufferStore | ( | ) |
Constructs a new BufferStore.
Definition at line 39 of file bufferstore.cc.
| BufferStore::BufferStore | ( | const unsigned char * | buf, |
| long | len | ||
| ) |
Constructs a new BufferStore and initializes its content.
| buf | Pointer to data for initialization. |
| len | Length of data for initialization. |
Definition at line 55 of file bufferstore.cc.
| BufferStore::~BufferStore | ( | ) |
Destroys a BufferStore instance.
Definition at line 86 of file bufferstore.cc.
| BufferStore::BufferStore | ( | const BufferStore & | b | ) |
Constructs a new BufferStore and initializes its content.
| b | A BufferStore, whose content is used for initialization. |
Definition at line 46 of file bufferstore.cc.
| void BufferStore::addBuff | ( | const BufferStore & | b, |
| long | maxLen = -1 |
||
| ) |
Appends data to the content of this instance.
| 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. |
Definition at line 180 of file bufferstore.cc.
| void BufferStore::addByte | ( | unsigned char | c | ) |
Appends a byte to the content of this instance.
| c | The byte to append. |
Definition at line 157 of file bufferstore.cc.
| void BufferStore::addBytes | ( | const unsigned char * | buf, |
| int | len | ||
| ) |
Appends data to the content of this instance.
| buf | The data to append. |
| len | Length of data. |
Definition at line 174 of file bufferstore.cc.
| void BufferStore::addDWord | ( | long | dw | ) |
Appends a dword to the content of this instance.
| dw | The dword to append. |
Definition at line 197 of file bufferstore.cc.
| void BufferStore::addString | ( | const char * | s | ) |
Appends a string to the content of this instance.
The trailing zero byte is not copied to the content.
| s | The string to append. |
Definition at line 162 of file bufferstore.cc.
| void BufferStore::addStringT | ( | const char * | s | ) |
Appends a string to the content of this instance.
The trailing zero byte is copied to the content.
| s | The string to append. |
Definition at line 169 of file bufferstore.cc.
| void BufferStore::addWord | ( | int | w | ) |
Appends a word to the content of this instance.
| w | The word to append. |
Definition at line 191 of file bufferstore.cc.
|
private |
Definition at line 146 of file bufferstore.cc.
| void BufferStore::discardFirstBytes | ( | int | len = 0 | ) |
Removes bytes from the start of the buffer.
| len | Number of bytes to remove. |
Definition at line 141 of file bufferstore.cc.
|
inline |
Tests if the BufferStore is empty.
Definition at line 258 of file bufferstore.h.
| unsigned char BufferStore::getByte | ( | long | pos = 0 | ) | const |
Retrieves the byte at index pos.
| pos | The index of the byte to retrieve. |
Definition at line 96 of file bufferstore.cc.
| uint32_t BufferStore::getDWord | ( | long | pos = 0 | ) | const |
Retrieves the dword at index pos.
| pos | The index of the dword to retrieve. |
Definition at line 104 of file bufferstore.cc.
| unsigned long BufferStore::getLen | ( | ) | const |
Retrieves the length of a BufferStore.
Definition at line 92 of file bufferstore.cc.
| int32_t BufferStore::getSDWord | ( | long | pos = 0 | ) | const |
Retrieves the signed dword at index pos.
| pos | The index of the signed dword to retrieve. |
Definition at line 111 of file bufferstore.cc.
| const char * BufferStore::getString | ( | long | pos = 0 | ) | const |
Retrieves the characters at index pos.
| pos | The index of the characters to retrieve. |
Definition at line 118 of file bufferstore.cc.
| uint16_t BufferStore::getWord | ( | long | pos = 0 | ) | const |
Retrieves the word at index pos.
| pos | The index of the word to retrieve. |
Definition at line 100 of file bufferstore.cc.
| void BufferStore::init | ( | ) |
Initializes the BufferStore.
All data is removed, the length is reset to 0.
Definition at line 74 of file bufferstore.cc.
| void BufferStore::init | ( | const unsigned char * | buf, |
| long | len | ||
| ) |
Initializes the BufferStore with a given data.
| buf | Pointer to data to initialize from. |
| len | Length of data. |
Definition at line 79 of file bufferstore.cc.
| BufferStore & BufferStore::operator= | ( | const BufferStore & | a | ) |
Copies a BufferStore.
Definition at line 64 of file bufferstore.cc.
| void BufferStore::prependByte | ( | unsigned char | c | ) |
Prepends a byte to the content of this instance.
| c | The byte to append. |
Definition at line 211 of file bufferstore.cc.
| void BufferStore::prependWord | ( | int | w | ) |
Prepends a word to the content of this instance.
| w | The word to append. |
Definition at line 217 of file bufferstore.cc.
| void BufferStore::truncate | ( | long | newLen | ) |
Truncates the buffer.
If the buffer is smaller, does nothing.
| newLen | The new length of the buffer. |
Definition at line 205 of file bufferstore.cc.
|
friend |
Prints a dump of the content.
| s | The stream to write to. |
| m | The BufferStore do be dumped. |
Definition at line 122 of file bufferstore.cc.
|
private |
Definition at line 253 of file bufferstore.h.
|
private |
Definition at line 250 of file bufferstore.h.
|
private |
Definition at line 251 of file bufferstore.h.
|
private |
Definition at line 252 of file bufferstore.h.