Drag[en]gine Game Engine  1.0
decUnicodeString Class Reference

Unicode string supporting encoding and decoding UTF8 formatted strings. More...

#include <decUnicodeString.h>

Public Member Functions

Accessors and Mutators
bool IsEmpty () const
 Determines if the string is empty. More...
 
void Empty ()
 Sets the string to the empty string. More...
 
int GetLength () const
 Retrieves the count of characters in the unicode string. More...
 
int GetAt (int position) const
 Retrieves the unicode character at the given location. More...
 
void SetAt (int position, int character)
 Sets the unicode character at the given location. More...
 
void Set (const decUnicodeString &string)
 Sets the string from another string. More...
 
void Set (int character, int count)
 Sets the string to a run of characters. More...
 
void SetValue (char value)
 Set string to a char value. More...
 
void SetValue (unsigned char value)
 Set string to an unsigned char value. More...
 
void SetValue (short value)
 Set string to a short value. More...
 
void SetValue (unsigned short value)
 Set string to an unsigned short value. More...
 
void SetValue (int value)
 Set string to a signed integer value. More...
 
void SetValue (unsigned int value)
 Set string to an unsigned integer value. More...
 
void SetValue (float value)
 Set string to a float value. More...
 
void SetValue (double value)
 Set string to a double value. More...
 
void SetFromUTF8 (const char *string)
 Set unicode string from the given utf8 encoded string. More...
 
void Format (const char *format,...)
 Formats a string using printf style formatting. More...
 
void FormatUsing (const char *format, va_list args)
 Formats a string using printf style formatting. More...
 
void Append (const decUnicodeString &string)
 Appends a string. More...
 
void AppendCharacter (char character)
 Appends a character. More...
 
void AppendCharacter (unsigned char character)
 
void AppendCharacter (int character)
 
void AppendValue (char value)
 Appends a char value. More...
 
void AppendValue (unsigned char value)
 Appends an unsigned char value. More...
 
void AppendValue (short value)
 Appends a short value. More...
 
void AppendValue (unsigned short value)
 Appends an unsigned short value. More...
 
void AppendValue (int value)
 Appends a signed integer value. More...
 
void AppendValue (unsigned int value)
 Appends an unsigned integer value. More...
 
void AppendValue (float value)
 Appends a float value. More...
 
void AppendValue (double value)
 Appends a double value. More...
 
void AppendFromUTF8 (const char *string)
 Append unicode string from the given utf8 encoded string. More...
 
void AppendFormat (const char *format,...)
 Appends a formatted string using printf style formatting. More...
 
void AppendFormatUsing (const char *format, va_list args)
 Appends a formatted string using printf style formatting. More...
 
int Find (int character) const
 Retrieve index of first occurance of a character or -1 if not found. Negative start or end is measured from the string end. More...
 
int Find (int character, int start) const
 
int Find (int character, int start, int end) const
 
int Find (const decUnicodeString &characters) const
 Retrieve index of first occurance of any charatcer in a list of characters or -1 if not found. Negative start or end is measured from the string end. More...
 
int Find (const decUnicodeString &characters, int start) const
 
int Find (const decUnicodeString &characters, int start, int end) const
 
int FindReverse (int character) const
 Retrieve index of last occurance of a character or -1 if not found. Negative start or end is measured from the string end. More...
 
int FindReverse (int character, int start) const
 
int FindReverse (int character, int start, int end) const
 
int FindReverse (const decUnicodeString &characters) const
 Retrieve index of last occurance of any character in a list of characters or -1 if not found. Negative start or end is measured from the string end. More...
 
int FindReverse (const decUnicodeString &characters, int start) const
 
int FindReverse (const decUnicodeString &characters, int start, int end) const
 
int FindString (const decUnicodeString &string) const
 Retrieve index of first occurance of a string or -1 if not found. Negative start or end is measured from the string end. More...
 
int FindString (const decUnicodeString &string, int start) const
 
int FindString (const decUnicodeString &string, int start, int end) const
 
int FindStringReverse (const decUnicodeString &string) const
 Retrieve index of first occurance of a character from the end to the start or -1 if not found. Negative start or end is measured from the string end. More...
 
int FindStringReverse (const decUnicodeString &string, int start) const
 
int FindStringReverse (const decUnicodeString &string, int start, int end) const
 
decUnicodeString GetLeft (int count) const
 Retrieves the first number of characters. More...
 
decUnicodeString GetRight (int count) const
 Retrieves the last number of characters. More...
 
decUnicodeString GetMiddle (int start) const
 Retrieves a sub string. Negative start or end is measured from the string end. More...
 
decUnicodeString GetMiddle (int start, int end) const
 
void Reverse ()
 Reverse string. More...
 
decUnicodeString GetReversed () const
 Retrieve reversed string. More...
 
decUnicodeStringList Split (int character) const
 Split string. More...
 
decUnicodeStringList Split (const decUnicodeString &characters) const
 Split string on multiple characters. More...
 
void Replace (int replaceCharacter, int withCharacter)
 Replace all occurances of a character. More...
 
void Replace (const decUnicodeString &replaceCharacters, int withCharacter)
 Replace all occurances of any character in a list of characters. More...
 
void ReplaceString (const decUnicodeString &replaceString, const decUnicodeString &withString)
 Replace all occurances of a string. More...
 
decUnicodeString GetReplaced (int replaceCharacter, int withCharacter) const
 Retrieves string with all occurances of a character replaced. More...
 
decUnicodeString GetReplaced (const decUnicodeString &replaceCharacters, int withCharacter) const
 Retrieves string with all occurances of any character of a list of characters replaced. More...
 
decUnicodeString GetReplacedString (const decUnicodeString &replaceString, const decUnicodeString &withString) const
 Retrieves string with all occurances of a string replaced. More...
 
void TrimLeft ()
 Removes whitespaces from the beginning. More...
 
decUnicodeString GetTrimmedLeft () const
 Retrieves a string with whitespaces removed from the beginning. More...
 
void TrimRight ()
 Removes whitespaces from the end. More...
 
decUnicodeString GetTrimmedRight () const
 Retrieves a string with whitespaces removed from the end. More...
 
void Trim ()
 Remove whitespaces from the beginning and end. More...
 
decUnicodeString GetTrimmed () const
 Retrieves a string with whitespaces removed from the beginning and end. More...
 
void ToLower ()
 Converts all characters to lower case. More...
 
decUnicodeString GetLower () const
 Retrieves string with all characters converted to lower case. More...
 
void ToUpper ()
 Converts all character to upper case. More...
 
decUnicodeString GetUpper () const
 Retrieves string with all characters converted to upper case. More...
 
int ToInt () const
 Retrieves integer value. More...
 
long long ToLong () const
 Retrieves the long int value. More...
 
float ToFloat () const
 Retrieves float value. More...
 
double ToDouble () const
 Retrieves double value. More...
 
decString ToUTF8 () const
 Retrieves the string representation of the unicode string with is an UTF8 encoded string. More...
 
bool Equals (const decUnicodeString &string) const
 Determines if the string equals another string case sensitive. More...
 
bool EqualsInsensitive (const decUnicodeString &string) const
 Determines if the string equals another string case insensitive. More...
 
int Compare (const decUnicodeString &string) const
 Compares the string to another string case sensitive returns -1(less), 0(equal) or 1(greater). More...
 
int CompareInsensitive (const decUnicodeString &string) const
 Compares the string to another string case insensitive returns -1(less), 0(equal) or 1(greater). More...
 
unsigned int Hash () const
 Calculate string hash. More...
 
Operators
int operator[] (int position) const
 Retrieves a character. More...
 
bool operator! () const
 Determines if the string is empty. More...
 
bool operator== (const decUnicodeString &string) const
 Determines if the string equals another string case sensitive. More...
 
bool operator!= (const decUnicodeString &string) const
 Determines if the string equals another string case sensitive. More...
 
bool operator< (const decUnicodeString &string) const
 Determines if the string is lexographically less than another string case sensitive. More...
 
bool operator<= (const decUnicodeString &string) const
 Determines if the string is lexographically less than or equal to another string case sensitive. More...
 
bool operator> (const decUnicodeString &string) const
 Determines if the string is lexographically greater than another string case sensitive. More...
 
bool operator>= (const decUnicodeString &string) const
 Determines if the string is lexographically greater than or equal to another string case sensitive. More...
 
decUnicodeString operator+ (const decUnicodeString &string) const
 Returns a new string being the concatenation of this string and another string. More...
 
decUnicodeStringoperator= (const decUnicodeString &string)
 Sets the string to another string. More...
 
decUnicodeStringoperator+= (const decUnicodeString &string)
 Appends a string to this string. More...
 

Constructors and Destructors

 decUnicodeString ()
 Creates a new empty unicode string. More...
 
 decUnicodeString (const decUnicodeString &string)
 Creates a new unicode string as a copy of the given unicode string. More...
 
 decUnicodeString (const decUnicodeString &string1, const decUnicodeString &string2)
 Creates a new unicode string as a copy of two concatenated unicode strings. More...
 
 decUnicodeString (int character)
 Creates a new unicode string from the given unicode character. More...
 
 ~decUnicodeString ()
 Frees the unicode string. More...
 
static decUnicodeString NewFromUTF8 (const char *string)
 Creates a new unicode string from the given utf8 encoded string. More...
 

Detailed Description

Unicode string supporting encoding and decoding UTF8 formatted strings.

Author
Pl├╝ss Roland
Version
1.0
Date
2014

Constructor & Destructor Documentation

◆ decUnicodeString() [1/4]

decUnicodeString::decUnicodeString ( )

Creates a new empty unicode string.

◆ decUnicodeString() [2/4]

decUnicodeString::decUnicodeString ( const decUnicodeString string)

Creates a new unicode string as a copy of the given unicode string.

◆ decUnicodeString() [3/4]

decUnicodeString::decUnicodeString ( const decUnicodeString string1,
const decUnicodeString string2 
)

Creates a new unicode string as a copy of two concatenated unicode strings.

◆ decUnicodeString() [4/4]

decUnicodeString::decUnicodeString ( int  character)

Creates a new unicode string from the given unicode character.

◆ ~decUnicodeString()

decUnicodeString::~decUnicodeString ( )

Frees the unicode string.

Member Function Documentation

◆ Append()

void decUnicodeString::Append ( const decUnicodeString string)

Appends a string.

Referenced by GetLength().

◆ AppendCharacter() [1/3]

void decUnicodeString::AppendCharacter ( char  character)

Appends a character.

Referenced by GetLength().

◆ AppendCharacter() [2/3]

void decUnicodeString::AppendCharacter ( unsigned char  character)

◆ AppendCharacter() [3/3]

void decUnicodeString::AppendCharacter ( int  character)

◆ AppendFormat()

void decUnicodeString::AppendFormat ( const char *  format,
  ... 
)

Appends a formatted string using printf style formatting.

Referenced by GetLength().

◆ AppendFormatUsing()

void decUnicodeString::AppendFormatUsing ( const char *  format,
va_list  args 
)

Appends a formatted string using printf style formatting.

Referenced by GetLength().

◆ AppendFromUTF8()

void decUnicodeString::AppendFromUTF8 ( const char *  string)

Append unicode string from the given utf8 encoded string.

Referenced by GetLength().

◆ AppendValue() [1/8]

void decUnicodeString::AppendValue ( char  value)

Appends a char value.

Referenced by GetLength().

◆ AppendValue() [2/8]

void decUnicodeString::AppendValue ( unsigned char  value)

Appends an unsigned char value.

◆ AppendValue() [3/8]

void decUnicodeString::AppendValue ( short  value)

Appends a short value.

◆ AppendValue() [4/8]

void decUnicodeString::AppendValue ( unsigned short  value)

Appends an unsigned short value.

◆ AppendValue() [5/8]

void decUnicodeString::AppendValue ( int  value)

Appends a signed integer value.

◆ AppendValue() [6/8]

void decUnicodeString::AppendValue ( unsigned int  value)

Appends an unsigned integer value.

◆ AppendValue() [7/8]

void decUnicodeString::AppendValue ( float  value)

Appends a float value.

◆ AppendValue() [8/8]

void decUnicodeString::AppendValue ( double  value)

Appends a double value.

◆ Compare()

int decUnicodeString::Compare ( const decUnicodeString string) const

Compares the string to another string case sensitive returns -1(less), 0(equal) or 1(greater).

Referenced by GetLength().

◆ CompareInsensitive()

int decUnicodeString::CompareInsensitive ( const decUnicodeString string) const

Compares the string to another string case insensitive returns -1(less), 0(equal) or 1(greater).

Referenced by GetLength().

◆ Empty()

void decUnicodeString::Empty ( )

Sets the string to the empty string.

◆ Equals()

bool decUnicodeString::Equals ( const decUnicodeString string) const

Determines if the string equals another string case sensitive.

Referenced by GetLength().

◆ EqualsInsensitive()

bool decUnicodeString::EqualsInsensitive ( const decUnicodeString string) const

Determines if the string equals another string case insensitive.

Referenced by GetLength().

◆ Find() [1/6]

int decUnicodeString::Find ( int  character) const

Retrieve index of first occurance of a character or -1 if not found. Negative start or end is measured from the string end.

Referenced by GetLength().

◆ Find() [2/6]

int decUnicodeString::Find ( int  character,
int  start 
) const

◆ Find() [3/6]

int decUnicodeString::Find ( int  character,
int  start,
int  end 
) const

◆ Find() [4/6]

int decUnicodeString::Find ( const decUnicodeString characters) const

Retrieve index of first occurance of any charatcer in a list of characters or -1 if not found. Negative start or end is measured from the string end.

◆ Find() [5/6]

int decUnicodeString::Find ( const decUnicodeString characters,
int  start 
) const

◆ Find() [6/6]

int decUnicodeString::Find ( const decUnicodeString characters,
int  start,
int  end 
) const

◆ FindReverse() [1/6]

int decUnicodeString::FindReverse ( int  character) const

Retrieve index of last occurance of a character or -1 if not found. Negative start or end is measured from the string end.

Referenced by GetLength().

◆ FindReverse() [2/6]

int decUnicodeString::FindReverse ( int  character,
int  start 
) const

◆ FindReverse() [3/6]

int decUnicodeString::FindReverse ( int  character,
int  start,
int  end 
) const

◆ FindReverse() [4/6]

int decUnicodeString::FindReverse ( const decUnicodeString characters) const

Retrieve index of last occurance of any character in a list of characters or -1 if not found. Negative start or end is measured from the string end.

◆ FindReverse() [5/6]

int decUnicodeString::FindReverse ( const decUnicodeString characters,
int  start 
) const

◆ FindReverse() [6/6]

int decUnicodeString::FindReverse ( const decUnicodeString characters,
int  start,
int  end 
) const

◆ FindString() [1/3]

int decUnicodeString::FindString ( const decUnicodeString string) const

Retrieve index of first occurance of a string or -1 if not found. Negative start or end is measured from the string end.

Referenced by GetLength().

◆ FindString() [2/3]

int decUnicodeString::FindString ( const decUnicodeString string,
int  start 
) const

◆ FindString() [3/3]

int decUnicodeString::FindString ( const decUnicodeString string,
int  start,
int  end 
) const

◆ FindStringReverse() [1/3]

int decUnicodeString::FindStringReverse ( const decUnicodeString string) const

Retrieve index of first occurance of a character from the end to the start or -1 if not found. Negative start or end is measured from the string end.

Referenced by GetLength().

◆ FindStringReverse() [2/3]

int decUnicodeString::FindStringReverse ( const decUnicodeString string,
int  start 
) const

◆ FindStringReverse() [3/3]

int decUnicodeString::FindStringReverse ( const decUnicodeString string,
int  start,
int  end 
) const

◆ Format()

void decUnicodeString::Format ( const char *  format,
  ... 
)

Formats a string using printf style formatting.

Referenced by GetLength().

◆ FormatUsing()

void decUnicodeString::FormatUsing ( const char *  format,
va_list  args 
)

Formats a string using printf style formatting.

Referenced by GetLength().

◆ GetAt()

int decUnicodeString::GetAt ( int  position) const

Retrieves the unicode character at the given location.

Referenced by GetLength().

◆ GetLeft()

decUnicodeString decUnicodeString::GetLeft ( int  count) const

Retrieves the first number of characters.

Referenced by GetLength().

◆ GetLength()

◆ GetLower()

decUnicodeString decUnicodeString::GetLower ( ) const

Retrieves string with all characters converted to lower case.

Referenced by GetLength().

◆ GetMiddle() [1/2]

decUnicodeString decUnicodeString::GetMiddle ( int  start) const

Retrieves a sub string. Negative start or end is measured from the string end.

Referenced by GetLength().

◆ GetMiddle() [2/2]

decUnicodeString decUnicodeString::GetMiddle ( int  start,
int  end 
) const

◆ GetReplaced() [1/2]

decUnicodeString decUnicodeString::GetReplaced ( int  replaceCharacter,
int  withCharacter 
) const

Retrieves string with all occurances of a character replaced.

Referenced by GetLength().

◆ GetReplaced() [2/2]

decUnicodeString decUnicodeString::GetReplaced ( const decUnicodeString replaceCharacters,
int  withCharacter 
) const

Retrieves string with all occurances of any character of a list of characters replaced.

◆ GetReplacedString()

decUnicodeString decUnicodeString::GetReplacedString ( const decUnicodeString replaceString,
const decUnicodeString withString 
) const

Retrieves string with all occurances of a string replaced.

Referenced by GetLength().

◆ GetReversed()

decUnicodeString decUnicodeString::GetReversed ( ) const

Retrieve reversed string.

Referenced by GetLength().

◆ GetRight()

decUnicodeString decUnicodeString::GetRight ( int  count) const

Retrieves the last number of characters.

Referenced by GetLength().

◆ GetTrimmed()

decUnicodeString decUnicodeString::GetTrimmed ( ) const

Retrieves a string with whitespaces removed from the beginning and end.

Referenced by GetLength().

◆ GetTrimmedLeft()

decUnicodeString decUnicodeString::GetTrimmedLeft ( ) const

Retrieves a string with whitespaces removed from the beginning.

Referenced by GetLength().

◆ GetTrimmedRight()

decUnicodeString decUnicodeString::GetTrimmedRight ( ) const

Retrieves a string with whitespaces removed from the end.

Referenced by GetLength().

◆ GetUpper()

decUnicodeString decUnicodeString::GetUpper ( ) const

Retrieves string with all characters converted to upper case.

Referenced by GetLength().

◆ Hash()

unsigned int decUnicodeString::Hash ( ) const

Calculate string hash.

Referenced by GetLength().

◆ IsEmpty()

bool decUnicodeString::IsEmpty ( ) const

Determines if the string is empty.

◆ NewFromUTF8()

static decUnicodeString decUnicodeString::NewFromUTF8 ( const char *  string)
static

Creates a new unicode string from the given utf8 encoded string.

◆ operator!()

bool decUnicodeString::operator! ( ) const

Determines if the string is empty.

Referenced by GetLength().

◆ operator!=()

bool decUnicodeString::operator!= ( const decUnicodeString string) const

Determines if the string equals another string case sensitive.

Referenced by GetLength().

◆ operator+()

decUnicodeString decUnicodeString::operator+ ( const decUnicodeString string) const

Returns a new string being the concatenation of this string and another string.

Referenced by GetLength().

◆ operator+=()

decUnicodeString& decUnicodeString::operator+= ( const decUnicodeString string)

Appends a string to this string.

Referenced by GetLength().

◆ operator<()

bool decUnicodeString::operator< ( const decUnicodeString string) const

Determines if the string is lexographically less than another string case sensitive.

Referenced by GetLength().

◆ operator<=()

bool decUnicodeString::operator<= ( const decUnicodeString string) const

Determines if the string is lexographically less than or equal to another string case sensitive.

Referenced by GetLength().

◆ operator=()

decUnicodeString& decUnicodeString::operator= ( const decUnicodeString string)

Sets the string to another string.

Referenced by GetLength().

◆ operator==()

bool decUnicodeString::operator== ( const decUnicodeString string) const

Determines if the string equals another string case sensitive.

Referenced by GetLength().

◆ operator>()

bool decUnicodeString::operator> ( const decUnicodeString string) const

Determines if the string is lexographically greater than another string case sensitive.

Referenced by GetLength().

◆ operator>=()

bool decUnicodeString::operator>= ( const decUnicodeString string) const

Determines if the string is lexographically greater than or equal to another string case sensitive.

Referenced by GetLength().

◆ operator[]()

int decUnicodeString::operator[] ( int  position) const

Retrieves a character.

Referenced by GetLength().

◆ Replace() [1/2]

void decUnicodeString::Replace ( int  replaceCharacter,
int  withCharacter 
)

Replace all occurances of a character.

Referenced by GetLength().

◆ Replace() [2/2]

void decUnicodeString::Replace ( const decUnicodeString replaceCharacters,
int  withCharacter 
)

Replace all occurances of any character in a list of characters.

◆ ReplaceString()

void decUnicodeString::ReplaceString ( const decUnicodeString replaceString,
const decUnicodeString withString 
)

Replace all occurances of a string.

Referenced by GetLength().

◆ Reverse()

void decUnicodeString::Reverse ( )

Reverse string.

Referenced by GetLength().

◆ Set() [1/2]

void decUnicodeString::Set ( const decUnicodeString string)

Sets the string from another string.

Referenced by GetLength().

◆ Set() [2/2]

void decUnicodeString::Set ( int  character,
int  count 
)

Sets the string to a run of characters.

◆ SetAt()

void decUnicodeString::SetAt ( int  position,
int  character 
)

Sets the unicode character at the given location.

Referenced by GetLength().

◆ SetFromUTF8()

void decUnicodeString::SetFromUTF8 ( const char *  string)

Set unicode string from the given utf8 encoded string.

Referenced by GetLength().

◆ SetValue() [1/8]

void decUnicodeString::SetValue ( char  value)

Set string to a char value.

Referenced by GetLength().

◆ SetValue() [2/8]

void decUnicodeString::SetValue ( unsigned char  value)

Set string to an unsigned char value.

◆ SetValue() [3/8]

void decUnicodeString::SetValue ( short  value)

Set string to a short value.

◆ SetValue() [4/8]

void decUnicodeString::SetValue ( unsigned short  value)

Set string to an unsigned short value.

◆ SetValue() [5/8]

void decUnicodeString::SetValue ( int  value)

Set string to a signed integer value.

◆ SetValue() [6/8]

void decUnicodeString::SetValue ( unsigned int  value)

Set string to an unsigned integer value.

◆ SetValue() [7/8]

void decUnicodeString::SetValue ( float  value)

Set string to a float value.

◆ SetValue() [8/8]

void decUnicodeString::SetValue ( double  value)

Set string to a double value.

◆ Split() [1/2]

decUnicodeStringList decUnicodeString::Split ( int  character) const

Split string.

Referenced by GetLength().

◆ Split() [2/2]

decUnicodeStringList decUnicodeString::Split ( const decUnicodeString characters) const

Split string on multiple characters.

◆ ToDouble()

double decUnicodeString::ToDouble ( ) const

Retrieves double value.

Referenced by GetLength().

◆ ToFloat()

float decUnicodeString::ToFloat ( ) const

Retrieves float value.

Referenced by GetLength().

◆ ToInt()

int decUnicodeString::ToInt ( ) const

Retrieves integer value.

Referenced by GetLength().

◆ ToLong()

long long decUnicodeString::ToLong ( ) const

Retrieves the long int value.

Referenced by GetLength().

◆ ToLower()

void decUnicodeString::ToLower ( )

Converts all characters to lower case.

Referenced by GetLength().

◆ ToUpper()

void decUnicodeString::ToUpper ( )

Converts all character to upper case.

Referenced by GetLength().

◆ ToUTF8()

decString decUnicodeString::ToUTF8 ( ) const

Retrieves the string representation of the unicode string with is an UTF8 encoded string.

This function works in two modes. If storage is NULL length is ignored and the required size for the string is returned. If storage is not NULL then the converted string is written into storage up to length bytes and the number of bytes written is returned. Remaining bytes will not be written. Should this happen the function makes sure only full characters are written so the converted string is valid.

Referenced by GetLength().

◆ Trim()

void decUnicodeString::Trim ( )

Remove whitespaces from the beginning and end.

Referenced by GetLength().

◆ TrimLeft()

void decUnicodeString::TrimLeft ( )

Removes whitespaces from the beginning.

Referenced by GetLength().

◆ TrimRight()

void decUnicodeString::TrimRight ( )

Removes whitespaces from the end.

Referenced by GetLength().


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