String Builder. More...
#include <rstringbuilder.h>
Public Member Functions | |
RStringBuilder (void) | |
RStringBuilder & | operator+= (const RChar src) |
RStringBuilder & | operator+= (const char src) |
RStringBuilder & | operator+= (const RString &src) |
RStringBuilder & | operator+= (const RChar *src) |
RStringBuilder & | operator+= (const char *src) |
const RString & | operator() (void) |
void | Clear (void) |
Private Member Functions | |
void | AppendBuffer (void) |
Private Attributes | |
RChar | Buffer [1025] |
RString | String |
size_t | Len |
RChar * | CurChar |
Detailed Description
String Builder.
The RStringBuilder provides a class to build efficiently a RString by adding a small number of characters (eventually one). It avoids to reallocate infinitively the internal buffer of a RString.
The implementation of the RTextFile::GetChars illustrates how it works:
Constructor & Destructor Documentation
RStringBuilder | ( | void | ) |
Constructor of a string builder.
Member Function Documentation
RStringBuilder& operator+= | ( | const RChar | src | ) |
Add a character to the string.
- Parameters
-
src Character.
RStringBuilder& operator+= | ( | const char | src | ) |
Add a character to the string.
- Parameters
-
src Character.
RStringBuilder& operator+= | ( | const RString & | src | ) |
Add a RString to the string.
- Parameters
-
src Source string.
RStringBuilder& operator+= | ( | const RChar * | src | ) |
Add some characters to the string.
- Parameters
-
src Source string.
RStringBuilder& operator+= | ( | const char * | src | ) |
Add a "C string" to the string.
- Parameters
-
src Source string.
const RString& operator() | ( | void | ) |
Get the string to build. If some characters are not concatenated, the method add them before returning the string.
- Returns
- the string.
void Clear | ( | void | ) |
Clear the string builder to construct a new string.
|
private |
Append the current content of the internal buffer to the string.
Field Documentation
|
private |
A static internal buffer used to hold intermediate characters.
|
private |
The string to build.
|
private |
Number of characters actually added but not concatenated to the string.
|
private |
Pointer to the current character in the buffer.