Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

StringBuffer

 

class StringBuffer : private NoCopy

A class useful when working with code that expects a character buffer, like C code. It supports constant time pick assignment to and from String.

 

 

Constructor Detail

 

StringBuffer()

Constructs empty buffer.

 


 

StringBuffer(int len)

Constructs buffer of len characters.

 


 

StringBuffer(String& s)

Assigns content of s to StringBuffer. Clears s.

 


 

~StringBuffer()

Default destructor.

 

 

Public Method List

 

char *Begin()

char *begin()

Returns a pointer to the buffer of characters. Mutating operations invalidate this pointer. Note that this is non-const operation and writes terminating zero at *end().

 


 

char *End()

char *end()

Returns begin() + GetCount(). Mutating operations invalidate this pointer. Note that this is non-const operation and writes terminating zero at *end().

 


 

void Cat(int c)

Appends single character c.

 


 

void Cat(int c, int count)

Appends count characters c.

 


 

void Cat(const char *s)

void Cat(const String& s)

Appends the string s.

 


 

void Cat(const char *s, int l)

Appends the first l characters of s.

 


 

void Cat(const char *s, const char *e)

Same as Cat(s, e - s).

 


 

int GetLength() const

int GetCount() const

Returns the number of characters in the buffer.

 


 

void SetLength(int l)

void SetCount(int l)

Sets the length of the character buffer to l.

 


 

void Strlen()

Sets the length of the character buffer to the length of the zero terminated string stored in the buffer (up to the first zero character). Useful for converting C strings returned from system to String.

 


 

void Clear()

Clears the contents of the string buffer.

 


 

void Reserve(int r)

Hint to preallocate internal buffer for concatenation of next r characters.

 


 

void Shrink()

Shrinks the internal buffer to minimize memory consumption.

 


 

int GetAlloc() const

Returns the maximum number of characters in the internal buffer.

 


 

char& operator*()

Returns *begin().

 


 

char& operator[](int i)

Returns begin()[i].

 


 

operator char*()

char *operator~()

Returns begin().

 


 

operator byte*()

Returns (byte *)begin().

 


 

operator void*()

Returns begin().

 


 

void operator=(String& s)

Clears the string buffer and assigns the content of s. Clears s.

 

 

 

 

WStringBuffer

 

class WStringBuffer : private NoCopy

A class useful when working with code that expects a wide character buffer, like C code. It supports constant time pick assignment to and from WString.

 

 

Constructor Detail

 

WStringBuffer()

Constructs empty buffer.

 


 

WStringBuffer(int len)

Constructs buffer of len characters.

 


 

WStringBuffer(WString& s)

Assigns content of s to StringBuffer. Clears s.

 


 

~WStringBuffer()

Default destructor.

 

 

Public Method List

 

wchar *Begin()

wchar *begin()

Returns a pointer to the buffer of characters. Mutating operations invalidate this pointer. Note that this is non-const operation and writes terminating zero at *end().

 


 

wchar *End()

wchar *end()

Returns begin() + GetCount(). Mutating operations invalidate this pointer. Note that this is non-const operation and writes terminating zero at *end().

 


 

void Cat(int c)

Appends single character c.

 


 

void Cat(int c, int count)

Appends count characters c.

 


 

void Cat(const wchar *s)

void Cat(const WString& s)

void Cat(const char *s)

Appends the string s.

 


 

void Cat(const wchar *s, int l)

Appends the first l characters of s.

 


 

void Cat(const wchar *s, const wchar *e)

Same as Cat(s, e - s).

 


 

int GetLength() const

int GetCount() const

Returns the number of characters in the buffer.

 


 

void SetLength(int l)

void SetCount(int l)

Sets the length of the character buffer to l.

 


 

void Strlen()

Sets the length of the character buffer to the length of the zero terminated string stored in the buffer (up to the first zero character). Useful for converting C strings returned from system to String.

 


 

void Clear()

Clears the contents of the string buffer.

 


 

void Reserve(int r)

Preallocates internal buffer (avoids resizing of internal buffer up to r characters).

 


 

int GetAlloc() const

Returns the maximum number of characters in the internal buffer.

 


 

wchar& operator*()

Returns *begin().

 


 

wchar& operator[](int i)

Returns begin()[i].

 


 

operator wchar*()

wchar *operator~()

Returns begin().

 


 

operator int16*()

Returns (int16*)begin().

 


 

operator void*()

Returns begin().

 


 

void operator=(WString& s)

Clears the string buffer and assigns the content of s. Clears s.

 

 

Do you want to contribute?