gatelib  2.1
Functions
g_str_lib

Functions

wchar_t * g::str::to_widestr (const char *src, wchar_t *dst=(wchar_t *) alloc_new)
 converts a byte gstr ( const char* ) to a wide one ( wchar_t* ). More...
 
char * g::str::to_charstr (const wchar_t *src, char *dst=(char *) alloc_new)
 converts a wide gstr ( const wchar_t* ) to a wide one ( char* ) More...
 
template<class T >
size_t g::str::get_len (const T *aString)
 Returns the string length.
 
template<class T >
size_t g::str::str_copy (T *aDestP, const T *aSrcP, size_t aNumChars=infinite)
 Copies from aSrc to aDest up to a maximum of aNumChars characters (excluding terminator) More...
 
template<class T >
int g::str::str_compare (const T *aS1, const T *aS2, bool aIsCaseSens=true, size_t aNumChars=infinite)
 Compares two strings. More...
 
template<class T >
bool g::str::str_equal (const T *aS1, const T *aS2, bool aIsCaseSens=true, size_t aNumChars=infinite)
 Check two strings for equality. More...
 
template<class T >
size_t g::str::str_search (const T *aS1, const T *aS2, bool aIsCaseSens=true, size_t aNumChars=infinite)
 Searches aS2 inside aS1. More...
 
template<class T >
size_t g::str::str_replace (const T *aString, const T *aWhat, const T *aWith, T *aOutputBuffer, size_t aNumChars=infinite)
 Replace aWhat with aWith inside aInput, the result is stored into aOutputBuffer, whose capacity us aNumChars. More...
 
template<class T , class R , size_t S>
g::str::str_replace (const T *aInput, const T *aWhat, const T *aWith)
 Replace aWhat with aWith inside aInput and returns the result as a class string (a std::string , std::wstring , g::cont::g_str<T>) More...
 

Detailed Description

See also
g_str_lib.h

Function Documentation

template<class T >
int g::str::str_compare ( const T *  aS1,
const T *  aS2,
bool  aIsCaseSens = true,
size_t  aNumChars = infinite 
)
inline

Compares two strings.

Parameters
aS1first string to be compared
aS2second string to be compared
aIsCaseSenscomparition to be case sensitive or not?
aNumCharsnum of chars to be compared.
Template Parameters
Ta character type(char,wchar_t)
Returns
  • -1 aC1 < aC2 (alphabetically order)
  • 0 aC1 = aC2
  • +1 aC1 > aC2 (alphabetically order)
template<class T >
size_t g::str::str_copy ( T *  aDestP,
const T *  aSrcP,
size_t  aNumChars = infinite 
)
inline

Copies from aSrc to aDest up to a maximum of aNumChars characters (excluding terminator)

Returns
the number of copied characters (excluding terminator)

Referenced by g::str::str_replace().

template<class T >
bool g::str::str_equal ( const T *  aS1,
const T *  aS2,
bool  aIsCaseSens = true,
size_t  aNumChars = infinite 
)
inline

Check two strings for equality.

Parameters
aS1first string to be compared
aS2second string to be compared
aIsCaseSenscomparition to be case sensitive or not?
aNumCharsnum of chars to be compared.
Template Parameters
Ta character type(char,wchar_t)
template<class T >
size_t g::str::str_replace ( const T *  aString,
const T *  aWhat,
const T *  aWith,
T *  aOutputBuffer,
size_t  aNumChars = infinite 
)
inline

Replace aWhat with aWith inside aInput, the result is stored into aOutputBuffer, whose capacity us aNumChars.

Template Parameters
Ta character type(char,wchar_t)
Parameters
aStringinput string (a char buffer)
aWhatstring to be searched
aWithstring replacing aWhat occurences
aOutputBufferchar buffer with a capacity of aNumChars + 1 (stores the terminator too)
aNumCharscapacity of aOutputBuffer (excluding the terminator)
template<class T , class R , size_t S>
R g::str::str_replace ( const T *  aInput,
const T *  aWhat,
const T *  aWith 
)
inline

Replace aWhat with aWith inside aInput and returns the result as a class string (a std::string , std::wstring , g::cont::g_str<T>)

Template Parameters
Tchar type (char,wchar_t)
Rreturn type (a structured, not necessarly emplate type ) where the operator += ( const T* ) must be defined.
S,sizein chars (excluding the terminator), therefore temp buffer has a capacity of S+1.
Parameters
aStringinput string (a char buffer)
aWhatstring to be searched
aWithstring replacing aWhat occurences
template<class T >
size_t g::str::str_search ( const T *  aS1,
const T *  aS2,
bool  aIsCaseSens = true,
size_t  aNumChars = infinite 
)
inline

Searches aS2 inside aS1.

Parameters
aS1first string to be compared
aS2second string to be compared
aIsCaseSenscomparition to be case sensitive or not?
aNumCharsnum of chars to be compared.
Template Parameters
Ta character type(char,wchar_t)

Searches aS2 inside aS1 until an offset of aNumChars from aS1.
If the search succeeds the returns the offset, otherwise returns the size of aS1 or aNumChars, if it is < of size(aS1)

Referenced by g::str::str_replace().

char * g::str::to_charstr ( const wchar_t *  aSrcP,
char *  aDstP = (char*)alloc_new 
)
inline

converts a wide gstr ( const wchar_t* ) to a wide one ( char* )

converts a wide gstr ( const wchar_t* ) to an ANSI one ( char* ).

if len = 0 returns null.
if dst = alloc_new ( 0 ) then it allocates the needed chars.

if len = 0 returns null.
if dst = alloc_new ( 0 ) then it allocates the needed chars

wchar_t * g::str::to_widestr ( const char *  aSrcP,
wchar_t *  aDstP = (wchar_t*)alloc_new 
)
inline

converts a byte gstr ( const char* ) to a wide one ( wchar_t* ).

converts a byte gstr ( const char* ) to a wide one ( wchar_t* )

if len = 0 returns null
if dst = alloc_new ( 0 ) then it allocates the needed chars