#include <buffer.h>
Public Member Functions | |
| Buffer () | |
| Default constructor. | |
| ~Buffer () | |
| Default destructor. | |
| void | packInt (uint32_t val) |
| Packs a 32 bit int into the buffer. | |
| void | packInt64 (uint64_t val) |
| Packs a 64 bit int into the buffer. | |
| void | packString (const std::string &val) |
| Packs a string into the buffer. | |
| uint32_t | unpackInt () |
| Unpacks a 32 bit int from the buffer. | |
| uint64_t | unpackInt64 () |
| Unpacks a 64 bit int from the buffer. | |
| std::string | unpackString () |
| Unpacks a string from the buffer. | |
| uint32_t | peekInt (uint32_t offset) |
| Peeks at the value of the 32 bit int at an offset into the buffer. | |
| void | createHeader (uint32_t ver, uint32_t seqnum, uint32_t type, uint32_t len, uint32_t fver=0) |
| Creates a header for the given parameters. | |
| bool | readHeader (uint32_t &ver, uint32_t &seqnum, uint32_t &type, uint32_t &len, uint32_t &fver) |
| Reads a header, passing back the parameters. | |
| void | setData (char *buff, uint32_t len) |
| Sets the buffer with the given data. | |
| char * | getData () |
| Gets the data in the buffer. | |
| uint32_t | getLength () |
| Gets the current length of the data in the buffer. | |
| void | setStringPadding (bool nsp) |
| Sets if String Padding is turned on. | |
| bool | getStringPadding () const |
| Checks if String Padding is turned on. | |
Supports unpacking and packing various base types and creating and reading the frame header.
| void TPProto::Buffer::packInt | ( | uint32_t | val | ) |
Packs a 32 bit int into the buffer.
| val | The value to be packed. |
| void TPProto::Buffer::packInt64 | ( | uint64_t | val | ) |
Packs a 64 bit int into the buffer.
| val | The value to be packed. |
| void TPProto::Buffer::packString | ( | const std::string & | val | ) |
Packs a string into the buffer.
| val | The string to be packed. |
| uint32_t TPProto::Buffer::unpackInt | ( | ) |
Unpacks a 32 bit int from the buffer.
| uint64_t TPProto::Buffer::unpackInt64 | ( | ) |
Unpacks a 64 bit int from the buffer.
| std::string TPProto::Buffer::unpackString | ( | ) |
Unpacks a string from the buffer.
| uint32_t TPProto::Buffer::peekInt | ( | uint32_t | offset | ) |
Peeks at the value of the 32 bit int at an offset into the buffer.
This operation does not change the r/w position.
| offset | The offset into the buffer. |
| void TPProto::Buffer::createHeader | ( | uint32_t | ver, | |
| uint32_t | seqnum, | |||
| uint32_t | type, | |||
| uint32_t | len, | |||
| uint32_t | fver = 0 | |||
| ) |
Creates a header for the given parameters.
The buffer is set to the header.
| ver | The version of the protocol. | |
| seqnum | The sequence number. | |
| type | The type number. | |
| len | The length of the data of the frame in bytes. | |
| fver | The frame type version, defaults to 0 |
| bool TPProto::Buffer::readHeader | ( | uint32_t & | ver, | |
| uint32_t & | seqnum, | |||
| uint32_t & | type, | |||
| uint32_t & | len, | |||
| uint32_t & | fver | |||
| ) |
Reads a header, passing back the parameters.
Some checks are performed to check that the buffer is a valid header.
| ver | A reference to where the version number of the protocol will be stored. | |
| seqnum | A reference to where the sequence number will be stored. | |
| type | A reference to where the type number will be stored. | |
| len | A reference to where the length of the data of the frame in bytes should be stored. | |
| fver | A reference to where the frame type version will be stored. |
| void TPProto::Buffer::setData | ( | char * | buff, | |
| uint32_t | len | |||
| ) |
Sets the buffer with the given data.
Should not be called in general, used by FrameCodec to set the data received from the network.
| buff | The char array of data to be copied as the buffer. | |
| len | The length of the array of data for the buffer. |
| char * TPProto::Buffer::getData | ( | ) |
Gets the data in the buffer.
Should not be called in general, used by FrameCodec to send the data on the network.
| uint32_t TPProto::Buffer::getLength | ( | ) |
Gets the current length of the data in the buffer.
| void TPProto::Buffer::setStringPadding | ( | bool | nsp | ) |
Sets if String Padding is turned on.
Should only be called by FrameCodec for use in the String Padding filter.
| nsp | The new bool value for String Padding. |
| bool TPProto::Buffer::getStringPadding | ( | ) | const |
Checks if String Padding is turned on.
1.5.1