Visualization Library 2.1.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine. More...
#include <String.hpp>
Public Member Functions | |
String () | |
Constructor. More... | |
String (const String &other) | |
Constructor. More... | |
String (const wchar_t *wstr) | |
Constructor. More... | |
String (const char *str) | |
Constructor. More... | |
String (const std::string &str) | |
Constructor. More... | |
String (const std::wstring &str) | |
Constructor. More... | |
String (wchar_t ch, int count=1) | |
Constructor. More... | |
const wchar_t * | ptr () const |
Returns the 0-terminated utf16 string. More... | |
wchar_t * | ptr () |
Returns the 0-terminated utf16 string. More... | |
int | length () const |
Returns the length of the string. More... | |
bool | empty () const |
Returns true if length() == 0. More... | |
bool | null () const |
Returns true if the String has never been assigned or resized. More... | |
String & | clear () |
Clears the string. More... | |
const wchar_t & | operator[] (int i) const |
Returns the character at position i . More... | |
wchar_t & | operator[] (int i) |
Returns the character at position i . More... | |
String & | replace (wchar_t old_ch, wchar_t new_ch) |
Replaces the character 'old_ch' with 'new_ch'. More... | |
String & | replace (int start, int count, wchar_t ch) |
Replaces count characters starting at position start with ch . More... | |
String & | replace (int start, int count, const String &str) |
Equivalent to remove(start, count); insert(start, str);. More... | |
String & | replace (const String &oldstr, const String &newstr, bool case_sensitive=true) |
Replaces all the occurrences of oldstr with newstr. More... | |
String & | remove (wchar_t ch, int start=0, int count=-1) |
Removes 'count' occurrences of the character 'ch' after position 'start'. More... | |
String & | remove (const String &str, int start=0, int count=-1) |
Removes 'count' occurrences of the string 'str' after position 'start'. More... | |
String & | remove (int start, int count) |
Removes 'count' characters starting at position 'start'. More... | |
String & | reverse () |
Reverses the order of the characters in the string. More... | |
String & | normalizeSlashes () |
Transform \ slashes in / slashes and removes duplicates. More... | |
int | count (wchar_t ch, int start=0) const |
Returns the number of occurrences of the given character after position 'start'. More... | |
int | count (const String &str, int start=0) const |
Returns the number of occurrences of the given string after position 'start'. More... | |
int | compare (const String &other) const |
Performs a lexicographic comparison. More... | |
bool | endsWith (const String &str) const |
Returns true if a String ends with the specified String str . More... | |
bool | startsWith (const String &str) const |
Returns true if a String starts with the specified String str . More... | |
bool | endsWith (wchar_t ch) const |
Returns true if a String ends with the specified character. More... | |
bool | startsWith (wchar_t ch) const |
Returns true if a String starts with the specified character. More... | |
String & | insert (int pos, const String &str) |
Inserts str at position pos . More... | |
String & | insert (int pos, wchar_t ch, int count=1) |
Inserts count characters ch starting at position pos . More... | |
String | left (int count) const |
Returns the count leftmost caracters of a String. If count is negative the function returns all but the abs(count) rightmost caracters. More... | |
String | right (int count) const |
Returns the count rightmost caracters of a String. If count is negative the function returns all but the abs(count) leftmost caracters. More... | |
String | extractPath () const |
If the String contains a file path the function returns the path with trailing slash, without the file name. More... | |
String | extractFileName () const |
If the String contains a file path the function returns the file name without the path. More... | |
String | extractFileExtension (bool require_dot=true) const |
If the String contains a file name or file path the function returns the extension of the file. More... | |
String & | resize (int character_count) |
Resizes the string to the specified character count. More... | |
String | substring (int start, int count=-1) const |
Returns the count characters long substring starting a character index start . If count == -1 the returned substring will contain all the characters from start to the end of the String. More... | |
String & | fill (wchar_t ch) |
Fills the string with the specified character ch . More... | |
String & | trim (wchar_t ch) |
Removes the specified character ch from the beginning and the end of the String. More... | |
String & | trim (const String &chars) |
Removes the characters contained in chars from the beginning and the end of the String. More... | |
String & | trim () |
Equivalent to trim ("\n\r\t\v "), that is, removes all the tabs, spaces and new-lines from the beginning and end of a String. More... | |
void | split (wchar_t separator, std::vector< String > &fields, bool remove_empty_fields=false) const |
Splits a String into a set of fields. The fields are separated by the specified separator and are returned in fields . More... | |
void | split (const String &separator_list, std::vector< String > &fields, bool remove_empty_fields=false) const |
Splits a String into a set of fields. The fields are separated by the specified separator_list and are returned in fields . More... | |
void | splitLines (std::vector< String > &lines) const |
Splits a String into a set of Strings each of which contains a line. More... | |
String | field (wchar_t separator, int field_index) const |
Splits a String into a set of fields based on the specified separator and returns the filed at position field_index . More... | |
String & | append (const String &other) |
Appends the specified String to another String. More... | |
String & | append (wchar_t ch, int count=1) |
Appends count characters ch to another String. More... | |
String & | prepend (const String &str) |
Prepends the specified String to another String. More... | |
String & | prepend (wchar_t ch, int count) |
Prepends count characters ch to another String. More... | |
int | find (wchar_t ch, int start=0) const |
Searches for the specified character ch starting at position start and returns the index of the first occurrence or -1 if no occurrence was found. More... | |
int | find (const String &substr, int start=0) const |
Searches for the specified string substr starting at position start and returns the index of the first occurrence or -1 if no occurrence was found. More... | |
int | findInLargeText (const String &substr, int start=0) const |
Searches for the specified string substr starting at position start and returns the index of the first occurrence or -1 if no occurrence was found. More... | |
int | findBackwards (wchar_t ch) const |
Searches for the specified character chstarting from the end of the string and returns the index of the first occurrence or -1 if no occurrence was found. More... | |
int | findBackwards (const String &str) const |
Searches for the specified String chstr from the end of the string and returns the index of the first occurrence or -1 if no occurrence was found. More... | |
bool | contains (wchar_t ch) const |
Returns true if a String contains the specified character. More... | |
bool | contains (const String &str) const |
Returns true if a String contains the specified String. More... | |
void | squeeze () |
Minimizes the memory buffer used to store the String. More... | |
int | toInt (bool hex=false) const |
Returns the int number represented by the string. The conversion is done using the standard atoi() function. More... | |
double | toDouble () const |
Returns the double number represented by the string. The conversion is done using the standard atof() function. More... | |
float | toFloat () const |
Returns the float number represented by the string. The conversion is done using the standard atof() function. More... | |
std::string | toStdString () const |
Returns a UTF8 encoded std::string. More... | |
std::wstring | toStdWString () const |
Returns the std::wstring representation of a String. More... | |
void | toAscii (std::string &ascii, bool translate_non_ascii_chars=true) const |
Provides some basic character translation of code points outside of the ASCII range. More... | |
void | toUTF8 (std::vector< unsigned char > &utf8, bool include_utf8_signature=true) const |
Encodes the String into a UTF8 encoded string. More... | |
void | toUTF8 (std::string &utf8, bool include_utf8_signature=true) const |
Encodes the String into a UTF8 encoded std::string. More... | |
void | toUTF16BE (std::vector< unsigned char > &utf16, bool include_utf16be_signature=true) const |
Encodes the String into a UTF16 big endian encoded string. More... | |
void | toUTF16LE (std::vector< unsigned char > &utf16, bool include_utf16le_signature=true) const |
Encodes the String into a UTF16 little endian encoded string. More... | |
void | toLatin1 (std::vector< unsigned char > &latin1) const |
Encodes the String into a Latin1 encoded string. More... | |
String | toLowerCase () const |
Returns the lower-case version of a String. More... | |
String | toUpperCase () const |
Returns the upper-case version of a String. More... | |
bool | operator< (const String &other) const |
Lexicographic sorting, equivalent to "compare(other) < 0" . More... | |
String & | operator= (const char *str) |
Equivalent to '*this = fromUTF8(str);'. More... | |
String & | operator= (const std::string &str) |
Equivalent to '*this = fromUTF8(str.c_str());'. More... | |
String & | operator= (const wchar_t *wstr) |
String & | operator= (const std::wstring &str) |
String & | operator= (const String &other) |
bool | operator== (const String &other) const |
bool | operator== (const std::string &other) const |
bool | operator== (const std::wstring &other) const |
bool | operator== (const char *other) const |
bool | operator== (const wchar_t *other) const |
bool | operator!= (const String &other) const |
bool | operator!= (const std::string &other) const |
bool | operator!= (const std::wstring &other) const |
bool | operator!= (const char *other) const |
bool | operator!= (const wchar_t *other) const |
String & | operator+= (wchar_t ch) |
String | operator+ (wchar_t ch) const |
String & | operator+= (const String &other) |
String | operator+ (const String &other) const |
void | acquireData () const |
Acquires a private copy of the data if the string has been copied from another one. More... | |
Static Public Member Functions | |
static EStringEncoding | detectEncoding (const void *str, int byte_count, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING) |
Detects the encoding. More... | |
static String | loadText (const String &path, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING) |
Loads a String from the specified path. More... | |
static String | loadText (const char *path, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING) |
Loads a String from the specified path. More... | |
static String | loadText (VirtualFile *file, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING) |
Loads a String from the specified VirtualFile. More... | |
static String | loadText (void *data, int bytes, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING) |
Loads a String from the specified memory buffer. More... | |
static unsigned short | getUpperCase (unsigned short ch) |
Returns the upper-case version of the specified character. More... | |
static unsigned short | getLowerCase (unsigned short ch) |
Returns the lower-case version of the specified character. More... | |
static unsigned short | getTitleCase (unsigned short ch) |
Returns the title-case version of the specified character. More... | |
static void | filterStrings (std::vector< String > &strings, const String &filter) |
Filters the specified Strings using the given filter. The filter must be of the type "*abc" , "abc*" and "*abc*" . More... | |
static wchar_t | platformSlash () |
Returns '\' under windows and '/' under Linux and Mac. More... | |
static std::string | trimStdString (const std::string &text) |
Remove the spaces before and after an std::string. More... | |
static String | fromPointer (const void *value) |
Creates a string representing the given pointer. More... | |
static String | fromInt (int value) |
Creates a string representing the given integer value. More... | |
static String | fromUInt (unsigned int value) |
Creates a string representing the given unsigned integer value. More... | |
static String | fromLongLong (long long value) |
Creates a string representing the given long long value. More... | |
static String | fromULongLong (unsigned long long value) |
Creates a string representing the given unsigned long long value. More... | |
static String | fromDouble (double value, int decimals=6) |
Creates a string representing the given double value The value of 'decimals' can be between 0 and 20. More... | |
static String | fromStdString (const std::string &str, bool utf8=true) |
Initializes the string from a std::string using fromUTF() if utf8 == true (default) otherwise uses fromAscii(). More... | |
static String | fromStdWString (const std::wstring &str) |
Initializes the string from a std::string using the fromAscii() function. More... | |
static String | fromAscii (const char *str, int size=-1) |
Initializes the string from a 7 bit ascii string. More... | |
static String | fromUTF16BE (const unsigned short *str, int byte_count=-1) |
Accepts strings with and without UTF16 BE signature Supports natively the characters from the BMP, the other characters are substituted with '?' The size of the buffer pointed by 'str' must be at least 'byte_count' bytes large or null terminated. More... | |
static String | fromUTF16LE (const unsigned short *str, int byte_count=-1) |
Accepts strings with and without UTF16 LE signature Supports natively the characters from the BMP, the other characters are substituted with '?' The size of the buffer pointed by 'str' must be at least 'byte_count' bytes large or null terminated. More... | |
static String | fromUTF16 (const unsigned short *str, int byte_count=-1) |
str must have UTF16 LE or UTF16 BE signature The size of the buffer pointed by 'str' must be at least 'byte_count' bytes large or null terminated. More... | |
static String | fromUTF8 (const char *str, int byte_count=-1) |
Accepts strings with and without UTF8 signature. More... | |
static String | fromLatin1 (const char *str, int character_count=-1) |
The size of the buffer pointed by 'str' must be at least 'character_count' bytes large or null terminated. More... | |
static String | printf (const char *fmt,...) |
Returns a formatted string using the legacy printf syntax. The resulting string can be maximum 1024 + strlen(fmt) characters long. More... | |
Protected Member Functions | |
void | createData () const |
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
The String class features:
Definition at line 62 of file String.hpp.
String::String | ( | ) |
Constructor.
Definition at line 47 of file String.cpp.
References acquireData().
Referenced by extractFileExtension(), extractFileName(), extractPath(), loadText(), split(), splitLines(), substring(), toLowerCase(), and toUpperCase().
String::String | ( | const String & | other | ) |
String::String | ( | const wchar_t * | wstr | ) |
String::String | ( | const char * | str | ) |
|
inline |
Constructor.
Definition at line 118 of file String.hpp.
|
inline |
Constructor.
Definition at line 121 of file String.hpp.
|
explicit |
|
inline |
Acquires a private copy of the data if the string has been copied from another one.
Definition at line 558 of file String.hpp.
Referenced by append(), fill(), fromAscii(), fromLatin1(), fromStdWString(), fromUTF16(), fromUTF16BE(), fromUTF16LE(), fromUTF8(), insert(), operator=(), remove(), replace(), resize(), reverse(), String(), substring(), toLowerCase(), toUpperCase(), and trim().
Appends the specified String to another String.
Definition at line 597 of file String.cpp.
References acquireData(), and length().
Referenced by insert(), operator+(), and vl::Say::pipeline().
String & String::append | ( | wchar_t | ch, |
int | count = 1 |
||
) |
Appends count
characters ch
to another String.
Definition at line 588 of file String.cpp.
References acquireData(), and count().
|
inline |
Clears the string.
Definition at line 142 of file String.hpp.
Referenced by fromUTF16(), normalizeSlashes(), vl::TextStream::readLine(), vl::TextStream::readLineCR(), vl::TextStream::readLineLF(), vl::TextStream::readQuotedString(), vl::TextStream::readString(), vl::Molecule::reset(), and vl::GLSLShader::setSource().
int String::compare | ( | const String & | other | ) | const |
Performs a lexicographic comparison.
Returns < 0 if this string comes before 'other'. Returns > 0 if 'other' comes before this string. Returns 0 if the two strings are equal.
Definition at line 691 of file String.cpp.
References createData(), length(), and vl::min().
bool String::contains | ( | wchar_t | ch | ) | const |
Returns true if a String contains the specified character.
Definition at line 212 of file String.cpp.
References find().
Referenced by vl::Say::euronotation(), vl::Say::pipeline(), and split().
bool String::contains | ( | const String & | str | ) | const |
Returns true if a String contains the specified String.
Definition at line 229 of file String.cpp.
References find().
int String::count | ( | wchar_t | ch, |
int | start = 0 |
||
) | const |
int String::count | ( | const String & | str, |
int | start = 0 |
||
) | const |
Returns the number of occurrences of the given string after position 'start'.
Definition at line 679 of file String.cpp.
|
inlineprotected |
Definition at line 567 of file String.hpp.
References vl::length(), and resize().
Referenced by compare().
|
static |
Detects the encoding.
Definition at line 1415 of file String.cpp.
References vl::SE_UTF16_BE, vl::SE_UTF16_LE, vl::SE_UTF32_BE, vl::SE_UTF32_LE, and vl::SE_UTF8.
Referenced by loadText().
|
inline |
Returns true
if length() == 0.
Definition at line 136 of file String.hpp.
References vl::length().
Referenced by vl::GLSLShader::compile(), count(), vl::DiskDirectory::diskSubDir(), endsWith(), vl::QtFile::exists(), vlX::VLXClassWrapper_GLSLShader::exportGLSLShader(), vlX::VLXClassWrapper_Texture::exportTexture(), extractFileExtension(), extractFileName(), extractPath(), filterStrings(), find(), findBackwards(), findInLargeText(), vl::LoadWriterManager::findLoader(), vl::LoadWriterManager::findWriter(), vl::Terrain::init(), insert(), vl::OpenGLContext::isCleanState(), vl::GLSLProgram::linkProgram(), vl::loadImagesFromDir(), vl::ObjLoader::loadObjMaterials(), vl::FileSystem::locateFile(), main(), operator==(), vl::StandardLog::printImplementation(), vl::GLSLProgram::programBinary(), vl::QtDirectory::qtSubDir(), vl::PlyLoader::readHeader(), vl::TextStream::readLineCR(), vl::TextStream::readLineLF(), vl::TextStream::readQuotedString(), vl::TextStream::readString(), vl::GLSLShader::reload(), vl::StandardLog::setLogFile(), vl::MemoryDirectory::setPath(), vl::ZippedDirectory::setPath(), vl::VirtualDirectory::setPath(), vl::GLSLShader::setSource(), split(), splitLines(), squeeze(), startsWith(), substring(), toAscii(), toDouble(), toInt(), toLatin1(), toLowerCase(), toStdString(), toStdWString(), toUpperCase(), toUTF16BE(), toUTF16LE(), and toUTF8().
bool String::endsWith | ( | const String & | str | ) | const |
Returns true
if a String ends with the specified String str
.
Definition at line 705 of file String.cpp.
References empty(), and length().
Referenced by filterStrings(), vl::ZippedDirectory::init(), vl::isJPG(), vl::isMHD(), vl::isTGA(), vl::LoadWriterManager::loadResource(), main(), normalizeSlashes(), vl::MemoryDirectory::setPath(), vl::ZippedDirectory::setPath(), and vl::VirtualDirectory::setPath().
bool String::endsWith | ( | wchar_t | ch | ) | const |
Returns true
if a String ends with the specified character.
Definition at line 737 of file String.cpp.
String String::extractFileExtension | ( | bool | require_dot = true | ) | const |
If the String contains a file name or file path the function returns the extension of the file.
Definition at line 857 of file String.cpp.
References empty(), findBackwards(), String(), and substring().
Referenced by vl::LoadWriterManager::findLoader(), vl::LoadWriterManager::findWriter(), and vlX::LoadWriterVLX::writeResource().
String String::extractFileName | ( | ) | const |
If the String contains a file path the function returns the file name without the path.
Definition at line 845 of file String.cpp.
References empty(), findBackwards(), String(), and substring().
Referenced by vl::FileSystem::locateFile().
String String::extractPath | ( | ) | const |
If the String contains a file path the function returns the path with trailing slash, without the file name.
Definition at line 830 of file String.cpp.
References empty(), findBackwards(), normalizeSlashes(), String(), and substring().
Referenced by vl::isDAT(), vl::MemoryDirectory::listSubDirs(), vl::ZippedDirectory::listSubDirs(), vl::loadAC3D(), vl::loadDAT(), vl::loadMHD(), vl::ObjLoader::loadOBJ(), vl::A3DSLoader::readMapChunk(), and vlX::VLXSerializer::resolvePath().
String String::field | ( | wchar_t | separator, |
int | field_index | ||
) | const |
Splits a String into a set of fields based on the specified separator
and returns the filed at position field_index
.
Definition at line 453 of file String.cpp.
References length().
Referenced by vl::ObjLoader::loadObjMaterials(), and vl::PlyLoader::readHeader().
String & String::fill | ( | wchar_t | ch | ) |
Fills the string with the specified character ch
.
Definition at line 298 of file String.cpp.
References acquireData(), and length().
Filters the specified Strings using the given filter. The filter
must be of the type "*abc"
, "abc*"
and "*abc*"
.
Definition at line 1377 of file String.cpp.
References empty(), endsWith(), vl::Log::error(), find(), length(), remove(), and startsWith().
Referenced by vl::VirtualDirectory::listFilesRecursive().
int String::find | ( | wchar_t | ch, |
int | start = 0 |
||
) | const |
Searches for the specified character ch
starting at position start
and returns the index of the first occurrence or -1 if no occurrence was found.
Definition at line 217 of file String.cpp.
References empty(), and length().
Referenced by vl::ResourceLoadWriter::canLoad(), vl::ResourceLoadWriter::canWrite(), contains(), count(), filterStrings(), vl::Say::pipeline(), remove(), and replace().
int String::find | ( | const String & | substr, |
int | start = 0 |
||
) | const |
Searches for the specified string substr
starting at position start
and returns the index of the first occurrence or -1 if no occurrence was found.
Definition at line 265 of file String.cpp.
int String::findBackwards | ( | wchar_t | ch | ) | const |
Searches for the specified character chstarting from the end of the string and returns the index of the first occurrence or -1 if no occurrence was found.
Definition at line 177 of file String.cpp.
References empty(), and length().
Referenced by extractFileExtension(), extractFileName(), and extractPath().
int String::findBackwards | ( | const String & | str | ) | const |
Searches for the specified String chstr from the end of the string and returns the index of the first occurrence or -1 if no occurrence was found.
Definition at line 189 of file String.cpp.
int String::findInLargeText | ( | const String & | substr, |
int | start = 0 |
||
) | const |
Searches for the specified string substr
starting at position start
and returns the index of the first occurrence or -1 if no occurrence was found.
This function can be substantially quicker that find() when searching in large texts but it can be slower than find() for small ones.
Definition at line 251 of file String.cpp.
|
static |
Initializes the string from a 7 bit ascii string.
Definition at line 889 of file String.cpp.
References acquireData().
Referenced by fromDouble(), fromInt(), fromLongLong(), fromPointer(), fromStdString(), fromUInt(), fromULongLong(), and loadText().
|
static |
Creates a string representing the given double value The value of 'decimals' can be between 0 and 20.
Definition at line 1112 of file String.cpp.
References fromAscii().
Referenced by vl::Log::operator<<().
|
static |
Creates a string representing the given integer value.
Definition at line 1080 of file String.cpp.
References fromAscii().
Referenced by vl::Log::operator<<().
|
static |
The size of the buffer pointed by 'str' must be at least 'character_count' bytes large or null terminated.
Definition at line 1057 of file String.cpp.
References acquireData().
Referenced by loadText().
|
static |
Creates a string representing the given long long value.
Definition at line 1096 of file String.cpp.
References fromAscii().
Referenced by vl::Log::operator<<().
|
static |
Creates a string representing the given pointer.
Definition at line 1072 of file String.cpp.
References fromAscii().
Referenced by vl::Log::operator<<().
|
static |
Initializes the string from a std::string using fromUTF() if utf8 == true (default) otherwise uses fromAscii().
Definition at line 881 of file String.cpp.
References fromAscii(), and fromUTF8().
Referenced by vl::QtDirectory::listFiles(), vl::QtDirectory::listSubDirs(), vl::Log::operator<<(), and vlX::VLXSerializer::resolvePath().
|
static |
Initializes the string from a std::string using the fromAscii() function.
Definition at line 870 of file String.cpp.
References acquireData().
|
static |
Creates a string representing the given unsigned integer value.
Definition at line 1088 of file String.cpp.
References fromAscii().
Referenced by vl::Log::operator<<().
|
static |
Creates a string representing the given unsigned long long value.
Definition at line 1104 of file String.cpp.
References fromAscii().
Referenced by vl::Log::operator<<().
|
static |
str must have UTF16 LE or UTF16 BE signature The size of the buffer pointed by 'str' must be at least 'byte_count' bytes large or null terminated.
Definition at line 982 of file String.cpp.
References acquireData(), clear(), vl::Log::error(), fromUTF16BE(), and fromUTF16LE().
|
static |
Accepts strings with and without UTF16 BE signature Supports natively the characters from the BMP, the other characters are substituted with '?' The size of the buffer pointed by 'str' must be at least 'byte_count' bytes large or null terminated.
Definition at line 910 of file String.cpp.
References acquireData(), and vl::VL_COMPILE_TIME_CHECK().
Referenced by fromUTF16(), and loadText().
|
static |
Accepts strings with and without UTF16 LE signature Supports natively the characters from the BMP, the other characters are substituted with '?' The size of the buffer pointed by 'str' must be at least 'byte_count' bytes large or null terminated.
Definition at line 946 of file String.cpp.
References acquireData(), and vl::VL_COMPILE_TIME_CHECK().
Referenced by fromUTF16(), and loadText().
|
static |
Accepts strings with and without UTF8 signature.
Definition at line 1000 of file String.cpp.
References acquireData().
Referenced by fromStdString(), vl::ZippedDirectory::init(), loadText(), vl::TextStream::readLine(), vl::TextStream::readLineCR(), and vl::TextStream::readLineLF().
|
static |
Returns the lower-case version of the specified character.
Definition at line 1445 of file String.cpp.
Referenced by toLowerCase().
|
static |
Returns the title-case version of the specified character.
Definition at line 1458 of file String.cpp.
|
static |
Returns the upper-case version of the specified character.
Definition at line 1432 of file String.cpp.
Referenced by toUpperCase().
Inserts str
at position pos
.
Definition at line 781 of file String.cpp.
References acquireData(), append(), empty(), and length().
Referenced by vl::Say::euronotation(), vl::Say::format(), vl::Say::pipeline(), prepend(), and replace().
String & String::insert | ( | int | pos, |
wchar_t | ch, | ||
int | count = 1 |
||
) |
Inserts count
characters ch
starting at position pos
.
Definition at line 797 of file String.cpp.
References acquireData(), append(), count(), and length().
String String::left | ( | int | count | ) | const |
Returns the count
leftmost caracters of a String. If count
is negative the function returns all but the abs(count) rightmost caracters.
Definition at line 814 of file String.cpp.
References length(), and substring().
Referenced by vl::MemoryDirectory::listSubDirs(), vl::ZippedDirectory::listSubDirs(), and vl::LoadWriterManager::loadResource().
|
inline |
Returns the length of the string.
Definition at line 133 of file String.hpp.
Referenced by append(), compare(), count(), vl::DiskDirectory::diskSubDir(), endsWith(), vl::Say::euronotation(), field(), fill(), filterStrings(), find(), findBackwards(), findInLargeText(), insert(), left(), normalizeSlashes(), operator==(), vl::Say::parse(), vl::Say::pipeline(), vl::QtDirectory::qtSubDir(), vl::Text::rawboundingRect(), vl::CoreText::rawboundingRect(), vl::ReadPixels::readPixels(), remove(), vl::Text::renderText(), vl::CoreText::renderText(), replace(), reverse(), right(), split(), splitLines(), startsWith(), substring(), toLatin1(), toLowerCase(), toStdWString(), toUpperCase(), toUTF16BE(), toUTF16LE(), toUTF8(), and trim().
|
static |
Loads a String from the specified path.
Definition at line 86 of file String.cpp.
References vl::defFileSystem(), vl::Log::error(), vl::ref< T >::get(), vl::FileSystem::locateFile(), and String().
Referenced by vl::GLSLShader::getShaderSource(), vl::Terrain::init(), loadText(), and vl::GLSLShader::setSource().
|
inlinestatic |
Loads a String from the specified path.
Definition at line 72 of file String.hpp.
References loadText(), and VL_PLATFORM_DEFAULT_ENCODING.
Referenced by loadText().
|
static |
Loads a String from the specified VirtualFile.
Definition at line 98 of file String.cpp.
References vl::VirtualFile::close(), vl::VirtualFile::load(), loadText(), and String().
|
static |
Loads a String from the specified memory buffer.
Definition at line 114 of file String.cpp.
References detectEncoding(), vl::Log::error(), fromAscii(), fromLatin1(), fromUTF16BE(), fromUTF16LE(), fromUTF8(), vl::SE_ASCII, vl::SE_LATIN1, vl::SE_Unknown, vl::SE_UTF16_BE, vl::SE_UTF16_LE, vl::SE_UTF32_BE, vl::SE_UTF32_LE, vl::SE_UTF8, and String().
String & String::normalizeSlashes | ( | ) |
Transform \ slashes in / slashes and removes duplicates.
Definition at line 534 of file String.cpp.
References clear(), endsWith(), length(), replace(), split(), and startsWith().
Referenced by vl::MemoryDirectory::addFile(), extractPath(), vl::ZippedDirectory::init(), vlX::VLXSerializer::resolvePath(), vl::MemoryDirectory::setPath(), vl::ZippedDirectory::setPath(), vl::VirtualDirectory::setPath(), vl::VirtualFile::setPath(), and vl::VirtualDirectory::translatePath().
|
inline |
Returns true
if the String has never been assigned or resized.
Definition at line 139 of file String.hpp.
|
inline |
Definition at line 506 of file String.hpp.
References vl::operator==().
|
inline |
Definition at line 511 of file String.hpp.
References vl::operator==().
|
inline |
Definition at line 516 of file String.hpp.
References vl::operator==().
|
inline |
Definition at line 521 of file String.hpp.
References vl::operator==().
|
inline |
Definition at line 526 of file String.hpp.
References vl::operator==().
|
inline |
Definition at line 538 of file String.hpp.
Definition at line 550 of file String.hpp.
References append().
|
inline |
Definition at line 531 of file String.hpp.
Definition at line 545 of file String.hpp.
|
inline |
Lexicographic sorting, equivalent to "compare(other) < 0"
.
Definition at line 384 of file String.hpp.
|
inline |
Equivalent to '*this = fromUTF8(str);'.
Definition at line 390 of file String.hpp.
Referenced by String().
|
inline |
Equivalent to '*this = fromUTF8(str.c_str());'.
Definition at line 397 of file String.hpp.
|
inline |
Definition at line 403 of file String.hpp.
|
inline |
Definition at line 416 of file String.hpp.
Definition at line 422 of file String.hpp.
References acquireData().
|
inline |
Definition at line 432 of file String.hpp.
References empty(), length(), vl::length(), and ptr().
|
inline |
Definition at line 454 of file String.hpp.
References vl::length().
|
inline |
Definition at line 469 of file String.hpp.
References vl::length().
|
inline |
Definition at line 484 of file String.hpp.
References vl::length().
|
inline |
Definition at line 495 of file String.hpp.
References vl::length().
|
inline |
Returns the character at position i
.
Definition at line 145 of file String.hpp.
|
inline |
Returns the character at position i
.
Definition at line 148 of file String.hpp.
|
inlinestatic |
Returns '\' under windows and '/' under Linux and Mac.
Definition at line 93 of file String.hpp.
Prepends the specified String to another String.
Definition at line 606 of file String.cpp.
References insert().
String & String::prepend | ( | wchar_t | ch, |
int | count | ||
) |
Prepends count
characters ch
to another String.
Definition at line 611 of file String.cpp.
References insert().
|
static |
Returns a formatted string using the legacy printf syntax. The resulting string can be maximum 1024 + strlen(fmt) characters long.
Definition at line 1510 of file String.cpp.
Referenced by vlX::VLXClassWrapper_Geometry::exportGeometry(), vl::GLSLShader::getShaderSource(), vl::RaycastVolume::updateUniforms(), and vlX::VisitorExportToVLT::writeHeader().
|
inline |
Returns the 0-terminated utf16 string.
Definition at line 127 of file String.hpp.
Referenced by vl::DiskDirectory::exists(), vl::DiskDirectory::listFiles(), vl::DiskDirectory::listSubDirs(), vl::log_failed_check(), operator==(), vlWin32::Win32Context::setWindowTitle(), and vlEGL::EGLWindow::setWindowTitle().
|
inline |
Returns the 0-terminated utf16 string.
Definition at line 130 of file String.hpp.
String & String::remove | ( | wchar_t | ch, |
int | start = 0 , |
||
int | count = -1 |
||
) |
Removes 'count' occurrences of the character 'ch' after position 'start'.
If 'count' is set -1 there is no limit to the number of occurrences removed.
Definition at line 502 of file String.cpp.
References acquireData(), and length().
Referenced by filterStrings(), and vl::Say::pipeline().
Removes 'count' occurrences of the string 'str' after position 'start'.
If 'count' is set -1 there is no limit to the number of occurrences removed.
Definition at line 469 of file String.cpp.
References acquireData(), count(), find(), and length().
String & String::remove | ( | int | start, |
int | count | ||
) |
Removes 'count' characters starting at position 'start'.
Definition at line 483 of file String.cpp.
References acquireData(), and length().
String & String::replace | ( | wchar_t | old_ch, |
wchar_t | new_ch | ||
) |
Replaces the character 'old_ch' with 'new_ch'.
Definition at line 656 of file String.cpp.
References acquireData(), and length().
Referenced by normalizeSlashes(), and replace().
String & String::replace | ( | int | start, |
int | count, | ||
wchar_t | ch | ||
) |
Replaces count
characters starting at position start
with ch
.
Definition at line 640 of file String.cpp.
References acquireData(), count(), and length().
Equivalent to remove(start, count); insert(start, str);.
Definition at line 616 of file String.cpp.
String & String::replace | ( | const String & | oldstr, |
const String & | newstr, | ||
bool | case_sensitive = true |
||
) |
Replaces all the occurrences of oldstr with newstr.
Definition at line 623 of file String.cpp.
References acquireData(), find(), length(), replace(), and toLowerCase().
String & String::resize | ( | int | character_count | ) |
Resizes the string to the specified character count.
Definition at line 146 of file String.cpp.
References acquireData().
Referenced by createData(), vl::ZippedDirectory::init(), and vl::Say::pipeline().
String & String::reverse | ( | ) |
Reverses the order of the characters in the string.
Definition at line 521 of file String.cpp.
References acquireData(), count(), and length().
String String::right | ( | int | count | ) | const |
Returns the count
rightmost caracters of a String. If count
is negative the function returns all but the abs(count) leftmost caracters.
Definition at line 822 of file String.cpp.
References length(), and substring().
Referenced by vl::DiskDirectory::diskSubDir(), vl::MemoryDirectory::listSubDirs(), vl::ZippedDirectory::listSubDirs(), vl::QtDirectory::qtSubDir(), vlX::VLXSerializer::resolvePath(), vl::MemoryDirectory::setPath(), vl::ZippedDirectory::setPath(), and vl::VirtualDirectory::translatePath().
void String::split | ( | wchar_t | separator, |
std::vector< String > & | fields, | ||
bool | remove_empty_fields = false |
||
) | const |
Splits a String into a set of fields. The fields are separated by the specified separator
and are returned in fields
.
Definition at line 386 of file String.cpp.
References empty(), length(), and String().
Referenced by vl::MemoryDirectory::listSubDirs(), vl::ZippedDirectory::listSubDirs(), vl::loadMHD(), normalizeSlashes(), and vl::ObjTexture::parseLine().
void String::split | ( | const String & | separator_list, |
std::vector< String > & | fields, | ||
bool | remove_empty_fields = false |
||
) | const |
Splits a String into a set of fields. The fields are separated by the specified separator_list
and are returned in fields
.
Definition at line 352 of file String.cpp.
References contains(), empty(), length(), and String().
void String::splitLines | ( | std::vector< String > & | lines | ) | const |
Splits a String into a set of Strings each of which contains a line.
Definition at line 420 of file String.cpp.
References empty(), length(), and String().
Referenced by vl::GLSLShader::getShaderSource().
void String::squeeze | ( | ) |
Minimizes the memory buffer used to store the String.
Definition at line 290 of file String.cpp.
References empty().
bool String::startsWith | ( | const String & | str | ) | const |
Returns true
if a String starts with the specified String str
.
Definition at line 720 of file String.cpp.
References empty(), and length().
Referenced by vl::MemoryDirectory::addFile(), vl::DiskDirectory::diskSubDir(), filterStrings(), vl::ObjLoader::loadObjMaterials(), normalizeSlashes(), vl::QtDirectory::qtSubDir(), vl::PlyLoader::readHeader(), vlX::VLXSerializer::resolvePath(), vl::MemoryDirectory::setPath(), vl::ZippedDirectory::setPath(), and vl::VirtualDirectory::translatePath().
bool String::startsWith | ( | wchar_t | ch | ) | const |
Returns true
if a String starts with the specified character.
Definition at line 746 of file String.cpp.
String String::substring | ( | int | start, |
int | count = -1 |
||
) | const |
Returns the count
characters long substring starting a character index start
. If count
== -1 the returned substring will contain all the characters from start
to the end of the String.
Definition at line 153 of file String.cpp.
References acquireData(), empty(), length(), and String().
Referenced by extractFileExtension(), extractFileName(), extractPath(), left(), right(), and trim().
void String::toAscii | ( | std::string & | ascii, |
bool | translate_non_ascii_chars = true |
||
) | const |
Provides some basic character translation of code points outside of the ASCII range.
Definition at line 1174 of file String.cpp.
References empty().
double String::toDouble | ( | ) | const |
Returns the double number represented by the string. The conversion is done using the standard atof() function.
Definition at line 1368 of file String.cpp.
References empty(), and toStdString().
Referenced by vl::ObjLoader::loadObjMaterials().
|
inline |
Returns the float number represented by the string. The conversion is done using the standard atof() function.
Definition at line 348 of file String.hpp.
Referenced by vl::Image::contrastHounsfieldAuto(), and vl::ObjLoader::loadObjMaterials().
int String::toInt | ( | bool | hex = false | ) | const |
Returns the int number represented by the string. The conversion is done using the standard atoi() function.
Definition at line 1352 of file String.cpp.
References empty(), and toStdString().
Referenced by vl::Image::contrastHounsfieldAuto(), vl::ObjLoader::loadObjMaterials(), and vl::PlyLoader::readHeader().
void String::toLatin1 | ( | std::vector< unsigned char > & | latin1 | ) | const |
Encodes the String into a Latin1 encoded string.
Definition at line 1318 of file String.cpp.
String String::toLowerCase | ( | ) | const |
Returns the lower-case version of a String.
Definition at line 755 of file String.cpp.
References acquireData(), empty(), getLowerCase(), length(), and String().
Referenced by vl::ResourceLoadWriter::canLoad(), vl::ResourceLoadWriter::canWrite(), vl::LoadWriterManager::findLoader(), vl::LoadWriterManager::findWriter(), vl::isJPG(), vl::isMHD(), vl::isTGA(), vl::loadImagesFromDir(), replace(), vl::ResourceLoadWriter::setLoadExtensions(), vl::ResourceLoadWriter::setWriteExtensions(), and vlX::LoadWriterVLX::writeResource().
std::string String::toStdString | ( | ) | const |
Returns a UTF8 encoded std::string.
Definition at line 1156 of file String.cpp.
References empty(), and toUTF8().
Referenced by vl::abort_vl(), vl::atomType(), vlX::VLXClassWrapper_Geometry::exportGeometry(), vlX::VLXClassWrapper_GLSLShader::exportGLSLShader(), vlX::VLXClassWrapper_Texture::exportTexture(), vl::DaeLoader::generateGeometry(), vl::Image::Image(), vl::ZippedDirectory::init(), vlGLFW::GLFWWindow::initGLFWWindow(), vlGLUT::GLUTWindow::initGLUTWindow(), vl::QtDirectory::listFiles(), vl::QtDirectory::listSubDirs(), vl::DaeLoader::load(), vl::load3DS(), vl::loadBMP(), vl::loadDDS(), vl::loadDICOM(), vl::loadImage(), vl::loadJPG(), vl::loadMHD(), vl::ObjLoader::loadOBJ(), vl::ObjLoader::loadObjMaterials(), vl::loadPNG(), vl::loadTGA(), main(), vl::ObjTexture::print(), vl::StandardLog::printImplementation(), vlX::VLXSerializer::resolvePath(), vlX::VLXSerializer::saveVLB(), vlX::VLXSerializer::saveVLT(), vl::StandardLog::setLogFile(), vl::GLSLShader::setSource(), vlSDL::SDLWindow::setWindowTitle(), vlWX::WXGLCanvas::setWindowTitle(), vlGLUT::GLUTWindow::setWindowTitle(), vlGLFW::GLFWWindow::setWindowTitle(), vlQt5::Qt5Widget::setWindowTitle(), vlQt4::Qt4Widget::setWindowTitle(), vlQt6::Qt6Widget::setWindowTitle(), toDouble(), toInt(), and vlX::VisitorExportToVLT::writeHeader().
std::wstring String::toStdWString | ( | ) | const |
Returns the std::wstring representation of a String.
Definition at line 1144 of file String.cpp.
References empty(), and length().
Referenced by vlWX::WXGLCanvas::setWindowTitle().
String String::toUpperCase | ( | ) | const |
Returns the upper-case version of a String.
Definition at line 768 of file String.cpp.
References acquireData(), empty(), getUpperCase(), length(), and String().
void String::toUTF16BE | ( | std::vector< unsigned char > & | utf16, |
bool | include_utf16be_signature = true |
||
) | const |
Encodes the String into a UTF16 big endian encoded string.
Definition at line 1266 of file String.cpp.
void String::toUTF16LE | ( | std::vector< unsigned char > & | utf16, |
bool | include_utf16le_signature = true |
||
) | const |
Encodes the String into a UTF16 little endian encoded string.
Definition at line 1292 of file String.cpp.
void String::toUTF8 | ( | std::vector< unsigned char > & | utf8, |
bool | include_utf8_signature = true |
||
) | const |
Encodes the String into a UTF8 encoded string.
Definition at line 1218 of file String.cpp.
References empty(), and length().
Referenced by vl::DiskDirectory::exists(), vl::DiskFile::exists(), vl::DiskDirectory::listFiles(), vl::DiskDirectory::listSubDirs(), vl::DiskFile::open(), vl::DiskFile::size(), toStdString(), and toUTF8().
void String::toUTF8 | ( | std::string & | utf8, |
bool | include_utf8_signature = true |
||
) | const |
Encodes the String into a UTF8 encoded std::string.
Definition at line 1206 of file String.cpp.
References toUTF8().
String & String::trim | ( | wchar_t | ch | ) |
Removes the specified character ch
from the beginning and the end of the String.
Definition at line 322 of file String.cpp.
References acquireData(), length(), and substring().
Referenced by vl::atomType(), vl::ObjLoader::loadObjMaterials(), vl::PlyLoader::readHeader(), vl::MemoryDirectory::setPath(), vl::ZippedDirectory::setPath(), and vl::VirtualDirectory::setPath().
Removes the characters contained in chars
from the beginning and the end of the String.
Definition at line 307 of file String.cpp.
References acquireData(), length(), and trim().
String & String::trim | ( | ) |
Equivalent to trim
("\n\r\t\v "), that is, removes all the tabs, spaces and new-lines from the beginning and end of a String.
Definition at line 343 of file String.cpp.
References acquireData().
Referenced by vl::ObjLoader::loadOBJ(), and trim().
|
static |
Remove the spaces before and after an std::string.
Definition at line 1471 of file String.cpp.
Referenced by vl::ObjLoader::loadOBJ().
Visualization Library 2.1.0 Reference Documentation
Updated on Wed Mar 10 2021 16:02:54.
© Copyright Michele Bosi. All rights reserved.