![]() |
nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
|
A basic string class made of chars stored on the stack. More...
#include <StaticString.h>
Public Types | |
using | Iterator = StringIterator< false > |
Iterator type. | |
using | ConstIterator = StringIterator< true > |
Constant iterator type. | |
using | ReverseIterator = nctl::ReverseIterator< Iterator > |
Reverse iterator type. | |
using | ConstReverseIterator = nctl::ReverseIterator< ConstIterator > |
Reverse constant iterator type. | |
Public Member Functions | |
StaticString () | |
Default constructor. | |
StaticString (const char *cString) | |
Constructs a string object from a C string. | |
StaticString (const StaticString &other) | |
Copy constructor. | |
template<unsigned int U> | |
StaticString (const StaticString< U > &other) | |
Conversion constructor from a string of different capacity. | |
StaticString & | operator= (const StaticString &other) |
Assignment operator (it might extend or truncate the original text) | |
template<unsigned int U> | |
StaticString & | operator= (const StaticString< U > &other) |
Assignment operator (it might extend or truncate the original text) | |
StaticString & | operator= (const char *cString) |
Assigns a constant C string to the string object. | |
Iterator | begin () |
Returns an iterator to the first character. | |
ReverseIterator | rBegin () |
Returns a reverse iterator to the last character. | |
Iterator | end () |
Returns an iterator to the termination character. | |
ReverseIterator | rEnd () |
Returns a reverse iterator to the byte preceding the first character. | |
ConstIterator | begin () const |
Returns a constant iterator to the first character. | |
ConstReverseIterator | rBegin () const |
Returns a constant reverse iterator to the last character. | |
ConstIterator | end () const |
Returns a constant iterator to the termination character. | |
ConstReverseIterator | rEnd () const |
Returns a constant reverse iterator to the byte preceding the first character. | |
ConstIterator | cBegin () const |
Returns a constant iterator to the first character. | |
ConstReverseIterator | crBegin () const |
Returns a constant reverse iterator to the last character. | |
ConstIterator | cEnd () const |
Returns a constant iterator to the termination character. | |
ConstReverseIterator | crEnd () const |
Returns a constant reverse iterator to the byte preceding the first character. | |
bool | isEmpty () const |
Returns true if the string is empty. | |
unsigned int | length () const |
Returns the string length. | |
unsigned int | capacity () const |
Returns the string capacity. | |
unsigned int | setLength (unsigned int newLength) |
Sets the string length. | |
void | clear () |
Clears the string. | |
char * | data () |
Returns a pointer to the internal array. | |
const char * | data () const |
Returns a constant pointer to the internal array. | |
unsigned int | replace (const StaticString &source, unsigned int srcChar, unsigned int numChar, unsigned int destChar) |
Replaces characters from somewhere in the other string to somewhere in this one (no truncation) | |
template<unsigned int U> | |
unsigned int | replace (const StaticString< U > &source, unsigned int srcChar, unsigned int numChar, unsigned int destChar) |
Replaces characters from somewhere in the other string to somewhere in this one (no truncation) | |
unsigned int | replace (const char *source, unsigned int numChar, unsigned int destChar) |
Replaces characters from a C string to somewhere in this one (no truncation) | |
unsigned int | assign (const StaticString &source, unsigned int srcChar, unsigned int numChar) |
Copies characters from somewhere in the other string to the beginning of this one. | |
template<unsigned int U> | |
unsigned int | assign (const StaticString< U > &source, unsigned int srcChar, unsigned int numChar) |
Copies characters from somewhere in the other string to the beginning of this one. | |
unsigned int | assign (const StaticString &source) |
Copies all characters from the other string to the beginning of this one. | |
template<unsigned int U> | |
unsigned int | assign (const StaticString< U > &source) |
Copies all characters from the other string to the beginning of this one. | |
unsigned int | assign (const char *source, unsigned int numChar) |
Copies characters from a C string to the beginning of this one. | |
unsigned int | copy (char *dest, unsigned int srcChar, unsigned int numChar) const |
Copies characters from somewhere in this string to a C string. | |
unsigned int | copy (char *dest) const |
Copies all characters from this string to a C string. | |
unsigned int | append (const StaticString &other) |
Appends all the characters from the other string to the end of this one. | |
template<unsigned int U> | |
unsigned int | append (const StaticString< U > &other) |
Appends all the characters from the other string to the end of this one. | |
unsigned int | append (const char *cString) |
Appends all the characters from the C string to the end of this one. | |
int | compare (const StaticString &other) const |
Compares the string with another one in lexicographical order. | |
template<unsigned int U> | |
int | compare (const StaticString< U > &other) const |
Compares the string with another one in lexicographical order. | |
int | compare (const char *cString) const |
Compares the string with a constant C string in lexicographical order. | |
int | findFirstChar (char c) const |
Finds the first occurrence of a character. | |
int | findLastChar (char c) const |
Finds the last occurrence of a character. | |
int | findFirstCharAfterIndex (char c, unsigned int index) const |
Finds the first occurrence of a character after the character at the index. | |
int | find (const StaticString &other) const |
Finds the first occurrence of the given string. | |
template<unsigned int U> | |
int | find (const StaticString< U > &other) const |
Finds the first occurrence of the given string. | |
int | find (const char *cString) const |
Finds the first occurrence of the given constant C string. | |
StaticString & | format (const char *fmt,...) |
Replaces the string with the formatted result. | |
StaticString & | formatAppend (const char *fmt,...) |
Append the formatted result to the string. | |
StaticString & | operator+= (const StaticString &other) |
Appends another string to this one. | |
template<unsigned int U> | |
StaticString & | operator+= (const StaticString< U > &other) |
Appends another string to this one. | |
StaticString & | operator+= (const char *cString) |
Appends a constant C string to the string object. | |
StaticString | operator+ (const StaticString &other) const |
Concatenate two strings together to create a third one. | |
template<unsigned int U> | |
StaticString | operator+ (const StaticString< U > &other) const |
Concatenate two strings together to create a third one. | |
StaticString | operator+ (const char *cString) const |
Concatenates a string with a constant C string to create a third one. | |
bool | operator== (const StaticString &other) const |
bool | operator!= (const StaticString &other) const |
bool | operator> (const StaticString &other) const |
bool | operator< (const StaticString &other) const |
bool | operator>= (const StaticString &other) const |
bool | operator<= (const StaticString &other) const |
template<unsigned int U> | |
bool | operator== (const StaticString< U > &other) const |
template<unsigned int U> | |
bool | operator!= (const StaticString< U > &other) const |
template<unsigned int U> | |
bool | operator> (const StaticString< U > &other) const |
template<unsigned int U> | |
bool | operator< (const StaticString< U > &other) const |
template<unsigned int U> | |
bool | operator>= (const StaticString< U > &other) const |
template<unsigned int U> | |
bool | operator<= (const StaticString< U > &other) const |
bool | operator== (const char *cString) const |
bool | operator!= (const char *cString) const |
bool | operator> (const char *cString) const |
bool | operator< (const char *cString) const |
bool | operator>= (const char *cString) const |
bool | operator<= (const char *cString) const |
const char & | at (unsigned int index) const |
Read-only access to the specified element (with bounds checking) | |
char & | at (unsigned int index) |
Access to the specified element (with bounds checking) | |
const char & | operator[] (unsigned int index) const |
Read-only subscript operator. | |
char & | operator[] (unsigned int index) |
Subscript operator. | |
int | utf8ToCodePoint (unsigned int position, unsigned int &codePoint, unsigned int *codeUnits) const |
Retrieves the Unicode code point and the UTF-8 code units from the UTF-8 substring starting at the specified position. | |
int | utf8ToCodePoint (unsigned int position, unsigned int &codePoint) const |
Retrieves the Unicode code point from the UTF-8 substring starting at the specified position. | |
template<unsigned int U> | |
StaticString< C > & | operator= (const StaticString< U > &other) |
template<unsigned int U> | |
StaticString< C > & | operator+= (const StaticString< U > &other) |
template<unsigned int U> | |
StaticString< C > | operator+ (const StaticString< U > &other) const |
Static Public Attributes | |
static const unsigned int | MaxCStringLength = 512 - 1 |
Maximum length when creating an object from C-style strings. | |
Friends | |
template<unsigned int U> | |
StaticString< U > | operator+ (const char *cString, const StaticString< U > &string) |
Friend operator to concatenate a constant C string with a string to create a third one. | |
bool | operator== (const char *cString, StaticString string) |
bool | operator!= (const char *cString, StaticString string) |
bool | operator> (const char *cString, StaticString string) |
bool | operator< (const char *cString, StaticString string) |
bool | operator>= (const char *cString, StaticString string) |
bool | operator<= (const char *cString, StaticString string) |
A basic string class made of chars stored on the stack.
void nctl::StaticString< C >::clear | ( | ) |
Clears the string.
Length will be reset to zero but capacity remains unmodified.
StaticString< C > & nctl::StaticString< C >::operator= | ( | const StaticString< C > & | other | ) |
Assignment operator (it might extend or truncate the original text)
StaticString< C > & nctl::StaticString< C >::operator= | ( | const StaticString< U > & | other | ) |
unsigned int nctl::StaticString< C >::replace | ( | const StaticString< C > & | source, |
unsigned int | srcChar, | ||
unsigned int | numChar, | ||
unsigned int | destChar | ||
) |
Replaces characters from somewhere in the other string to somewhere in this one (no truncation)
The method returns the number of characters copied, to allow truncation.
unsigned int nctl::StaticString< C >::replace | ( | const StaticString< U > & | source, |
unsigned int | srcChar, | ||
unsigned int | numChar, | ||
unsigned int | destChar | ||
) |
Replaces characters from somewhere in the other string to somewhere in this one (no truncation)
The method returns the number of characters copied, to allow truncation.
Sets the string length.
The method is useful to update the string length after writing into it through the data()
pointer.
int nctl::StaticString< C >::utf8ToCodePoint | ( | unsigned int | position, |
unsigned int & | codePoint | ||
) | const |
Retrieves the Unicode code point from the UTF-8 substring starting at the specified position.
int nctl::StaticString< C >::utf8ToCodePoint | ( | unsigned int | position, |
unsigned int & | codePoint, | ||
unsigned int * | codeUnits | ||
) | const |
Retrieves the Unicode code point and the UTF-8 code units from the UTF-8 substring starting at the specified position.