SCENE C++ API  2.1.0
List of all members
LSString Class Reference

String implementation for unicode character strings. More...

#include <lsstring.h>

+ Inheritance diagram for LSString:

Public Member Functions

Construction, Destruction & Assignment
 LSString ()
 Constructs an empty string. More...
 
 LSString (const LSString &str)
 Constructs a string containing a copy of the string str. More...
 
 LSString (const wchar_t *str)
 Constructs a string containing a copy of the string str. More...
 
 LSString (const wchar_t &c)
 Constructs a string containing a copy of the character c. More...
 
 ~LSString ()
 Destroys the string. More...
 
LSStringoperator= (const LSString &str)
 Assigns a copy of the string str to this string. More...
 
LSStringoperator= (const wchar_t *str)
 Assigns a copy of the string str to this string. More...
 
Conversion to other string types
const char * toCharStr () const
 Returns a string representation of the current string encoded in the current system locale. More...
 
const char * toUtf8Str () const
 Returns a string representation of the current string encoded in UTF8. More...
 
const wchar_t * toWcharStr () const
 Returns a wide character string representation of the current string. More...
 
String operations
bool empty () const
 Tests whether the string is empty (whether its length is 0). More...
 
int length () const
 Returns the length of the string, counted in the number of characters. More...
 
int find (const LSString &str, int pos=0) const
 Searches the string for the first occurrence of the string str starting at the position pos. More...
 
int find (const wchar_t *str, int pos=0) const
 Searches the string for the first occurrence of the string str starting at the position pos. More...
 
int find (const wchar_t &c, int pos=0) const
 Searches the string for the first occurrence of the character c starting at the position pos. More...
 
int rfind (const LSString &str, int pos=-1) const
 Searches the string for the last occurrence of the string str which is completely located before the position pos. More...
 
int rfind (const wchar_t *str, int pos=-1) const
 Searches the string for the last occurrence of the string str which is completely located before the position pos. More...
 
int rfind (const wchar_t &c, int pos=-1) const
 Searches the string for the last occurrence of the character c which is located before the position pos. More...
 
LSString substr (int pos=0, int len=-1) const
 Returns a new string which contains a substring of this string starting at position pos and spanning len characters. More...
 
int compare (const LSString &str) const
 Lexicographically compares the contents of this string to the contents of the string str. More...
 
int compare (const wchar_t *str) const
 Lexicographically compares the contents of this string to the contents of the string str. More...
 
LSStringreplace (const LSString &before, const LSString &after)
 Replaces all occurrences of the string before with the string after. More...
 
LSStringreplace (const LSString &before, const wchar_t *after)
 Replaces all occurrences of the string before with the string after. More...
 
LSStringreplace (const wchar_t *before, const LSString &after)
 Replaces all occurrences of the string before with the string after. More...
 
LSStringreplace (const wchar_t *before, const wchar_t *after)
 Replaces all occurrences of the string before with the string after. More...
 
LSStringreplace (const wchar_t &before, const wchar_t &after)
 Replaces all occurrences of the character before with the character after. More...
 
LSStringappend (const LSString &str)
 Appends the string str to this string. More...
 
LSStringappend (const wchar_t *str)
 Appends the string str to this string. More...
 
LSStringappend (const wchar_t &c)
 Appends the character c to this string. More...
 
LSStringoperator+= (const LSString &str)
 Appends the string str to this string. More...
 
LSStringoperator+= (const wchar_t *str)
 Appends the string str to this string. More...
 
LSStringoperator+= (const wchar_t &c)
 Appends the character c to this string. More...
 
Element access
wchar_t & operator[] (int pos)
 Returns a reference to the character at position pos in the string. More...
 
wchar_t operator[] (int pos) const
 Returns a reference to the character at position pos in the string. More...
 
wchar_t & at (int pos)
 Returns a reference to the character at position pos in the string. More...
 
wchar_t at (int pos) const
 Returns a reference to the character at position pos in the string. More...
 
New / Delete operators
void * operator new (size_t tSize)
 Default allocation function. More...
 
void operator delete (void *p)
 Default deallocation function. More...
 

Static Public Member Functions

Conversion from other string types
static LSString fromCharStr (const char *charStr)
 Creates a copy of the string charStr. More...
 
static LSString fromUtf8Str (const char *utf8Str)
 Creates a copy of the string utf8Str. More...
 
static LSString fromWcharStr (const wchar_t *wcharStr)
 Creates a copy of the string wcharStr. More...
 

Related Functions

(Note that these are not member functions.)

String concatenation
LSString operator+ (const LSString &str1, const LSString &str2)
 
LSString operator+ (const LSString &str1, const wchar_t *str2)
 
LSString operator+ (const wchar_t *str1, const LSString &str2)
 
LSString operator+ (const LSString &str, const wchar_t &c)
 
LSString operator+ (const wchar_t &c, const LSString &str)
 
bool operator== (const LSString &str1, const LSString &str2)
 
Relational operators
bool operator== (const LSString &str1, const wchar_t *str2)
 
bool operator== (const wchar_t *str1, const LSString &str2)
 
bool operator!= (const LSString &str1, const LSString &str2)
 
bool operator!= (const LSString &str1, const wchar_t *str2)
 
bool operator!= (const wchar_t *str1, const LSString &str2)
 
bool operator< (const LSString &str1, const LSString &str2)
 
bool operator< (const LSString &str1, const wchar_t *str2)
 
bool operator< (const wchar_t *str1, const LSString &str2)
 
bool operator<= (const LSString &str1, const LSString &str2)
 
bool operator<= (const LSString &str1, const wchar_t *str2)
 
bool operator<= (const wchar_t *str1, const LSString &str2)
 
bool operator> (const LSString &str1, const LSString &str2)
 
bool operator> (const LSString &str1, const wchar_t *str2)
 
bool operator> (const wchar_t *str1, const LSString &str2)
 
bool operator>= (const LSString &str1, const LSString &str2)
 
bool operator>= (const LSString &str1, const wchar_t *str2)
 
bool operator>= (const wchar_t *str1, const LSString &str2)
 

Detailed Description

String implementation for unicode character strings.

Version
SCENE API Version 2.0.0.

Constructor & Destructor Documentation

◆ LSString() [1/4]

LSString ( )

Constructs an empty string.

Version
SCENE API Version 2.0.0.

◆ LSString() [2/4]

LSString ( const LSString str)

Constructs a string containing a copy of the string str.

Version
SCENE API Version 2.0.0.

◆ LSString() [3/4]

LSString ( const wchar_t *  str)

Constructs a string containing a copy of the string str.

Version
SCENE API Version 2.0.0.

◆ LSString() [4/4]

LSString ( const wchar_t &  c)

Constructs a string containing a copy of the character c.

Version
SCENE API Version 2.0.0.

◆ ~LSString()

~LSString ( )

Destroys the string.

Version
SCENE API Version 2.0.0.

Member Function Documentation

◆ operator=() [1/2]

LSString& operator= ( const LSString str)

Assigns a copy of the string str to this string.

Version
SCENE API Version 2.0.0.

◆ operator=() [2/2]

LSString& operator= ( const wchar_t *  str)

Assigns a copy of the string str to this string.

Version
SCENE API Version 2.0.0.

◆ fromCharStr()

static LSString fromCharStr ( const char *  charStr)
static

Creates a copy of the string charStr.

The string charStr is assumed to be encoded in the current system locale.

Returns
A copy of the string charStr.
Version
SCENE API Version 2.0.0.

◆ fromUtf8Str()

static LSString fromUtf8Str ( const char *  utf8Str)
static

Creates a copy of the string utf8Str.

The string utf8Str is assumed to be encoded in UTF8.

Returns
A copy of the string utf8Str.
Version
SCENE API Version 2.0.0.

◆ fromWcharStr()

static LSString fromWcharStr ( const wchar_t *  wcharStr)
static

Creates a copy of the string wcharStr.

Returns
A copy of the string wcharStr.
Version
SCENE API Version 2.0.0.

◆ toCharStr()

const char* toCharStr ( ) const

Returns a string representation of the current string encoded in the current system locale.

Returns
A string representation of the current string encoded in the current system locale.
Version
SCENE API Version 2.0.0.

◆ toUtf8Str()

const char* toUtf8Str ( ) const

Returns a string representation of the current string encoded in UTF8.

Returns
A string representation of the current string encoded in UTF8.
Version
SCENE API Version 2.0.0.

◆ toWcharStr()

const wchar_t* toWcharStr ( ) const

Returns a wide character string representation of the current string.

Returns
A wide character string representation of the current string.
Version
SCENE API Version 2.0.0.

◆ empty()

bool empty ( ) const

Tests whether the string is empty (whether its length is 0).

Returns
true if the length of the string is 0, false otherwise.
Version
SCENE API Version 2.0.0.

◆ length()

int length ( ) const

Returns the length of the string, counted in the number of characters.

Returns
The number of characters in the string.
Version
SCENE API Version 2.0.0.

◆ find() [1/3]

int find ( const LSString str,
int  pos = 0 
) const

Searches the string for the first occurrence of the string str starting at the position pos.

Returns
The position of the first character of the first match. If no match is found -1 is returned.
Version
SCENE API Version 2.0.0.

◆ find() [2/3]

int find ( const wchar_t *  str,
int  pos = 0 
) const

Searches the string for the first occurrence of the string str starting at the position pos.

Returns
The position of the first character of the first match. If no match is found -1 is returned.
Version
SCENE API Version 2.0.0.

◆ find() [3/3]

int find ( const wchar_t &  c,
int  pos = 0 
) const

Searches the string for the first occurrence of the character c starting at the position pos.

Returns
The position of the first match. If no match is found -1 is returned.
Version
SCENE API Version 2.0.0.

◆ rfind() [1/3]

int rfind ( const LSString str,
int  pos = -1 
) const

Searches the string for the last occurrence of the string str which is completely located before the position pos.

Returns
The position of the first character of the last match. If no match is found -1 is returned.
Version
SCENE API Version 2.0.0.

◆ rfind() [2/3]

int rfind ( const wchar_t *  str,
int  pos = -1 
) const

Searches the string for the last occurrence of the string str which is completely located before the position pos.

Returns
The position of the first character of the last match. If no match is found -1 is returned.
Version
SCENE API Version 2.0.0.

◆ rfind() [3/3]

int rfind ( const wchar_t &  c,
int  pos = -1 
) const

Searches the string for the last occurrence of the character c which is located before the position pos.

Returns
The position of the last match. If no match is found -1 is returned.
Version
SCENE API Version 2.0.0.

◆ substr()

LSString substr ( int  pos = 0,
int  len = -1 
) const

Returns a new string which contains a substring of this string starting at position pos and spanning len characters.

Returns
A string containing a substring of this object.
Version
SCENE API Version 2.0.0.

◆ compare() [1/2]

int compare ( const LSString str) const

Lexicographically compares the contents of this string to the contents of the string str.

Returns
Returns 0 if the strings are equal, <0 if either the first character that doesn't match is lower in str or all characters match but str is shorter and >0 if either the first character that doesn't match is greater in str or all characters match but str is longer.
Version
SCENE API Version 2.0.0.

◆ compare() [2/2]

int compare ( const wchar_t *  str) const

Lexicographically compares the contents of this string to the contents of the string str.

Returns
Returns 0 if the strings are equal, <0 if either the first character that doesn't match is lower in str or all characters match but str is shorter and >0 if either the first character that doesn't match is greater in str or all characters match but str is longer.
Version
SCENE API Version 2.0.0.

◆ replace() [1/5]

LSString& replace ( const LSString before,
const LSString after 
)

Replaces all occurrences of the string before with the string after.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ replace() [2/5]

LSString& replace ( const LSString before,
const wchar_t *  after 
)

Replaces all occurrences of the string before with the string after.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ replace() [3/5]

LSString& replace ( const wchar_t *  before,
const LSString after 
)

Replaces all occurrences of the string before with the string after.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ replace() [4/5]

LSString& replace ( const wchar_t *  before,
const wchar_t *  after 
)

Replaces all occurrences of the string before with the string after.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ replace() [5/5]

LSString& replace ( const wchar_t &  before,
const wchar_t &  after 
)

Replaces all occurrences of the character before with the character after.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ append() [1/3]

LSString& append ( const LSString str)

Appends the string str to this string.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ append() [2/3]

LSString& append ( const wchar_t *  str)

Appends the string str to this string.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ append() [3/3]

LSString& append ( const wchar_t &  c)

Appends the character c to this string.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ operator+=() [1/3]

LSString& operator+= ( const LSString str)

Appends the string str to this string.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ operator+=() [2/3]

LSString& operator+= ( const wchar_t *  str)

Appends the string str to this string.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ operator+=() [3/3]

LSString& operator+= ( const wchar_t &  c)

Appends the character c to this string.

Returns
*this.
Version
SCENE API Version 2.0.0.

◆ operator[]() [1/2]

wchar_t& operator[] ( int  pos)

Returns a reference to the character at position pos in the string.

Returns
The character at the specified position in the string.
Version
SCENE API Version 2.0.0.

◆ operator[]() [2/2]

wchar_t operator[] ( int  pos) const

Returns a reference to the character at position pos in the string.

Returns
The character at the specified position in the string.
Version
SCENE API Version 2.0.0.

◆ at() [1/2]

wchar_t& at ( int  pos)

Returns a reference to the character at position pos in the string.

Returns
The character at the specified position in the string.
Version
SCENE API Version 2.0.0.

◆ at() [2/2]

wchar_t at ( int  pos) const

Returns a reference to the character at position pos in the string.

Returns
The character at the specified position in the string.
Version
SCENE API Version 2.0.0.

◆ operator new()

void* operator new ( size_t  tSize)

Default allocation function.

Overloaded in order to always allocate LSString objects in the context of this module.

Version
SCENE API Version 2.0.0.

◆ operator delete()

void operator delete ( void *  p)

Default deallocation function.

Overloaded in order to always deallocate LSString objects in the context of this module.

Version
SCENE API Version 2.0.0.

Friends And Related Function Documentation

◆ operator+() [1/5]

LSString operator+ ( const LSString str1,
const LSString str2 
)
related

Returns a new string containing the concatenation of the contents of the string str1 followed by the contents of the string str2.

Returns
A string whose value is the concatenation of str1 and str2.
Version
SCENE API Version 2.0.0.

◆ operator+() [2/5]

LSString operator+ ( const LSString str1,
const wchar_t *  str2 
)
related

Returns a new string containing the concatenation of the contents of the string str1 followed by the contents of the string str2.

Returns
A string whose value is the concatenation of str1 and str2.
Version
SCENE API Version 2.0.0.

◆ operator+() [3/5]

LSString operator+ ( const wchar_t *  str1,
const LSString str2 
)
related

Returns a new string containing the concatenation of the contents of the string str1 followed by the contents of the string str2.

Returns
A string whose value is the concatenation of str1 and str2.
Version
SCENE API Version 2.0.0.

◆ operator+() [4/5]

LSString operator+ ( const LSString str,
const wchar_t &  c 
)
related

Returns a new string containing the concatenation of the contents of the string str followed by the character c.

Returns
A string whose value is the concatenation of str and c.
Version
SCENE API Version 2.0.0.

◆ operator+() [5/5]

LSString operator+ ( const wchar_t &  c,
const LSString str 
)
related

Returns a new string containing the concatenation of the character c followed by the contents of the string str.

Returns
A string whose value is the concatenation of c and str.
Version
SCENE API Version 2.0.0.

◆ operator==() [1/3]

bool operator== ( const LSString str1,
const LSString str2 
)
related

Tests whether the string str1 and the string str2 are equal.

Returns
true if str1 and str2 are equal, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator==() [2/3]

bool operator== ( const LSString str1,
const wchar_t *  str2 
)
related

Tests whether the string str1 and the string str2 are equal.

Returns
true if str1 and str2 are equal, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator==() [3/3]

bool operator== ( const wchar_t *  str1,
const LSString str2 
)
related

Tests whether the string str1 and the string str2 are equal.

Returns
true if str1 and str2 are equal, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator!=() [1/3]

bool operator!= ( const LSString str1,
const LSString str2 
)
related

Tests whether the string str1 and the string str2 are unequal.

Returns
true if str1 and str2 are unequal, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator!=() [2/3]

bool operator!= ( const LSString str1,
const wchar_t *  str2 
)
related

Tests whether the string str1 and the string str2 are unequal.

Returns
true if str1 and str2 are unequal, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator!=() [3/3]

bool operator!= ( const wchar_t *  str1,
const LSString str2 
)
related

Tests whether the string str1 and the string str2 are unequal.

Returns
true if str1 and str2 are unequal, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator<() [1/3]

bool operator< ( const LSString str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically smaller than the string str2.

Returns
true if str1 is smaller than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator<() [2/3]

bool operator< ( const LSString str1,
const wchar_t *  str2 
)
related

Tests whether the string str1 is lexicographically smaller than the string str2.

Returns
true if str1 is smaller than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator<() [3/3]

bool operator< ( const wchar_t *  str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically smaller than the string str2.

Returns
true if str1 is smaller than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator<=() [1/3]

bool operator<= ( const LSString str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically smaller or equal than the string str2.

Returns
true if str1 is smaller or equal than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator<=() [2/3]

bool operator<= ( const LSString str1,
const wchar_t *  str2 
)
related

Tests whether the string str1 is lexicographically smaller or equal than the string str2.

Returns
true if str1 is smaller or equal than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator<=() [3/3]

bool operator<= ( const wchar_t *  str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically smaller or equal than the string str2.

Returns
true if str1 is smaller or equal than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator>() [1/3]

bool operator> ( const LSString str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically greater than the string str2.

Returns
true if str1 is greater than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator>() [2/3]

bool operator> ( const LSString str1,
const wchar_t *  str2 
)
related

Tests whether the string str1 is lexicographically greater than the string str2.

Returns
true if str1 is greater than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator>() [3/3]

bool operator> ( const wchar_t *  str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically greater than the string str2.

Returns
true if str1 is greater than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator>=() [1/3]

bool operator>= ( const LSString str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically greater or equal than the string str2.

Returns
true if str1 is greater or equal than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator>=() [2/3]

bool operator>= ( const LSString str1,
const wchar_t *  str2 
)
related

Tests whether the string str1 is lexicographically greater or equal than the string str2.

Returns
true if str1 is greater or equal than str2, false otherwise.
Version
SCENE API Version 2.0.0.

◆ operator>=() [3/3]

bool operator>= ( const wchar_t *  str1,
const LSString str2 
)
related

Tests whether the string str1 is lexicographically greater or equal than the string str2.

Returns
true if str1 is greater or equal than str2, false otherwise.
Version
SCENE API Version 2.0.0.