#include <string.h>
Class to store 8 bit strings. The CString stores 8 bit characters. Any characters are legal, including 0C (for example CString("\0\0\0\0", 4) will result in a CString with length 4). CStrings are reference-counted objects. This means that as long as you copy and do not modify strings they are just referenced. The first modification breaks the link and it becomes a unique new object. For error handling see String.
Public Types | |
using | CharType = CStringInterface::CharType |
using | ConstIterator = BaseIterator< const CString, false > |
using | Iterator = ConstIterator |
using | ValueType = Char |
Public Member Functions | |
MAXON_DEFAULT_REFERENCE_CONSTRUCTORS (CString, Reference) | |
CString (const Char *str, Int count=-1) | |
CString (Int count, Char fillChar) | |
CString (const Block< const Char > &str) | |
CString (const String &str, const StringEncodingRef &stringEncoding=GetUtf8DefaultEncoder()) | |
Char | operator[] (Int pos) const |
MAXON_ATTRIBUTE_FORCE_INLINE CStringInterface::CharPtr | operator[] (Int position) |
ConstIterator | Begin () const |
ConstIterator | End () const |
Bool | IsEmpty () const |
Bool | IsPopulated () const |
CString & | operator+= (const CString &str) |
operator const Char * () const | |
operator Block< const Char > () const | |
Block< const Char > | ToBlock () const |
Static Public Member Functions | |
static const CString & | GetLineEnd () |
Private Member Functions | |
void | operator-> () const |
using CharType = CStringInterface::CharType |
using ConstIterator = BaseIterator<const CString, false> |
using Iterator = ConstIterator |
Constructor for Char array. If you have static Char strings use "..."_cs instead.
[in] | str | C string block. |
[in] | count | Number of characters, -1 to auto detect the length of the string (search for the first 0). |
Constructor to create a string with a specific length and a default character.
[in] | count | Number of characters of the new string. |
[in] | fillChar | Character to fill the string with. |
Constructor from a Char Block. If you have static strings use "..."_cs instead.
[in] | str | Char block, for example a BaseArray<Char>. |
|
explicit |
Constructor to create a CString from a String. The lower byte of each character will be copied, whereas the upper byte will be discarded.
[in] | str | Unicode string. |
[in] | stringEncoding | Encoding for the string. By default utf8 is selected. If a nullptr is passed the data is truncated to Char and no conversion takes place. |
MAXON_DEFAULT_REFERENCE_CONSTRUCTORS | ( | CString | , |
Reference | |||
) |
Index operator to access single characters of the string.
[in] | pos | Position within the string the first character starts with an index of 0. If the position is out of boundaries 0 will be returned. |
MAXON_ATTRIBUTE_FORCE_INLINE CStringInterface::CharPtr operator[] | ( | Int | position | ) |
Index operator to access single characters of the string.
[in] | position | Position within the string the first character starts with an index of 0. if the position is out of boundaries no changes will be made. |
ConstIterator Begin | ( | ) | const |
ConstIterator End | ( | ) | const |
Bool IsEmpty | ( | ) | const |
Returns if the string length is zero.
Bool IsPopulated | ( | void | ) | const |
Returns if the string contains any characters.
operator const Char * | ( | ) | const |
Conversion to const Char*, returns the pointer to a null-terminated C string.
|
static |
Returns a string with the platform specific line ending.
|
private |