C3D Toolkit  Kernel - 117982, Vision - 2.9.2.2
VSN::String Class Reference

General String class based on Unicode standard. More...

#include <vsn_string.h>

+ Collaboration diagram for VSN::String:

Public Member Functions

 String ()
 Default constructor creating an empty String.
 
 String (const String &str)
 Copy constructor from another String object.
 
 String (const char *str)
 Constructor by defined pointer to const char.
 
 String (char *str)
 Constructor by defined pointer to char.
 
 String (const char *str, unsigned length)
 Constructor by defined pointer to const char and by length.
 
 String (const wchar_t *str)
 Constructor by defined pointer to null-terminated const wchar_t.
 
 String (wchar_t *str)
 Constructor by defined pointer to null-terminated wchar_t.
 
 String (const WString &str)
 Constructor by WString.
 
 String (int value)
 Constructor by integer.
 
 String (short value)
 Constructor by short integer.
 
 String (long value)
 Constructor by long integer.
 
 String (long long value)
 Constructor by long long integer.
 
 String (unsigned value)
 Constructor by unsigned integer.
 
 String (unsigned short value)
 Constructor by unsigned short integer.
 
 String (unsigned long value)
 Constructor by unsigned long integer.
 
 String (unsigned long long value)
 Constructor by unsigned long long integer.
 
 String (float value)
 Constructor by float.
 
 String (double value)
 Constructor by double.
 
 String (bool value)
 Constructor by bool.
 
 String (char value)
 Constructor by character.
 
 String (char value, unsigned length)
 Constructor by character and length.
 
template<class T >
 String (const T &value)
 Constructor by arbitrary type.
 
 ~String ()
 Destructor.
 
Stringoperator= (const String &rhs)
 Assigns String.
 
Stringoperator= (const char *rhs)
 Assigns the specified pointer to const char.
 
Stringoperator+= (const String &rhs)
 Assigns and add the specified String.
 
Stringoperator+= (const char *rhs)
 Assigns and adds the specified ponter to const char.
 
Stringoperator+= (char rhs)
 Assigns and adds the specified char.
 
Stringoperator+= (int rhs)
 Assigns and adds integer, with concatenation as a string.
 
Stringoperator+= (short rhs)
 Assigns and adds short integer, with concatenation as a string.
 
Stringoperator+= (long rhs)
 Assigns and adds long integer, with concatenation as a string.
 
Stringoperator+= (long long rhs)
 Assigns and adds long long integer, with concatenation as a string.
 
Stringoperator+= (unsigned rhs)
 Assigns and adds unsigned integer, with concatenation as a string.
 
Stringoperator+= (unsigned short rhs)
 Assigns and adds unsigned unsigned integer, with concatenation as a string.
 
Stringoperator+= (unsigned long rhs)
 Assigns and adds unsigned long unsigned integer, with concatenation as a string.
 
Stringoperator+= (unsigned long long rhs)
 Assigns and adds long long unsigned integer, with concatenation as a string.
 
Stringoperator+= (float rhs)
 Assigns and adds float, with concatenation as a string.
 
Stringoperator+= (bool rhs)
 Assigns and adds bool, with concatenation as a string.
 
template<class T >
String operator+= (const T &rhs)
 Assigns and adds arbitrary type, with concatenation as a string.
 
String operator+ (const String &rhs) const
 Adds String.
 
String operator+ (const char *rhs) const
 Adds const char array.
 
bool operator== (const String &rhs) const
 Checks equality to another string.
 
bool operator!= (const String &rhs) const
 Checks inequality to another string.
 
bool operator< (const String &rhs) const
 Checks if string is less than another string.
 
bool operator> (const String &rhs) const
 Checks if string is more than another string.
 
bool operator== (const char *rhs) const
 Checks conformance to const char string.
 
bool operator!= (const char *rhs) const
 Checks inequality of specified array.
 
bool operator< (const char *rhs) const
 Checks if string is less than const char string.
 
bool operator> (const char *rhs) const
 Checks if string is more than const char string.
 
char & operator[] (unsigned index)
 Returns char by index.
 
const char & operator[] (unsigned index) const
 Returns const char by index.
 
char & At (unsigned index)
 Returns char by index.
 
const char & At (unsigned index) const
 Returns const char by index.
 
void Replace (char replaceThis, char replaceWith, bool caseSensitive=true)
 Replaces all occurrences of char.
 
void Replace (const String &replaceThis, const String &replaceWith, bool caseSensitive=true)
 Replaces all occurrences of specified strings.
 
void Replace (unsigned pos, unsigned length, const String &replaceWith)
 Replaces substring.
 
void Replace (unsigned pos, unsigned length, const char *replaceWith)
 Replaces substring by const char pointer.
 
Iterator Replace (const Iterator &start, const Iterator &end, const String &replaceWith)
 Replaces substring by iterator.
 
String Replaced (char replaceThis, char replaceWith, bool caseSensitive=true) const
 Returns string with all occurred chars.
 
String Replaced (const String &replaceThis, const String &replaceWith, bool caseSensitive=true) const
 Returns string with all occurred strings.
 
StringAppend (const String &str)
 Adds specified string.
 
StringAppend (const char *str)
 Adds specified const char array.
 
StringAppend (char c)
 Adds specified char.
 
StringAppend (const char *str, unsigned length)
 Adds specified const char array of defined length.
 
void Insert (unsigned pos, const String &str)
 Inserts string to specified position.
 
void Insert (unsigned pos, char c)
 Inserts char to specified position.
 
Iterator Insert (const Iterator &dest, const String &str)
 Inserts string by iterator.
 
Iterator Insert (const Iterator &dest, const Iterator &start, const Iterator &end)
 Inserts string particularly by iterator.
 
Iterator Insert (const Iterator &dest, char c)
 Inserts char by iterator.
 
void Remove (char c)
 Removes char.
 
void Chop (std::ptrdiff_t n)
 Removes n characters from the end of the string.
 
void Erase (unsigned pos, unsigned length=1)
 Erases specified position of defined length.
 
Iterator Erase (const Iterator &it)
 Erases char by iterator.
 
Iterator Erase (const Iterator &start, const Iterator &end)
 Erases chars by iterators.
 
void Resize (unsigned newLength)
 Changes string size.
 
void Reserve (unsigned newCapacity)
 Sets new char capacity.
 
void Compact ()
 Compacts memory.
 
void Clear ()
 Clears string.
 
void Swap (String &str)
 Swaps with another string.
 
Iterator Begin ()
 Returns initial iterator.
 
ConstIterator CBegin () const
 Returns initial const iterator.
 
Iterator End ()
 Returns finite iterator.
 
ConstIterator CEnd () const
 Returns finite const iterator.
 
char Front () const
 Returns the first char or 0 if string is empty.
 
char Back () const
 Returns last char or 0 if string is empty.
 
String Substring (unsigned pos) const
 Returns substring from specified position to end of substring.
 
String Substring (unsigned pos, unsigned length) const
 Returns substring from specified position of defined length.
 
String Trimmed () const
 Returns string with leading and trailing spaces removed.
 
String ToUpper () const
 Returns string with all uppercase letters.
 
String ToLower () const
 Returns string with all lowercase letters.
 
ObjectList< StringSplit (char separator, bool keepEmptyStrings=false) const
 Returns strings split by specified chars. The function does not return empty strings by default.
 
void Join (const std::vector< String > &subStrings, const String &glue)
 Joins specified vector to existing string.
 
unsigned Find (const String &str, unsigned startPos=0, bool caseSensitive=true) const
 Returns index of the first occurrence in string. If not found, returns NPOS.
 
unsigned Find (char c, unsigned startPos=0, bool caseSensitive=true) const
 Returns index of the first occurrence in string. If not found, returns NPOS.
 
unsigned FindLast (const String &str, unsigned startPos=NPOS, bool caseSensitive=true) const
 Returns index of the last occurrence in string. If not found, returns NPOS.
 
unsigned FindLast (char c, unsigned startPos=NPOS, bool caseSensitive=true) const
 Returns index of the last occurrence in string. If not found, returns NPOS.
 
bool StartsWith (const String &str, bool caseSensitive=true) const
 True if string begins as specified string.
 
bool EndsWith (const String &str, bool caseSensitive=true) const
 True if string ends as specified string.
 
const char * c_str () const
 Returns pointer to const array.
 
unsigned Length () const
 Returns string length.
 
unsigned Capacity () const
 Returns buffer capacity.
 
bool IsEmpty () const
 True if string is empty.
 
int Compare (const String &str, bool caseSensitive=true) const
 True if strings are identical.
 
int Compare (const char *str, bool caseSensitive=true) const
 True if chars are identical.
 
bool Contains (const String &str, bool caseSensitive=true) const
 True if there is an occurrence of specified string.
 
bool Contains (char c, bool caseSensitive=true) const
 True if there is an occurrence of specified char.
 
void SetUTF8FromLatin1 (const char *str)
 Builds string content in UTF8 format with Latin1 standard.
 
void SetUTF8FromWChar (const wchar_t *str)
 Builds string content in UTF8 format from specified chars.
 
unsigned LengthUTF8 () const
 Counts chars in UTF8 content.
 
unsigned ByteOffsetUTF8 (unsigned index) const
 Returns byte offset in char in UTF8 content.
 
unsigned NextUTF8Char (unsigned &byteOffset) const
 Returns the next Unicode char from UTF8 content.
 
unsigned AtUTF8 (unsigned index) const
 Returns char by index from UTF8 content.
 
void ReplaceUTF8 (unsigned index, unsigned unicodeChar)
 Replaces char by index in UTF8 content.
 
StringAppendUTF8 (unsigned unicodeChar)
 Adds Unicode char to end of UTF8 content.
 
String SubstringUTF8 (unsigned pos) const
 Returns UTF8 substring from specified position to end of string.
 
String SubstringUTF8 (unsigned pos, unsigned length) const
 Returns UTF8 substring from specified position of defined length.
 
unsigned ToHash () const
 Returns hash value for HashSet and HashMap.
 
StringAppendWithFormat (const char *formatString,...)
 Appends string using formatting.
 
StringAppendWithFormatArgs (const char *formatString, va_list args)
 Appends string using formatting and variables.
 

Static Public Member Functions

static ObjectList< StringSplit (const char *str, char separator, bool keepEmptyStrings=false)
 Returns strings splitted by specified chars. The function does not return empty strings by default.
 
static String Joined (const std::vector< String > &subStrings, const String &glue)
 Joins all elements of an array into a string and returns the string.
 
static void EncodeUTF8 (char *&dest, unsigned unicodeChar)
 Encodes Unicode char to UTF8. Please note, that the pointer will be increased.
 
static unsigned DecodeUTF8 (const char *&src)
 Decodes Unicode char from UTF8. Please note, that the pointer will be increased.
 
static unsigned CStringLength (const char *str)
 Returns string length.
 
static int Compare (const char *str1, const char *str2, bool caseSensitive)
 Compares two strings.
 

Static Public Attributes

static const unsigned NPOS
 For position.
 
static const unsigned MIN_CAPACITY = 8
 Initial capacity.
 
static const String EMPTY
 Empty string.
 

Detailed Description

General String class based on Unicode standard.

The String class supports conversion to and from std::string, std::wstring, const char*, const wchar_t*. A separate CharArray class is used to support the ToAscii() method for conversion to a const char* string.


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