Visualization Library v1.0.3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions

vl::String Class Reference

The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine. More...

#include <String.hpp>

List of all members.

Classes

class  StringData

Public Member Functions

 String ()
 Constructor.
 String (const String &other)
 Constructor.
 String (const wchar_t *wstr)
 Constructor.
 String (const char *str)
 Constructor.
 String (wchar_t ch, int count=1)
 Constructor.
const wchar_t * ptr () const
 Returns the 0-terminated utf16 string.
wchar_t * ptr ()
 Returns the 0-terminated utf16 string.
int length () const
 Returns the length of the string.
bool empty () const
 Returns true if length() == 0.
bool null () const
 Returns true if the String has never been assigned or resized.
Stringclear ()
 Clears the string.
const wchar_t & operator[] (int i) const
 Returns the character at position i.
wchar_t & operator[] (int i)
 Returns the character at position i.
Stringreplace (wchar_t old_ch, wchar_t new_ch)
 Replaces the character 'old_ch' with 'new_ch'.
Stringreplace (int start, int count, wchar_t ch)
 Replaces count characters starting at position start with ch.
Stringreplace (int start, int count, const String &str)
 Equivalent to remove(start, count); insert(start, str);.
Stringreplace (const String &oldstr, const String &newstr, bool case_sensitive=true)
 Replaces all the occurrences of oldstr with newstr.
Stringremove (wchar_t ch, int start=0, int count=-1)
 Removes 'count' occurrences of the character 'ch' after position 'start'.
Stringremove (const String &str, int start=0, int count=-1)
 Removes 'count' occurrences of the string 'str' after position 'start'.
Stringremove (int start, int count)
 Removes 'count' characters starting at position 'start'.
Stringreverse ()
 Reverses the order of the characters in the string.
StringnormalizeSlashes ()
 Transform \ slashes in / slashes and removes duplicates.
int count (wchar_t ch, int start=0) const
 Returns the number of occurrences of the given character after position 'start'.
int count (const String &str, int start=0) const
 Returns the number of occurrences of the given string after position 'start'.
int compare (const String &other) const
 Performs a lexicographic comparison.
bool endsWith (const String &str) const
 Returns true if a String ends with the specified String str.
bool startsWith (const String &str) const
 Returns true if a String starts with the specified String str.
bool endsWith (wchar_t ch) const
 Returns true if a String ends with the specified character.
bool startsWith (wchar_t ch) const
 Returns true if a String starts with the specified character.
Stringinsert (int pos, const String &str)
 Inserts str at position pos.
Stringinsert (int pos, wchar_t ch, int count=1)
 Inserts count characters ch starting at position pos.
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.
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.
String extractPath () const
 If the String contains a file path the function returns the path with trailing slash, without the file name.
String extractFileName () const
 If the String contains a file path the function returns the file name without the path.
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.
Stringresize (int character_count)
 Resizes the string to the specified character count.
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.
Stringfill (wchar_t ch)
 Fills the string with the specified character ch.
Stringtrim (wchar_t ch)
 Removes the specified character ch from the beginning and the end of the String.
Stringtrim (const String &chars)
 Removes the characters contained in chars from the beginning and the end of the String.
Stringtrim ()
 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.
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.
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.
void splitLines (std::vector< String > &lines) const
 Splits a String into a set of Strings each of which contains a line.
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.
Stringappend (const String &other)
 Appends the specified String to another String.
Stringappend (wchar_t ch, int count=1)
 Appends count characters ch to another String.
Stringprepend (const String &str)
 Prepends the specified String to another String.
Stringprepend (wchar_t ch, int count)
 Prepends count characters ch to another String.
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.
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.
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.
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.
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.
bool contains (wchar_t ch) const
 Returns true if a String contains the specified character.
bool contains (const String &str) const
 Returns true if a String contains the specified String.
void squeeze ()
 Minimizes the memory buffer used to store the String.
int toInt (bool hex=false) const
 Returns the int number represented by the string. The conversion is done using the standard atoi() function.
double toDouble () const
 Returns the double number represented by the string. The conversion is done using the standard atof() function.
float toFloat () const
 Returns the float number represented by the string. The conversion is done using the standard atof() function.
std::string toStdString () const
 Returns a UTF8 encoded std::string.
std::wstring toStdWString () const
 Returns the std::wstring representation of a String.
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.
void toUTF8 (std::vector< unsigned char > &utf8, bool include_utf8_signature=true) const
 Encodes the String into a UTF8 encoded string.
void toUTF8 (std::string &utf8, bool include_utf8_signature=true) const
 Encodes the String into a UTF8 encoded std::string.
void toUTF16BE (std::vector< unsigned char > &utf16, bool include_utf16be_signature=true) const
 Encodes the String into a UTF16 big endian encoded string.
void toUTF16LE (std::vector< unsigned char > &utf16, bool include_utf16le_signature=true) const
 Encodes the String into a UTF16 little endian encoded string.
void toLatin1 (std::vector< unsigned char > &latin1) const
 Encodes the String into a Latin1 encoded string.
String toLowerCase () const
 Returns the lower-case version of a String.
String toUpperCase () const
 Returns the upper-case version of a String.
bool operator< (const String &other) const
 Lexicographic sorting, equivalent to "compare(other) < 0".
Stringoperator= (const char *str)
 Equivalent to '*this = fromUTF8(str);'.
Stringoperator= (const std::string &str)
 Equivalent to '*this = fromUTF8(str.c_str());'.
Stringoperator= (const wchar_t *wstr)
Stringoperator= (const std::wstring &str)
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
Stringoperator+= (wchar_t ch)
String operator+ (wchar_t ch) const
Stringoperator+= (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.

Static Public Member Functions

static EStringEncoding detectEncoding (const void *str, int byte_count, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
 Detects the encoding.
static String loadText (const String &path, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
 Loads a String from the specified path.
static String loadText (const char *path, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
 Loads a String from the specified path.
static String loadText (VirtualFile *file, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
 Loads a String from the specified VirtualFile.
static String loadText (void *data, int bytes, EStringEncoding encoding=VL_PLATFORM_DEFAULT_ENCODING)
 Loads a String from the specified memory buffer.
static unsigned short getUpperCase (unsigned short ch)
 Returns the upper-case version of the specified character.
static unsigned short getLowerCase (unsigned short ch)
 Returns the lower-case version of the specified character.
static unsigned short getTitleCase (unsigned short ch)
 Returns the title-case version of the specified character.
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*".
static wchar_t platformSlash ()
 Returns '\' under windows and '/' under Linux and Mac.
static std::string trimStdString (const std::string &text)
 Remove the spaces before and after an std::string.
static String fromPointer (const void *value)
 Creates a string representing the given pointer.
static String fromInt (int value)
 Creates a string representing the given integer value.
static String fromUInt (unsigned int value)
 Creates a string representing the given unsigned integer value.
static String fromLongLong (long long value)
 Creates a string representing the given long long value.
static String fromULongLong (unsigned long long value)
 Creates a string representing the given unsigned long long value.
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.
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().
static String fromStdWString (const std::wstring &str)
 Initializes the string from a std::string using the fromAscii() function.
static String fromAscii (const char *str, int size=-1)
 Initializes the string from a 7 bit ascii string.
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.
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.
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.
static String fromUTF8 (const char *str, int byte_count=-1)
 Accepts strings with and without UTF8 signature.
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.
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.

Protected Member Functions

void createData () const

Detailed Description

The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.

The String class features:

Definition at line 62 of file String.hpp.


Constructor & Destructor Documentation

String::String (  )
String::String ( const String other )

Constructor.

Definition at line 54 of file String.cpp.

References operator=().

String::String ( const wchar_t *  wstr )

Constructor.

Definition at line 59 of file String.cpp.

References acquireData().

String::String ( const char *  str )

Constructor.

Definition at line 68 of file String.cpp.

References acquireData().

String::String ( wchar_t  ch,
int  count = 1 
) [explicit]

Constructor.

Definition at line 77 of file String.cpp.

References acquireData(), and count().


Member Function Documentation

EStringEncoding String::detectEncoding ( const void *  str,
int  byte_count,
EStringEncoding  encoding = VL_PLATFORM_DEFAULT_ENCODING 
) [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().

String String::loadText ( const String path,
EStringEncoding  encoding = VL_PLATFORM_DEFAULT_ENCODING 
) [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::Terrain::init(), loadText(), and vl::GLSLShader::setSource().

static String vl::String::loadText ( const char *  path,
EStringEncoding  encoding = VL_PLATFORM_DEFAULT_ENCODING 
) [inline, static]

Loads a String from the specified path.

Definition at line 72 of file String.hpp.

References loadText().

Referenced by loadText().

String String::loadText ( VirtualFile file,
EStringEncoding  encoding = VL_PLATFORM_DEFAULT_ENCODING 
) [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().

String String::loadText ( void *  data,
int  bytes,
EStringEncoding  encoding = VL_PLATFORM_DEFAULT_ENCODING 
) [static]
unsigned short String::getUpperCase ( unsigned short  ch ) [static]

Returns the upper-case version of the specified character.

Definition at line 1432 of file String.cpp.

Referenced by toUpperCase().

unsigned short String::getLowerCase ( unsigned short  ch ) [static]

Returns the lower-case version of the specified character.

Definition at line 1445 of file String.cpp.

Referenced by toLowerCase().

unsigned short String::getTitleCase ( unsigned short  ch ) [static]

Returns the title-case version of the specified character.

Definition at line 1458 of file String.cpp.

void String::filterStrings ( std::vector< String > &  strings,
const String filter 
) [static]

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().

static wchar_t vl::String::platformSlash (  ) [inline, static]

Returns '\' under windows and '/' under Linux and Mac.

Definition at line 93 of file String.hpp.

std::string String::trimStdString ( const std::string &  text ) [static]

Remove the spaces before and after an std::string.

Definition at line 1471 of file String.cpp.

Referenced by vl::ObjLoader::loadOBJ().

const wchar_t* vl::String::ptr (  ) const [inline]
wchar_t* vl::String::ptr (  ) [inline]

Returns the 0-terminated utf16 string.

Definition at line 124 of file String.hpp.

int vl::String::length (  ) const [inline]
bool vl::String::empty (  ) const [inline]
bool vl::String::null (  ) const [inline]

Returns true if the String has never been assigned or resized.

Definition at line 133 of file String.hpp.

String& vl::String::clear (  ) [inline]
const wchar_t& vl::String::operator[] ( int  i ) const [inline]

Returns the character at position i.

Definition at line 139 of file String.hpp.

wchar_t& vl::String::operator[] ( int  i ) [inline]

Returns the character at position i.

Definition at line 142 of file String.hpp.

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().

String & String::replace ( int  start,
int  count,
const String str 
)

Equivalent to remove(start, count); insert(start, str);.

Definition at line 616 of file String.cpp.

References count(), and insert().

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::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().

String & String::remove ( const String str,
int  start = 0,
int  count = -1 
)

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::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::normalizeSlashes (  )
int String::count ( wchar_t  ch,
int  start = 0 
) const

Returns the number of occurrences of the given character after position 'start'.

Definition at line 666 of file String.cpp.

References empty(), and length().

Referenced by append(), insert(), remove(), replace(), reverse(), vl::GLSLShader::setSource(), and String().

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.

References empty(), find(), and length().

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::endsWith ( const String str ) const
bool String::startsWith ( const String str ) const
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.

References empty(), and length().

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.

References empty(), and length().

String & String::insert ( int  pos,
const String str 
)

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::ZippedDirectory::listSubDirs(), and vl::MemoryDirectory::listSubDirs().

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::ZippedDirectory::listSubDirs(), vl::MemoryDirectory::listSubDirs(), vl::VLXSerializer::resolvePath(), vl::ZippedDirectory::setPath(), vl::MemoryDirectory::setPath(), and vl::VirtualDirectory::translatePath().

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::ZippedDirectory::listSubDirs(), vl::MemoryDirectory::listSubDirs(), vl::loadAC3D(), vl::loadDAT(), vl::ObjLoader::loadOBJ(), vl::A3DSLoader::readMapChunk(), and vl::VLXSerializer::resolvePath().

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::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 vl::LoadWriterVLX::writeResource().

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 vl::ZippedDirectory::init(), vl::Say::pipeline(), and printf().

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().

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().

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::ZippedDirectory::setPath(), vl::VirtualDirectory::setPath(), and vl::MemoryDirectory::setPath().

String & String::trim ( const String chars )

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().

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::ZippedDirectory::listSubDirs(), vl::MemoryDirectory::listSubDirs(), 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().

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::append ( const String other )

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().

String & String::prepend ( const String str )

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().

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.

References empty(), length(), and vl::max().

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.

References empty(), and length().

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.

References empty(), and length().

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().

void String::squeeze (  )

Minimizes the memory buffer used to store the String.

Definition at line 290 of file String.cpp.

References empty().

String String::fromPointer ( const void *  value ) [static]

Creates a string representing the given pointer.

Definition at line 1072 of file String.cpp.

References fromAscii().

Referenced by vl::Log::operator<<().

String String::fromInt ( int  value ) [static]

Creates a string representing the given integer value.

Definition at line 1080 of file String.cpp.

References fromAscii().

Referenced by vl::Log::operator<<().

String String::fromUInt ( unsigned int  value ) [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<<().

String String::fromLongLong ( long long  value ) [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<<().

String String::fromULongLong ( unsigned long long  value ) [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<<().

String String::fromDouble ( double  value,
int  decimals = 6 
) [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<<().

String String::fromStdString ( const std::string &  str,
bool  utf8 = true 
) [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::Log::operator<<(), and vl::VLXSerializer::resolvePath().

String String::fromStdWString ( const std::wstring &  str ) [static]

Initializes the string from a std::string using the fromAscii() function.

Definition at line 870 of file String.cpp.

References acquireData().

String String::fromAscii ( const char *  str,
int  size = -1 
) [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().

String String::fromUTF16BE ( const unsigned short *  str,
int  byte_count = -1 
) [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().

String String::fromUTF16LE ( const unsigned short *  str,
int  byte_count = -1 
) [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().

String String::fromUTF16 ( const unsigned short *  str,
int  byte_count = -1 
) [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().

String String::fromUTF8 ( const char *  str,
int  byte_count = -1 
) [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().

String String::fromLatin1 ( const char *  str,
int  character_count = -1 
) [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().

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().

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().

float vl::String::toFloat (  ) const [inline]

Returns the float number represented by the string. The conversion is done using the standard atof() function.

Definition at line 342 of file String.hpp.

Referenced by vl::Image::contrastHounsfieldAuto(), and vl::ObjLoader::loadObjMaterials().

String String::printf ( const char *  fmt,
  ... 
) [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.

References resize().

Referenced by vl::VLXClassWrapper_Geometry::exportGeometry().

std::string String::toStdString (  ) const
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().

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().

void String::toUTF8 ( std::vector< unsigned char > &  utf8,
bool  include_utf8_signature = true 
) const
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().

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.

References empty(), and length().

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.

References empty(), and length().

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.

References empty(), and length().

String String::toLowerCase (  ) const
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().

bool vl::String::operator< ( const String other ) const [inline]

Lexicographic sorting, equivalent to "compare(other) < 0".

Definition at line 378 of file String.hpp.

String& vl::String::operator= ( const char *  str ) [inline]

Equivalent to '*this = fromUTF8(str);'.

Definition at line 384 of file String.hpp.

Referenced by String().

String& vl::String::operator= ( const std::string &  str ) [inline]

Equivalent to '*this = fromUTF8(str.c_str());'.

Definition at line 391 of file String.hpp.

String& vl::String::operator= ( const wchar_t *  wstr ) [inline]

Definition at line 397 of file String.hpp.

String& vl::String::operator= ( const std::wstring &  str ) [inline]

Definition at line 410 of file String.hpp.

bool vl::String::operator== ( const String other ) const [inline]

Definition at line 424 of file String.hpp.

References empty(), vl::length(), length(), and ptr().

bool vl::String::operator== ( const std::string &  other ) const [inline]

Definition at line 446 of file String.hpp.

References vl::length().

bool vl::String::operator== ( const std::wstring &  other ) const [inline]

Definition at line 461 of file String.hpp.

References vl::length().

bool vl::String::operator== ( const char *  other ) const [inline]

Definition at line 476 of file String.hpp.

References vl::length().

bool vl::String::operator== ( const wchar_t *  other ) const [inline]

Definition at line 487 of file String.hpp.

References vl::length().

bool vl::String::operator!= ( const String other ) const [inline]

Definition at line 498 of file String.hpp.

References vl::operator==().

bool vl::String::operator!= ( const std::string &  other ) const [inline]

Definition at line 503 of file String.hpp.

References vl::operator==().

bool vl::String::operator!= ( const std::wstring &  other ) const [inline]

Definition at line 508 of file String.hpp.

References vl::operator==().

bool vl::String::operator!= ( const char *  other ) const [inline]

Definition at line 513 of file String.hpp.

References vl::operator==().

bool vl::String::operator!= ( const wchar_t *  other ) const [inline]

Definition at line 518 of file String.hpp.

References vl::operator==().

String& vl::String::operator+= ( wchar_t  ch ) [inline]

Definition at line 523 of file String.hpp.

String vl::String::operator+ ( wchar_t  ch ) const [inline]

Definition at line 530 of file String.hpp.

String& vl::String::operator+= ( const String other ) [inline]

Definition at line 537 of file String.hpp.

String vl::String::operator+ ( const String other ) const [inline]

Definition at line 542 of file String.hpp.

References append().

void vl::String::acquireData (  ) const [inline]

Acquires a private copy of the data if the string has been copied from another one.

Definition at line 550 of file String.hpp.

Referenced by append(), fill(), fromAscii(), fromLatin1(), fromStdWString(), fromUTF16(), fromUTF16BE(), fromUTF16LE(), fromUTF8(), insert(), remove(), replace(), resize(), reverse(), String(), substring(), toLowerCase(), toUpperCase(), and trim().

void vl::String::createData (  ) const [inline, protected]

Definition at line 559 of file String.hpp.

Referenced by compare().


The documentation for this class was generated from the following files:

Visualization Library v1.0.3 Reference Documentation
Copyright Michele Bosi. All rights reserved.
Updated on Tue Feb 7 2017 00:55:07.
Permission is granted to use this page to write and publish articles regarding Visualization Library.