#include <tlstring.h>
Collaboration diagram for TLString:
Public Member Functions | |
TLString () | |
Create a NULL string (NULL ref). | |
TLString (const char *str) | |
Create a string. | |
TLString (const TLString &s) | |
Copy a string (i.e. reference it). | |
TLString (const char *strA, const char *strB) | |
Create a string which is the concatenation of both passed strings. | |
TLString (const char *strA, const TLString &strB) | |
Create a string which is the concatenation of both passed strings. | |
TLString (const TLString &strA, const char *strB) | |
Create a string which is the concatenation of both passed strings. | |
TLString (const TLString &strA, const TLString &strB) | |
Create a string which is the concatenation of both passed strings. | |
~TLString () | |
Destructor: dereference. | |
TLString & | operator= (const TLString &s) |
Normal assignment, i.e. reference. | |
TLString & | operator= (const char *str) |
Assign a NUL-terminated string. | |
void | assign (const char *str, size_t len) |
Assign a string with specified length. | |
void | deref () |
This is like assigning a NULL ref,. | |
bool | operator! () const |
This can be used to check for NULL refs. | |
operator bool () const | |
This can be used to check for NULL refs. | |
size_t | length () const |
Get length of string; 0 for NULL refs. | |
const char * | str () const |
Get pointer to internally stored string. | |
char | operator[] (size_t idx) const |
Get one char in the string. Returns NUL if out of range. | |
void | append (const char *str) |
Append a NUL-terminated string. | |
void | append (const char *str, size_t len) |
Append a (non-terminated) string with passed length. | |
TLString & | operator+= (const char *str) |
Append a NUL-terminated string. | |
void | append (const TLString &str) |
Append string. | |
TLString & | operator+= (const TLString &str) |
Append string. | |
void | prepend (const char *str) |
Prepend string. | |
void | prepend (const TLString &str) |
Prepend string. | |
void | sprintf (const char *fmt,...) _fnformat_(__printf__ |
sprintf() functionality. | |
void | vsprintf (const char *fmt, va_list ap) |
Version of sprintf() with va_list argument. | |
void | trunc (size_t len, bool do_not_shrink=0) |
Truncate the string to specified length. | |
void | skip (size_t n) |
Skip the first n chars in the string. | |
int | zero () |
Zero out the string. | |
ssize_t | index (char c) const |
Return index of first occurance of passed character in string. | |
ssize_t | rindex (char c) const |
Return index of last occurance of passed character in string. | |
ssize_t | find (const char *str) const |
ssize_t | find (const TLString &str) const |
ssize_t | rfind (const char *str) const |
Like find() but from backwards. | |
ssize_t | rfind (const TLString &str) const |
size_t | TightenSize () |
Make sure the string does not consume more memory than needed. | |
int | compare (const TLString &strB) |
Compare two strings. | |
Static Public Member Functions | |
TLString | ParseString (const char *instr, ssize_t inlen, SError &error) |
Parse C-like string. | |
Private Member Functions | |
void | _aqref () const |
void | _deref () const |
void | _aqrefN () const |
void | _derefN () const |
void | _detachN () |
Detach the data. | |
void | _detach () |
Detach the data. | |
void | _storeN (const char *str) |
Store passed string, no NULL check. | |
void | _storeN (const char *str, size_t len) |
void | _storeN (const TLString &str) |
void | _referenceN (const TLString &str) |
Reference passed string, no NULL check. | |
Private Attributes | |
SData * | d |
Internally used ref-counting data structure. | |
Friends | |
bool | operator== (const TLString &strA, const TLString &strB) |
bool | operator== (const TLString &strA, const char *strB) |
bool | operator< (const TLString &strA, const TLString &strB) |
bool | operator< (const TLString &strA, const char *strB) |
bool | operator> (const TLString &strA, const char *strB) |
bool | operator<= (const TLString &strA, const TLString &strB) |
bool | operator<= (const TLString &strA, const char *strB) |
bool | operator>= (const TLString &strA, const char *strB) |
Definition at line 53 of file tlstring.h.
|
Create a NULL string (NULL ref).
Definition at line 156 of file tlstring.h. References d. Referenced by ParseString(). |
|
Create a string.
Definition at line 158 of file tlstring.h. References d. |
|
Copy a string (i.e. reference it).
Definition at line 161 of file tlstring.h. |
|
Create a string which is the concatenation of both passed strings.
Definition at line 702 of file tlstring.cc. References _storeN(), d, TLString::SData::len, and TLString::SData::str. |
|
Create a string which is the concatenation of both passed strings.
Definition at line 718 of file tlstring.cc. References _aqrefN(), _derefN(), _referenceN(), _storeN(), d, TLString::SData::len, and TLString::SData::str. |
|
Create a string which is the concatenation of both passed strings.
Definition at line 736 of file tlstring.cc. References _aqrefN(), _derefN(), _referenceN(), _storeN(), d, TLString::SData::len, and TLString::SData::str. |
|
Create a string which is the concatenation of both passed strings.
Definition at line 753 of file tlstring.cc. References _aqrefN(), _derefN(), _referenceN(), d, TLString::SData::len, and TLString::SData::str. |
|
Destructor: dereference.
Definition at line 171 of file tlstring.h. References _deref(). |
|
Definition at line 117 of file tlstring.h. References d, AtomicInt::inc(), and TLString::SData::refcnt. Referenced by _referenceN(), operator=(), and TLString(). |
|
Definition at line 119 of file tlstring.h. References d, AtomicInt::inc(), and TLString::SData::refcnt. Referenced by compare(), find(), operator<(), operator<=(), operator==(), operator>(), operator>=(), rfind(), and TLString(). |
|
Definition at line 118 of file tlstring.h. References d, AtomicInt::DecAndTest(), and TLString::SData::refcnt. Referenced by assign(), deref(), operator=(), vsprintf(), and ~TLString(). |
|
Definition at line 120 of file tlstring.h. References d, AtomicInt::DecAndTest(), and TLString::SData::refcnt. Referenced by _detachN(), compare(), find(), operator<(), operator<=(), operator==(), operator>(), operator>=(), rfind(), skip(), TLString(), trunc(), and zero(). |
|
Detach the data.
This means: Make a private copy if the ref count is larger than 1. Definition at line 140 of file tlstring.h. References _detachN(), and d. |
|
Detach the data.
This means: Make a private copy if the ref count is larger than 1. Definition at line 128 of file tlstring.h. References _derefN(), d, TLString::SData::refcnt, and AtomicInt::val(). |
|
Reference passed string, no NULL check.
Definition at line 151 of file tlstring.h. Referenced by append(), prepend(), and TLString(). |
|
Definition at line 147 of file tlstring.h. References d. |
|
Definition at line 145 of file tlstring.h. References d. |
|
Store passed string, no NULL check.
Definition at line 143 of file tlstring.h. References d. Referenced by append(), prepend(), skip(), and TLString(). |
|
Append string.
Definition at line 147 of file tlstring.cc. References _detachN(), TLString::SData::_EnsureSize(), _referenceN(), d, TLString::SData::len, and TLString::SData::str. |
|
Append a (non-terminated) string with passed length.
Definition at line 131 of file tlstring.cc. References _detachN(), TLString::SData::_EnsureSize(), _storeN(), d, TLString::SData::len, and TLString::SData::str. |
|
Append a NUL-terminated string.
Definition at line 115 of file tlstring.cc. References _detachN(), TLString::SData::_EnsureSize(), _storeN(), d, TLString::SData::len, and TLString::SData::str. Referenced by operator+=(), and StringTreeDump::write(). |
|
Assign a string with specified length.
Definition at line 181 of file tlstring.h. Referenced by VM::InstructionStorage::DumpInstruction(), VM::VarType::TypeString(), and VM::FuncType::TypeString(). |
|
Compare two strings.
This function returns -1, 0, +1 depending on whether strB is <, == or > than *this. This is much like strcmp(3). Definition at line 225 of file tlstring.cc. References _aqrefN(), _derefN(), d, TLString::SData::len, and TLString::SData::str. |
|
This is like assigning a NULL ref,.
Definition at line 185 of file tlstring.h. Referenced by VM::AssemblerFile_Plaintext::_WriteSymbols_Recursive(), VM::NamespaceInfo::DumpTree(), and VM::ClassInfo::DumpTree(). |
|
Definition at line 632 of file tlstring.cc. References _aqrefN(), _derefN(), d, TLString::SData::len, ssize_t, and TLString::SData::str. |
|
Find first occurance of str in this string; return index or -1.
Definition at line 623 of file tlstring.cc. References d, TLString::SData::len, memfind(), ssize_t, and TLString::SData::str. |
|
Return index of first occurance of passed character in string. Returns -1 if not found. Definition at line 585 of file tlstring.cc. References d, TLString::SData::len, ssize_t, and TLString::SData::str. |
|
Get length of string; 0 for NULL refs.
Definition at line 193 of file tlstring.h. References d, and TLString::SData::len. Referenced by StringTreeDump::Entry::RemoveEnd(), and StringTreeDump::write(). |
|
This can be used to check for NULL refs.
Definition at line 190 of file tlstring.h. References d. |
|
This can be used to check for NULL refs.
Definition at line 188 of file tlstring.h. References d. |
|
Append string.
Definition at line 221 of file tlstring.h. References append(). |
|
Append a NUL-terminated string.
Definition at line 215 of file tlstring.h. References append(). |
|
Assign a NUL-terminated string.
Definition at line 178 of file tlstring.h. |
|
Normal assignment, i.e. reference.
Definition at line 174 of file tlstring.h. |
|
Get one char in the string. Returns NUL if out of range.
Definition at line 207 of file tlstring.h. References d, TLString::SData::len, and TLString::SData::str. |
|
Parse C-like string.
If an error occurs, the error is returned in the passed SError class using the [FIXME] default domain and the code 1 (FIXME). All characters in the input with the exception of the escape char "\" (and possibly the first and last double quote as well as whitespace in between, see below) are copied into the destination string. The following escape sequences are recognized:
Normally, the input string will start with a double quote as the first character and end with one as the last character. The first and last double quotes will then not be part of the parsed string. Furthermore, if non-escaped double quotes are found in the text, then the text between them is ignored if it is whitespace or a single '\' followed by a newline (otherwise an error occurs). This can be used to parse continued strings like: In case the _first_ char is _not_ a double quote, the double quote recognition is not performed and any double quote is copied into the destination string just as any other normal character.
Definition at line 22 of file parsestring.cc. References TLString::SData::asize, Assert, SError::clear(), d, TLString::SData::DownSizeIfNeeded(), int8, TLString::SData::len, ssize_t, TLString::SData::str, and TLString(). |
|
Prepend string.
Definition at line 197 of file tlstring.cc. References _detachN(), TLString::SData::_EnsureSize(), _referenceN(), d, TLString::SData::len, and TLString::SData::str. |
|
Prepend string.
Definition at line 180 of file tlstring.cc. References _detachN(), TLString::SData::_EnsureSize(), _storeN(), d, TLString::SData::len, and TLString::SData::str. Referenced by _ParseInt(), _ParseUInt(), and VM::NamespaceInfo::CompleteName(). |
|
Definition at line 675 of file tlstring.cc. References _aqrefN(), _derefN(), d, TLString::SData::len, ssize_t, and TLString::SData::str. |
|
Like find() but from backwards.
Definition at line 659 of file tlstring.cc. References d, TLString::SData::len, ssize_t, and TLString::SData::str. |
|
Return index of last occurance of passed character in string. Returns -1 if not found. Definition at line 593 of file tlstring.cc. References d, TLString::SData::len, ssize_t, and TLString::SData::str. |
|
Skip the first n chars in the string.
Definition at line 459 of file tlstring.cc. References _derefN(), _storeN(), d, TLString::SData::DownSizeIfNeeded(), TLString::SData::len, TLString::SData::refcnt, TLString::SData::str, and AtomicInt::val(). |
|
sprintf() functionality. Like printf() for TLString. The passed format string and args are formatted into the string, replacing the current value of the string. The string is first formatted into a 64 bytes prealloc buffer via vsnprintf() to see how long it will get. If less that 64 bytes, the result is simply copied otherwise it is re-formatted using vsnprintf() again. Definition at line 576 of file tlstring.cc. References vsprintf(). Referenced by _ParseFloat(), _ParseInt(), VM::AssemblerFile_Plaintext::_ParseProgram_Label(), VM::AssemblerFile_Plaintext::_ParseSymbols_Symbols(), _ParseUInt(), VM::AssemblerFile_Plaintext::_WriteSymbols_Global(), VM::AssemblerFile_Plaintext::_WriteSymbols_Recursive(), VM::NamespaceInfo::DumpTree(), VM::ClassInfo::DumpTree(), _InternalSourceFileNode::IncludeHierarchyStr(), _InternalSourcePosition::PosRangeString(), _InternalSourcePosition::PosString(), and _InternalSourcePosition::PosStringRelative(). |
|
|
Make sure the string does not consume more memory than needed. Returns amount of memory allocated (including overhead). NOTE: Does actually nothing if this is not the only reference to the string. (The only thing we could do was to detach thereby allocation additional memory which is not what we are about when calling this.) Definition at line 500 of file tlstring.cc. References TLString::SData::asize, d, TLString::SData::refcnt, TLString::SData::TightenSize(), and AtomicInt::val(). Referenced by StringTreeDump::append(), and StringTreeDump::Entry::TightenSize(). |
|
Truncate the string to specified length. If the length is longer than the string, nothing is done. If do_not_shrink is set, the memory chunk will NOT be shrinked. This is useful when new data is to be appended immediately. Only effective if this is the only reference to the string. Definition at line 434 of file tlstring.cc. References _derefN(), d, TLString::SData::DownSizeIfNeeded(), TLString::SData::len, TLString::SData::refcnt, TLString::SData::str, and AtomicInt::val(). Referenced by StringTreeDump::write(). |
|
Version of sprintf() with va_list argument.
Definition at line 509 of file tlstring.cc. References _deref(), TLString::SData::asize, CritAssert, d, TLString::SData::EnsureSize(), TLString::SData::len, TLString::SData::refcnt, ssize_t, TLString::SData::str, and AtomicInt::val(). Referenced by _vaMessage(), and sprintf(). |
|
Zero out the string. Only effective, if this is the only reference to the string. Does a deref() after zeroing.
Definition at line 423 of file tlstring.cc. References _derefN(), d, TLString::SData::len, TLString::SData::refcnt, TLString::SData::str, and AtomicInt::val(). |
|
Definition at line 315 of file tlstring.cc. |
|
The < and > operators return 0 if at least one string is NULL. Definition at line 293 of file tlstring.cc. |
|
Definition at line 380 of file tlstring.cc. |
|
Definition at line 358 of file tlstring.cc. |
|
Definition at line 270 of file tlstring.cc. |
|
NOTE that two NULL refs are always equal; NULL strings behave like NULL refs. Definition at line 253 of file tlstring.cc. |
|
Definition at line 336 of file tlstring.cc. |
|
Definition at line 401 of file tlstring.cc. |
|
Internally used ref-counting data structure.
Definition at line 115 of file tlstring.h. Referenced by _aqref(), _aqrefN(), _deref(), _derefN(), _detach(), _detachN(), _referenceN(), _storeN(), append(), assign(), compare(), deref(), find(), index(), length(), operator bool(), operator!(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), operator[](), ParseString(), prepend(), rfind(), rindex(), skip(), str(), TightenSize(), TLString(), trunc(), vsprintf(), and zero(). |