|
wavelength 1.0.0
|
Growable text buffer that is also a PrnStream. More...
#include <string.h>


Public Types | |
| enum | { npos = -1 } |
| The result of a search that finds nothing. More... | |
Public Member Functions | |
| String () | |
| Construct an empty string. | |
| String (const char *pszText) | |
| Construct a copy of a C string. | |
| String (const String &other) | |
| Copy another string. | |
| ~String () override | |
| Release the text. | |
| void | Print (const char *pszText) override |
| Append text. | |
| String & | operator= (const String &other) |
| Replace the text with a copy of another string's text. | |
| String & | operator= (const char *pszText) |
| Replace the text with a copy of a C string. | |
| String & | Clear () |
| Release the text and leave the string empty. | |
| char | operator[] (int nIndex) const |
| Report one character. | |
| String & | Replace (int nPos, int nCount, const String &text) |
| Replace a run of characters with another string's text. | |
| String & | Truncate (int nLength) |
| Cut the text to a length. | |
| String & | Erase (int nPos, int nCount) |
| Remove a run of characters. | |
| String & | operator+= (const String &other) |
| Append another string's text. | |
| String & | operator+= (const char *pszText) |
| Append a C string. | |
| String & | operator+= (char ch) |
| Append a character. | |
| int | Compare (int nPos, int nCount, const char *pszText) const |
| Compare a run of characters with a C string. | |
| int | Find (const char *pszText) const |
| Find the first occurrence of a C string in the text. | |
| int | Find (char ch) const |
| Find the first occurrence of a character. | |
| int | Find (char ch, int nPos) const |
| Find the first occurrence of a character at or after a position. | |
| int | RFind (char ch) const |
| Find the last occurrence of a character. | |
| String | Substring (int nPos) const |
| Copy the characters from a position to the end. | |
| String | Substring (int nPos, int nCount) const |
| Copy a run of characters, or the characters from a position to the end when the run reaches the end. | |
| String & | Insert (int nPos, int nCount, char ch) |
| Insert copies of one character. | |
| String & | Insert (int nPos, const String &text) |
| Insert a copy of another string's text. | |
| bool | operator< (const String &other) const |
| Report whether the text sorts before another string's text. | |
| bool | operator== (const char *pszText) const |
| Report whether the text equals a C string. | |
| bool | operator== (const String &other) const |
| Report whether the text equals another string's text. | |
| bool | operator!= (const char *pszText) const |
| Report whether the text differs from a C string. | |
| bool | operator!= (const String &other) const |
| Report whether the text differs from another string's text. | |
| String | operator+ (const char *pszText) const |
| Report a copy of the string with text appended. | |
| String | operator+ (char ch) const |
| Report a copy of the string with a character appended. | |
| String | operator+ (const String &other) const |
| Report a copy of the string with another string's text appended. | |
| void | Resize (int nLength) |
| Replace the text with nLength zero bytes. | |
| const char * | c_str () const |
| Report the text. | |
| int | GetLength () const |
| char * | GetBuffer () const |
| String () | |
| String (const char *str) | |
| Copy text. | |
| String (const String &other) | |
| Copy another String. | |
| virtual | ~String () |
| Free the buffer. | |
| virtual void | Print (const char *str) |
| Append printed text. | |
| String & | operator+= (const String &other) |
| Append another String. | |
| String & | operator+= (const char *str) |
| Append text. | |
| String & | operator= (const char *str) |
| Replace the text. | |
| String & | operator= (const String &other) |
| Replace the text with a copy of another String. | |
| bool | operator!= (const char *str) const |
| Compare with text. | |
| bool | operator!= (const String &other) const |
| Compare with another String. | |
| bool | operator== (const char *str) const |
| Compare with text. | |
| bool | operator== (const String &other) const |
| Compare with another String. | |
| bool | operator< (const String &other) const |
| Order by the bytes of the text. | |
| void | Resize (unsigned int length) |
| Replace the text with a length of zero bytes. | |
| int | Find (const char *str) const |
| Find the first occurrence of text. | |
| int | FindLast (char c) const |
| Find the last occurrence of a character. | |
| String | Substring (unsigned int pos) const |
| Copy the text from a position to the end. | |
| String | Substring (unsigned int pos, unsigned int count) const |
| Copy part of the text. | |
| String & | Replace (unsigned int pos, unsigned int count, const String &str) |
| Replace part of the text with another String. | |
| String & | Clear () |
| Empty the String. | |
| const char * | c_str () const |
| operator const char * () const | |
| unsigned int | size () const |
| Public Member Functions inherited from PrnStream | |
| PrnStream () | |
| Construct a stream with a dump level of 0. | |
| virtual | ~PrnStream () |
| Release the stream. | |
| void | Printf (const char *pszFormat,...) |
| Format text into the shared format buffer and write the result through Print(). | |
| PrnStream & | operator<< (const char *pszText) |
| Write text. | |
| PrnStream & | operator<< (char ch) |
| Write a character. | |
| PrnStream & | operator<< (short nValue) |
| Write a short integer in decimal. | |
| PrnStream & | operator<< (int nValue) |
| Write an integer in decimal. | |
| PrnStream & | operator<< (unsigned char nValue) |
| Write a byte as an unsigned integer in decimal. | |
| PrnStream & | operator<< (unsigned short nValue) |
| Write an unsigned short integer in decimal. | |
| PrnStream & | operator<< (unsigned int nValue) |
| Write an unsigned integer in decimal. | |
| PrnStream & | operator<< (unsigned long long nValue) |
| Write an unsigned 64-bit number in decimal. | |
| PrnStream & | operator<< (float fValue) |
| Write a number with two decimals. | |
| PrnStream & | operator<< (bool bValue) |
| Write true or false. | |
| void | Space (int nCount) |
| Write a number of spaces, one Print() call each. | |
| int | GetDumpLevel () const |
| PrnStream () | |
| virtual | ~PrnStream () |
| Destroy the stream. | |
| void | Printf (const char *format,...) |
| Format text with printf() conventions and write it. | |
| PrnStream & | operator<< (char c) |
| Write a character. | |
| PrnStream & | operator<< (int i) |
| Write an integer in decimal. | |
| PrnStream & | operator<< (float f) |
| Write a number with two decimal places. | |
| PrnStream & | operator<< (const char *str) |
| Write text. | |
| void | Space (int count) |
| Write spaces. | |
Static Public Attributes | |
| static constexpr int | npos = -1 |
| The position Find() reports when the text does not occur. | |
Friends | |
| class | BinStream |
Growable text buffer that is also a PrnStream.
Text that grows as it is printed to.
The RTTI includes the class name and records PrnStream as the base. An empty string points mBuffer at g_szStringEmptyBuffer rather than at an allocation of its own.
The RTTI records the class as deriving from PrnStream. The object is 0x14 bytes. The buffer comes from the pool allocator and is replaced, not grown, by every change. An empty String points at gStringEmptyBuffer. The length is named by the assertion text of the source; the other member names, and the names of the members compiled inline (c_str(), size(), the default constructor), are inferred.
|
inline |
Construct an empty string.
The constructor has no out-of-line copy, and it does not set mCapacity.
|
explicit |
Construct a copy of a C string.
| pszText | The text. |
| String::String | ( | const String & | other | ) |
Copy another string.
| other | The string. |
|
override |
Release the text.
|
inline |
| String::String | ( | const char * | str | ) |
Copy text.
A null pointer makes an empty String.
| str | The text, or null. |
| String::String | ( | const String & | other | ) |
|
virtual |
Free the buffer.
|
overridevirtual |
Append text.
| pszText | The text. |
Implements PrnStream.
Replace the text with a copy of another string's text.
The shared empty buffer is shared again rather than copied.
| other | The other string. |
| String & String::operator= | ( | const char * | pszText | ) |
Replace the text with a copy of a C string.
| pszText | The text. A null pointer empties the string. |
| String & String::Clear | ( | ) |
Release the text and leave the string empty.
The name is inferred.
| char String::operator[] | ( | int | nIndex | ) | const |
Report one character.
| nIndex | The character's position. |
Replace a run of characters with another string's text.
| nPos | The first character of the run. |
| nCount | The length of the run. |
| text | The replacement. |
| String & String::Truncate | ( | int | nLength | ) |
Cut the text to a length.
The shared empty buffer is left unchanged.
| nLength | The new length. |
| String & String::Erase | ( | int | nPos, |
| int | nCount ) |
Remove a run of characters.
A run that reaches the end of the text truncates the text at nPos.
| nPos | The first character of the run. |
| nCount | The length of the run. |
Append another string's text.
| other | The other string. |
| String & String::operator+= | ( | const char * | pszText | ) |
Append a C string.
| pszText | The text. |
| String & String::operator+= | ( | char | ch | ) |
Append a character.
| ch | The character. |
| int String::Compare | ( | int | nPos, |
| int | nCount, | ||
| const char * | pszText ) const |
Compare a run of characters with a C string.
| nPos | The first character of the run. |
| nCount | The length of the run. |
| pszText | The text to compare with. |
| int String::Find | ( | const char * | pszText | ) | const |
Find the first occurrence of a C string in the text.
| pszText | The text to find. |
| int String::Find | ( | char | ch | ) | const |
Find the first occurrence of a character.
| ch | The character to find. |
| int String::Find | ( | char | ch, |
| int | nPos ) const |
Find the first occurrence of a character at or after a position.
| ch | The character to find. |
| nPos | The first position searched. |
| int String::RFind | ( | char | ch | ) | const |
Find the last occurrence of a character.
| ch | The character to find. |
| String String::Substring | ( | int | nPos | ) | const |
Copy the characters from a position to the end.
| nPos | The first character copied. |
| String String::Substring | ( | int | nPos, |
| int | nCount ) const |
Copy a run of characters, or the characters from a position to the end when the run reaches the end.
| nPos | The first character copied. |
| nCount | The length of the run. |
| String & String::Insert | ( | int | nPos, |
| int | nCount, | ||
| char | ch ) |
Insert copies of one character.
| nPos | The position the copies go before. |
| nCount | The number of copies. |
| ch | The character. |
Insert a copy of another string's text.
| nPos | The position the text goes before. |
| text | The text. |
| bool String::operator< | ( | const String & | other | ) | const |
Report whether the text sorts before another string's text.
| other | The other string. |
| bool String::operator== | ( | const char * | pszText | ) | const |
Report whether the text equals a C string.
| pszText | The C string, or null. |
| bool String::operator== | ( | const String & | other | ) | const |
Report whether the text equals another string's text.
| other | The other string. |
| bool String::operator!= | ( | const char * | pszText | ) | const |
Report whether the text differs from a C string.
| pszText | The C string, or null. |
| bool String::operator!= | ( | const String & | other | ) | const |
Report whether the text differs from another string's text.
| other | The other string. |
| String String::operator+ | ( | const char * | pszText | ) | const |
Report a copy of the string with text appended.
| pszText | The text to append. |
| String String::operator+ | ( | char | ch | ) | const |
Report a copy of the string with a character appended.
| ch | The character to append. |
Report a copy of the string with another string's text appended.
| other | The other string. |
| void String::Resize | ( | int | nLength | ) |
Replace the text with nLength zero bytes.
| nLength | The new length. |
|
inline |
Report the text.
|
inline |
|
inline |
|
virtual |
| String & String::operator+= | ( | const char * | str | ) |
Append text.
A null pointer appends nothing.
| str | The text, or null. |
| String & String::operator= | ( | const char * | str | ) |
| bool String::operator!= | ( | const char * | str | ) | const |
Compare with text.
A null pointer is unequal to every String.
| str | The text, or null. |
| bool String::operator!= | ( | const String & | other | ) | const |
| bool String::operator== | ( | const char * | str | ) | const |
Compare with text.
A null pointer is unequal to every String.
| str | The text, or null. |
| bool String::operator== | ( | const String & | other | ) | const |
| bool String::operator< | ( | const String & | other | ) | const |
Order by the bytes of the text.
| other | The String. |
| void String::Resize | ( | unsigned int | length | ) |
Replace the text with a length of zero bytes.
| length | The new length. |
| int String::Find | ( | const char * | str | ) | const |
Find the first occurrence of text.
| str | The text. |
| int String::FindLast | ( | char | c | ) | const |
Find the last occurrence of a character.
| c | The character. |
| String String::Substring | ( | unsigned int | pos | ) | const |
Copy the text from a position to the end.
| pos | The first character. |
| String String::Substring | ( | unsigned int | pos, |
| unsigned int | count ) const |
Copy part of the text.
A count that passes the end copies to the end.
| pos | The first character. |
| count | The number of characters. |
|
inline |
|
inline |
|
inline |
|
friend |
|
staticconstexpr |
The position Find() reports when the text does not occur.