Polycode
|
Unicode-friendly string. More...
Public Member Functions | |
String () | |
Default constructor. | |
String (const wchar_t *str) | |
Initializes the string from a pointer to wide character buffer. | |
String (const char *str, size_t n) | |
Initializes the string from a pointer to regular character buffer of a certain size. | |
String (const char *str) | |
Initializes the string from a regular character buffer. | |
String (const std::string &str) | |
Initializes the string from an STL string. | |
String (const std::wstring &str) | |
Initializes the string from an STL wstring. | |
size_t | size () const |
Return the length of the string. | |
size_t | length () const |
Return the length of the string. | |
const std::string & | getSTLString () const |
Return the string and an STL string. | |
String | substr (size_t pos=0, size_t n=std::wstring::npos) const |
Returns the substring of the string. | |
size_t | rfind (const String &str, size_t pos=std::wstring::npos) const |
Find last occurrence of content in string. | |
size_t | find (const String &str, size_t pos=0) const |
Find content in string. | |
size_t | find_last_of (const String &str, size_t pos=std::wstring::npos) |
Find character in string from the end. | |
String | toLowerCase () const |
Returns the lowercase version of the string. | |
String | toUpperCase () const |
Returns the uppercase version of the string. | |
std::vector< String > | split (const String &delim) const |
Splits the string by the specified delimeter. | |
String | replace (const String &what, const String &withWhat) const |
Replaces parts of the string with another string. | |
const char * | c_str () const |
Pointer to char data. | |
const char * | getDataWithEncoding (int encoding) const |
Returns data with the specified encoding. | |
size_t | getDataSizeWithEncoding (int encoding) const |
Returns the size of the data with the specified encoding. | |
void | setDataWithEncoding (char *data, int encoding) |
Sets the data for the string using specified encoding. | |
Static Public Member Functions | |
static String | NumberToString (Number value) |
Convert a Number to a String. | |
static String | IntToString (int value) |
Convert an integer to a String. | |
Public Attributes | |
std::string | contents |
STL string version of the string. | |
Static Public Attributes | |
static const int | ENCODING_UTF8 = 0 |
UTF-8 encoding. |
Unicode-friendly string.
The Polycode String class wraps around STL wstring to support Unicode text in the engine. You can request data from it in different encodings (currently only UTF-8) or plain char data. It is mostly just a wrapper around STL created for easier Unicode support, LUA bindings and convenience methods.
const char * String::c_str | ( | ) | const |
Pointer to char data.
size_t Polycode::String::find | ( | const String & | str, |
size_t | pos = 0 |
||
) | const [inline] |
Find content in string.
str | String to be searched for in the object. |
pos | Position of the first character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched. |
size_t Polycode::String::find_last_of | ( | const String & | str, |
size_t | pos = std::wstring::npos |
||
) | [inline] |
Find character in string from the end.
Searches the string from the end for any of the characters that are part of the passed string.
str | String containing the characters to search for. |
pos | Position of the last character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched. |
size_t String::getDataSizeWithEncoding | ( | int | encoding | ) | const |
Returns the size of the data with the specified encoding.
Currently the only supported encoding is String::ENCODING_UTF8
encoding | The encoding to use. |
const char * String::getDataWithEncoding | ( | int | encoding | ) | const |
Returns data with the specified encoding.
Currently the only supported encoding is String::ENCODING_UTF8
encoding | The encoding to use. |
String String::IntToString | ( | int | value | ) | [static] |
Convert an integer to a String.
value | Integer to convert. |
String String::NumberToString | ( | Number | value | ) | [static] |
Convert a Number to a String.
value | Number to convert. |
Replaces parts of the string with another string.
what | Ocurrences of which string to replace in this string. |
withWhat | What to replace them with. |
size_t Polycode::String::rfind | ( | const String & | str, |
size_t | pos = std::wstring::npos |
||
) | const [inline] |
Find last occurrence of content in string.
str | String to be searched for in the object. |
pos | Position of the last character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched. |
void String::setDataWithEncoding | ( | char * | data, |
int | encoding | ||
) |
Sets the data for the string using specified encoding.
data | Data to set the string with. |
encoding | The encoding to use. |
Splits the string by the specified delimeter.
delim | The delimeter to split by. |
String Polycode::String::substr | ( | size_t | pos = 0 , |
size_t | n = std::wstring::npos |
||
) | const [inline] |
Returns the substring of the string.
pos | Position of a character in the current string object to be used as starting character for the substring. |
n | Length of the substring. |
String String::toLowerCase | ( | ) | const |
Returns the lowercase version of the string.
String String::toUpperCase | ( | ) | const |
Returns the uppercase version of the string.