nis-util
1.0.D108
|
#include <accumulator.h>
Public Member Functions | |
~rcstring_accumulator () | |
rcstring_accumulator () | |
rcstring_accumulator (const rcstring_accumulator &rhs) | |
rcstring_accumulator & | operator= (const rcstring_accumulator &rhs) |
void | push_back (char c) |
void | push_back (unsigned char c) |
void | push_back (const char *text) |
void | push_back (const char *text, size_t text_size) |
void | push_back (const rcstring &text) |
void | pop_back (void) |
unsigned char | back (void) const |
void | push_front (unsigned char c) |
void | pop_front (void) |
void | pop_front (size_t nbytes) |
unsigned char | front (void) const |
rcstring | mkstr (void) const |
void | clear (void) |
size_t | size (void) const |
bool | empty (void) const |
const char * | get_data (void) const |
Private Member Functions | |
void | grow (size_t nbytes) |
Private Attributes | |
char * | data |
size_t | data_size |
size_t | data_alloc |
The rcstring_accumulator class is used to represent an efficient buffer for accumulating strings.
Definition at line 28 of file accumulator.h.
The destructor. It is not virtual, thou shalt not derive from this class.
Definition at line 22 of file accumulator.cc.
The default constructor.
Definition at line 22 of file default_constructor.cc.
rcstring_accumulator::rcstring_accumulator | ( | const rcstring_accumulator & | rhs | ) |
The copy constructor.
rhs | The right hand side of the initialization. |
Definition at line 24 of file copy_constructor.cc.
unsigned char rcstring_accumulator::back | ( | void | ) | const |
void rcstring_accumulator::clear | ( | void | ) | [inline] |
The clear method is used to discard the contents of the accumulator.
The allocated data of the accumulator is not discarded, so re-using an accumulator is more time-efficient than repeatedly instantiating accumulator instances.
Definition at line 167 of file accumulator.h.
bool rcstring_accumulator::empty | ( | void | ) | const [inline] |
The empty method is used to determine whether or not the accumulator is empty.
Definition at line 179 of file accumulator.h.
unsigned char rcstring_accumulator::front | ( | void | ) | const |
const char* rcstring_accumulator::get_data | ( | void | ) | const [inline] |
The get_data method is used to obtain the pointer to the base of the data array.
Definition at line 185 of file accumulator.h.
void rcstring_accumulator::grow | ( | size_t | nbytes | ) | [private] |
rcstring rcstring_accumulator::mkstr | ( | void | ) | const |
rcstring_accumulator & rcstring_accumulator::operator= | ( | const rcstring_accumulator & | rhs | ) |
The assignment operator.
rhs | The right hand side of the assignment. |
Definition at line 25 of file assignment_operator.cc.
void rcstring_accumulator::pop_back | ( | void | ) |
The pop_back method is used to discard a single byte from the end of the data. It is safe to do this to an empty accumulator.
Definition at line 23 of file pop_back.cc.
void rcstring_accumulator::pop_front | ( | void | ) |
The pop_front method is used to discard a single byte from the start of the data. This is expensive, use sparingly. It is safe to call this on an empty accumulator.
Definition at line 25 of file pop_front.cc.
void rcstring_accumulator::pop_front | ( | size_t | nbytes | ) |
The pop_front method is used to discard a number of bytes from the start of the data. This is expensive, use sparingly.
It is safe to request that more bytes be removed from the accumulator than the accumulator contains, the result will be an empty accumulator.
nbytes | The number of bytes to discard. |
Definition at line 25 of file pop_front_n.cc.
void rcstring_accumulator::push_back | ( | char | c | ) |
The push_back method is used to append a single byte to the end of the accumulated text, in data.
c | The byte value to be appended. |
Definition at line 23 of file push_back_5.cc.
void rcstring_accumulator::push_back | ( | unsigned char | c | ) |
The push_back method is used to append a single byte to the end of the accumulated text, in data.
c | The byte value to be appended. |
Definition at line 23 of file push_back_4.cc.
void rcstring_accumulator::push_back | ( | const char * | text | ) |
The push_back method is used to append a C string to the end of the accumulated text, in data.
text | The bytes to be appended, NUL terminated. |
Definition at line 25 of file push_back_2.cc.
void rcstring_accumulator::push_back | ( | const char * | text, |
size_t | text_size | ||
) |
The push_back method is used to append a C string to the end of the accumulated text, in data.
text | The bytes to be appended. |
text_size | The number of bytes to be appended. |
Definition at line 25 of file push_back_3.cc.
void rcstring_accumulator::push_back | ( | const rcstring & | text | ) |
The push_back method is used to append a C string to the end of the accumulated text, in data.
text | The bytes to be appended. |
Definition at line 23 of file push_back_1.cc.
void rcstring_accumulator::push_front | ( | unsigned char | c | ) |
The push_front method is used to insert a byte at the start of the accumulator. This is expensive, use sparingly.
c | The byte to be inserted. |
Definition at line 25 of file push_front.cc.
size_t rcstring_accumulator::size | ( | void | ) | const [inline] |
The size method is used to obtain the current size of the accumulator, in bytes.
Definition at line 173 of file accumulator.h.
char* rcstring_accumulator::data [private] |
The data instance variable is used to remember the base address of a dynamically allocated array of bytes, used to hold the accumulated text.
assert(!data == !data_alloc);
Definition at line 195 of file accumulator.h.
size_t rcstring_accumulator::data_alloc [private] |
The data_alloc instance variable is used to remember how many bytes have been allocated for the data array.
assert(!data == !data_alloc);
Definition at line 212 of file accumulator.h.
size_t rcstring_accumulator::data_size [private] |
The data_size instance variable is used to remember how many bytes of the data array have been used.
assert(!data == !data_size); assert(data_size <= data_alloc);
Definition at line 204 of file accumulator.h.