|
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 57 of file bufferstore.cc.
| bufferStore::~bufferStore | ( | ) |
Destroys a bufferStore instance.
Definition at line 89 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 47 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 182 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 159 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 176 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 199 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 164 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 171 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 193 of file bufferstore.cc.
|
private |
Definition at line 148 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 143 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 98 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 106 of file bufferstore.cc.
| unsigned long bufferStore::getLen | ( | ) | const |
Retrieves the length of a bufferStore.
Definition at line 94 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 113 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 120 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 102 of file bufferstore.cc.
| void bufferStore::init | ( | ) |
Initializes the bufferStore.
All data is removed, the length is reset to 0.
Definition at line 77 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 82 of file bufferstore.cc.
| bufferStore & bufferStore::operator= | ( | const bufferStore & | a | ) |
Copies a bufferStore.
Definition at line 67 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 212 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 218 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 207 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 124 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.