Dillo
Classes | Public Member Functions | Private Attributes | List of all members
lout::misc::StringBuffer Class Reference

A class for fast concatenation of a large number of strings. More...

#include <misc.hh>

Classes

struct  Node
 

Public Member Functions

 StringBuffer ()
 
 ~StringBuffer ()
 
void append (const char *str)
 Append a NUL-terminated string to the buffer, with copying. More...
 
void appendInt (int n)
 
void appendPointer (void *p)
 
void appendBool (bool b)
 
void appendNoCopy (char *str)
 Append a NUL-terminated string to the buffer, without copying. More...
 
const char * getChars ()
 Return a NUL-terminated strings containing all appended strings. More...
 
void clear ()
 Remove all strings appended to the string buffer. More...
 

Private Attributes

NodefirstNode
 
NodelastNode
 
int numChars
 
char * str
 
bool strValid
 

Detailed Description

A class for fast concatenation of a large number of strings.

Constructor & Destructor Documentation

lout::misc::StringBuffer::StringBuffer ( )

References firstNode, lastNode, numChars, str, and strValid.

lout::misc::StringBuffer::~StringBuffer ( )

References clear(), and str.

Member Function Documentation

void lout::misc::StringBuffer::append ( const char *  str)
inline
void lout::misc::StringBuffer::appendBool ( bool  b)
inline
void lout::misc::StringBuffer::appendInt ( int  n)
inline
void lout::misc::StringBuffer::appendNoCopy ( char *  str)

Append a NUL-terminated string to the buffer, without copying.

No copy is made, so this method should only be used in cases, where the string would otherwise be freed again. (This method may then save some CPU cycles.)

References lout::misc::StringBuffer::Node::data, firstNode, lastNode, lout::misc::StringBuffer::Node::next, numChars, str, and strValid.

Referenced by append(), and dw::core::SelectionState::copy().

void lout::misc::StringBuffer::appendPointer ( void *  p)
inline
void lout::misc::StringBuffer::clear ( )

Remove all strings appended to the string buffer.

References lout::misc::StringBuffer::Node::data, firstNode, lastNode, lout::misc::StringBuffer::Node::next, numChars, and strValid.

Referenced by ~StringBuffer().

const char * lout::misc::StringBuffer::getChars ( )

Member Data Documentation

Node* lout::misc::StringBuffer::firstNode
private
Node * lout::misc::StringBuffer::lastNode
private

Referenced by appendNoCopy(), clear(), and StringBuffer().

int lout::misc::StringBuffer::numChars
private
char* lout::misc::StringBuffer::str
private
bool lout::misc::StringBuffer::strValid
private

The documentation for this class was generated from the following files: