Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

irr::core::string< T, TAlloc > Class Template Reference

Very simple string class with some useful features. More...

#include <irrString.h>

List of all members.

Public Member Functions

void append (const string< T > &other, u32 length)
 Appends a string of the length l to this string.
void append (const string< T > &other)
 Appends a string to this string.
void append (const T *const other)
 Appends a char string to this string.
void append (T character)
 Appends a character to this string.
const T * c_str () const
 Returns character string.
bool equals_ignore_case (const string< T > &other) const
 Compares the strings ignoring case.
bool equalsn (const T *const str, u32 n) const
 compares the first n characters of the strings
bool equalsn (const string< T > &other, u32 n) const
 compares the first n characters of the strings
void erase (u32 index)
 Erases a character from the string.
template<class B>
s32 find (const B *const str) const
 finds another string in this string
s32 findFirst (T c) const
 finds first occurrence of character in string
s32 findFirstChar (const T *const c, u32 count) const
 finds first occurrence of a character of a list in string
template<class B>
s32 findFirstCharNotInList (const B *const c, u32 count) const
 Finds first position of a character not in a given list.
s32 findLast (T c, s32 start=-1) const
 finds last occurrence of character in string
s32 findLastChar (const T *const c, u32 count) const
 finds last occurrence of a character of a list in string
template<class B>
s32 findLastCharNotInList (const B *const c, u32 count) const
 Finds last position of a character not in a given list.
s32 findNext (T c, u32 startPos) const
 finds next occurrence of character in string
bool lower_ignore_case (const string< T > &other) const
 Compares the strings ignoring case.
void make_lower ()
 Makes the string lower case.
void make_upper ()
 Makes the string upper case.
bool operator!= (const string< T > &other) const
 Inequality operator.
bool operator!= (const T *const str) const
 Inequality operator.
template<class B>
string< T > operator+ (const B *const c) const
 Append operator for strings, ascii and unicode.
string< T > operator+ (const string< T > &other) const
 Append operator for other strings.
string< T > & operator+= (const float i)
string< T > & operator+= (const double i)
string< T > & operator+= (const unsigned long &i)
string< T > & operator+= (const long i)
string< T > & operator+= (const unsigned int i)
string< T > & operator+= (const int i)
string< T > & operator+= (const string< T > &other)
 Appends a string to this string.
string< T > & operator+= (const T *const c)
 Appends a char string to this string.
string< T > & operator+= (T c)
 Appends a character to this string.
bool operator< (const string< T > &other) const
 Is smaller comparator.
template<class B>
string< T > & operator= (const B *const c)
 Assignment operator for strings, ascii and unicode.
template<class B>
string< T > & operator= (const string< B > &other)
 Assignment operator for other string types.
string< T > & operator= (const string< T > &other)
 Assignment operator.
bool operator== (const string< T > &other) const
 Equality operator.
bool operator== (const T *const str) const
 Equality operator.
const T & operator[] (const u32 index) const
 Direct access operator.
T & operator[] (const u32 index)
 Direct access operator.
void replace (T toReplace, T replaceWith)
 replaces all characters of a special type with another one
void reserve (u32 count)
 Reserves some memory.
u32 size () const
 Returns length of string.
template<class B>
 string (const B *const c)
 Constructor for unicode and ascii strings.
template<class B>
 string (const B *const c, u32 length)
 Constructor for copying a string from a pointer with a given length.
 string (unsigned int number)
 Constructs a string from an unsigned int.
 string (int number)
 Constructs a string from an int.
 string (const double number)
 Constructs a string from a float.
template<class B>
 string (const string< B > &other)
 Constructor from other string types.
 string (const string< T > &other)
 Constructor.
 string ()
 Default constructor.
string< T > subString (u32 begin, s32 length) const
 Returns a substring.
string< T > & trim (const string< T > &whitespace=" \t\n\r")
 trims the string.
 ~string ()
 destructor


Detailed Description

template<typename T, typename TAlloc = irrAllocator<T>>
class irr::core::string< T, TAlloc >

Very simple string class with some useful features.

string<c8> and string<wchar_t> both accept Unicode AND ASCII/Latin-1, so you can assign Unicode to string<c8> and ASCII/Latin-1 to string<wchar_t> (and the other way round) if you want to.

However, note that the conversation between both is not done using any encoding. This means that c8 strings are treated as ASCII/Latin-1, not UTF-8, and are simply expanded to the equivalent wchar_t, while Unicode/wchar_t characters are truncated to 8-bit ASCII/Latin-1 characters, discarding all other information in the wchar_t.

Known bugs: Special characters like umlauts are ignored in the methods make_upper, make_lower and equals_ignore_case.

Definition at line 36 of file irrString.h.


Constructor & Destructor Documentation

template<typename T, typename TAlloc = irrAllocator<T>>
irr::core::string< T, TAlloc >::string (  )  [inline]

Default constructor.

Definition at line 41 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
irr::core::string< T, TAlloc >::string ( const string< T > &  other  )  [inline]

Constructor.

Definition at line 50 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
irr::core::string< T, TAlloc >::string ( const string< B > &  other  )  [inline]

Constructor from other string types.

Definition at line 58 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
irr::core::string< T, TAlloc >::string ( const double  number  )  [inline, explicit]

Constructs a string from a float.

Definition at line 66 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
irr::core::string< T, TAlloc >::string ( int  number  )  [inline, explicit]

Constructs a string from an int.

Definition at line 76 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
irr::core::string< T, TAlloc >::string ( unsigned int  number  )  [inline, explicit]

Constructs a string from an unsigned int.

Definition at line 125 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
irr::core::string< T, TAlloc >::string ( const B *const   c,
u32  length 
) [inline]

Constructor for copying a string from a pointer with a given length.

Definition at line 158 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
irr::core::string< T, TAlloc >::string ( const B *const   c  )  [inline]

Constructor for unicode and ascii strings.

Definition at line 180 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
irr::core::string< T, TAlloc >::~string (  )  [inline]

destructor

Definition at line 188 of file irrString.h.


Member Function Documentation

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::append ( const string< T > &  other,
u32  length 
) [inline]

Appends a string of the length l to this string.

Parameters:
other,: other String to append to this string.
length,: How much characters of the other string to add to this one.

Definition at line 524 of file irrString.h.

References irr::core::string< T, TAlloc >::append(), and irr::core::string< T, TAlloc >::size().

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::append ( const string< T > &  other  )  [inline]

Appends a string to this string.

Parameters:
other,: String to append.

Definition at line 506 of file irrString.h.

References irr::core::string< T, TAlloc >::size().

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::append ( const T *const   other  )  [inline]

Appends a char string to this string.

Parameters:
other,: Char string to append.

Definition at line 478 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::append ( character  )  [inline]

template<typename T, typename TAlloc = irrAllocator<T>>
const T* irr::core::string< T, TAlloc >::c_str (  )  const [inline]

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::equals_ignore_case ( const string< T > &  other  )  const [inline]

Compares the strings ignoring case.

Parameters:
other,: Other string to compare.
Returns:
True if the strings are equal ignoring case.

Definition at line 400 of file irrString.h.

References irr::core::array< T, TAlloc >::used.

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::equalsn ( const T *const   str,
u32  n 
) const [inline]

compares the first n characters of the strings

Parameters:
str Other string to compare.
n Number of characters to compare
Returns:
True if the n first characters of this string are smaller.

Definition at line 447 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::equalsn ( const string< T > &  other,
u32  n 
) const [inline]

compares the first n characters of the strings

Parameters:
other Other string to compare.
n Number of characters to compare
Returns:
True if the n first characters of this string are smaller.

Definition at line 430 of file irrString.h.

References irr::core::string< T, TAlloc >::used.

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::erase ( u32  index  )  [inline]

Erases a character from the string.

May be slow, because all elements following after the erased element have to be copied.

Parameters:
index,: Index of element to be erased.

Definition at line 848 of file irrString.h.

References _IRR_DEBUG_BREAK_IF.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
s32 irr::core::string< T, TAlloc >::find ( const B *const   str  )  const [inline]

finds another string in this string

Parameters:
str,: Another string
Returns:
Positions where the string has been found, or -1 if not found.

Definition at line 696 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
s32 irr::core::string< T, TAlloc >::findFirst ( c  )  const [inline]

finds first occurrence of character in string

Parameters:
c,: Character to search for.
Returns:
Position where the character has been found, or -1 if not found.

Definition at line 562 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
s32 irr::core::string< T, TAlloc >::findFirstChar ( const T *const   c,
u32  count 
) const [inline]

finds first occurrence of a character of a list in string

Parameters:
c,: List of characters to find. For example if the method should find the first occurrence of 'a' or 'b', this parameter should be "ab".
count,: Amount of characters in the list. Usually, this should be strlen(c)
Returns:
Position where one of the characters has been found, or -1 if not found.

Definition at line 578 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
s32 irr::core::string< T, TAlloc >::findFirstCharNotInList ( const B *const   c,
u32  count 
) const [inline]

Finds first position of a character not in a given list.

Parameters:
c,: List of characters not to find. For example if the method should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab".
count,: Amount of characters in the list. Usually, this should be strlen(c)
Returns:
Position where the character has been found, or -1 if not found.

Definition at line 600 of file irrString.h.

Referenced by irr::core::string< T, TAlloc >::trim().

template<typename T, typename TAlloc = irrAllocator<T>>
s32 irr::core::string< T, TAlloc >::findLast ( c,
s32  start = -1 
) const [inline]

finds last occurrence of character in string

Parameters:
c,: Character to search for.
start,: start to search reverse ( default = -1, on end )
Returns:
Position where the character has been found, or -1 if not found.

Definition at line 660 of file irrString.h.

References irr::core::clamp().

Referenced by irr::core::cutFilenameExtension(), and irr::core::getFileNameExtension().

template<typename T, typename TAlloc = irrAllocator<T>>
s32 irr::core::string< T, TAlloc >::findLastChar ( const T *const   c,
u32  count 
) const [inline]

finds last occurrence of a character of a list in string

Parameters:
c,: List of strings to find. For example if the method should find the last occurrence of 'a' or 'b', this parameter should be "ab".
count,: Amount of characters in the list. Usually, this should be strlen(c)
Returns:
Position where one of the characters has been found, or -1 if not found.

Definition at line 677 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
s32 irr::core::string< T, TAlloc >::findLastCharNotInList ( const B *const   c,
u32  count 
) const [inline]

Finds last position of a character not in a given list.

Parameters:
c,: List of characters not to find. For example if the method should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab".
count,: Amount of characters in the list. Usually, this should be strlen(c)
Returns:
Position where the character has been found, or -1 if not found.

Definition at line 624 of file irrString.h.

Referenced by irr::core::string< T, TAlloc >::trim().

template<typename T, typename TAlloc = irrAllocator<T>>
s32 irr::core::string< T, TAlloc >::findNext ( c,
u32  startPos 
) const [inline]

finds next occurrence of character in string

Parameters:
c,: Character to search for.
startPos,: Position in string to start searching.
Returns:
Position where the character has been found, or -1 if not found.

Definition at line 645 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::lower_ignore_case ( const string< T > &  other  )  const [inline]

Compares the strings ignoring case.

Parameters:
other,: Other string to compare.
Returns:
True if this string is smaller ignoring case.

Definition at line 413 of file irrString.h.

References irr::core::string< T, TAlloc >::array, and irr::core::string< T, TAlloc >::used.

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::make_lower (  )  [inline]

Makes the string lower case.

Definition at line 375 of file irrString.h.

Referenced by irr::video::ITexture::ITexture().

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::make_upper (  )  [inline]

Makes the string upper case.

Definition at line 383 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::operator!= ( const string< T > &  other  )  const [inline]

Inequality operator.

Definition at line 352 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::operator!= ( const T *const   str  )  const [inline]

Inequality operator.

Definition at line 345 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
string<T> irr::core::string< T, TAlloc >::operator+ ( const B *const   c  )  const [inline]

Append operator for strings, ascii and unicode.

Definition at line 275 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T> irr::core::string< T, TAlloc >::operator+ ( const string< T > &  other  )  const [inline]

Append operator for other strings.

Definition at line 264 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const float  i  )  [inline]

Definition at line 812 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const double  i  )  [inline]

Definition at line 805 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const unsigned long &  i  )  [inline]

Definition at line 798 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const long  i  )  [inline]

Definition at line 791 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const unsigned int  i  )  [inline]

Definition at line 784 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const int  i  )  [inline]

Definition at line 777 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const string< T > &  other  )  [inline]

Appends a string to this string.

Parameters:
other,: String to append.

Definition at line 770 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( const T *const   c  )  [inline]

Appends a char string to this string.

Parameters:
other,: Char string to append.

Definition at line 761 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator+= ( c  )  [inline]

Appends a character to this string.

Parameters:
character,: Character to append.

Definition at line 752 of file irrString.h.

References irr::core::string< T, TAlloc >::append().

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::operator< ( const string< T > &  other  )  const [inline]

Is smaller comparator.

Definition at line 327 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
string<T>& irr::core::string< T, TAlloc >::operator= ( const B *const   c  )  [inline]

Assignment operator for strings, ascii and unicode.

Definition at line 222 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
template<class B>
string<T>& irr::core::string< T, TAlloc >::operator= ( const string< B > &  other  )  [inline]

Assignment operator for other string types.

Definition at line 213 of file irrString.h.

References irr::core::string< T, TAlloc >::c_str().

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::operator= ( const string< T > &  other  )  [inline]

Assignment operator.

Definition at line 195 of file irrString.h.

References irr::core::string< T, TAlloc >::c_str(), and irr::core::string< T, TAlloc >::size().

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::operator== ( const string< T > &  other  )  const [inline]

Equality operator.

Definition at line 316 of file irrString.h.

References irr::core::string< T, TAlloc >::array, and irr::core::string< T, TAlloc >::used.

template<typename T, typename TAlloc = irrAllocator<T>>
bool irr::core::string< T, TAlloc >::operator== ( const T *const   str  )  const [inline]

Equality operator.

Definition at line 301 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
const T& irr::core::string< T, TAlloc >::operator[] ( const u32  index  )  const [inline]

Direct access operator.

Definition at line 293 of file irrString.h.

References _IRR_DEBUG_BREAK_IF.

template<typename T, typename TAlloc = irrAllocator<T>>
T& irr::core::string< T, TAlloc >::operator[] ( const u32  index  )  [inline]

Direct access operator.

Definition at line 285 of file irrString.h.

References _IRR_DEBUG_BREAK_IF.

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::replace ( toReplace,
replaceWith 
) [inline]

replaces all characters of a special type with another one

Definition at line 820 of file irrString.h.

template<typename T, typename TAlloc = irrAllocator<T>>
void irr::core::string< T, TAlloc >::reserve ( u32  count  )  [inline]

Reserves some memory.

Parameters:
count,: Amount of characters to reserve.

Definition at line 549 of file irrString.h.

Referenced by irr::core::string< T, TAlloc >::subString().

template<typename T, typename TAlloc = irrAllocator<T>>
u32 irr::core::string< T, TAlloc >::size (  )  const [inline]

template<typename T, typename TAlloc = irrAllocator<T>>
string<T> irr::core::string< T, TAlloc >::subString ( u32  begin,
s32  length 
) const [inline]

template<typename T, typename TAlloc = irrAllocator<T>>
string<T>& irr::core::string< T, TAlloc >::trim ( const string< T > &  whitespace = " \t\n\r"  )  [inline]

trims the string.

Removes the specified characters (by default, Latin-1 whitespace) from the begining and the end of the string.

Definition at line 831 of file irrString.h.

References irr::core::string< T, TAlloc >::findFirstCharNotInList(), irr::core::string< T, TAlloc >::findLastCharNotInList(), and irr::core::string< T, TAlloc >::subString().


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

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2008 by Nikolaus Gebhardt. Generated on Sun Dec 14 08:04:49 2008 by Doxygen (1.5.6)