iaux::iaString Class Reference

#include <iaString.h>

Public Types

enum class  Alignment { Left , Right , Center }
 

Public Member Functions

 iaString ()=default
 
 iaString (const char *text, const int64 length=INVALID_POSITION)
 
 iaString (const wchar_t *text, const int64 length=INVALID_POSITION)
 
 iaString (const wchar_t character, int count=1)
 
 iaString (const char character, int count=1)
 
 iaString (const iaString &text)
 
 ~iaString ()
 
int64 getLength () const
 
int64 getSize () const
 
int64 getHashValue () const
 
void toLower ()
 
void toUpper ()
 
iaString operator+ (const iaString &text) const
 
void operator+= (const iaString &text)
 
iaString operator+ (const wchar_t &character) const
 
void operator+= (const wchar_t &character)
 
bool operator== (const iaString &text) const
 
bool operator== (const wchar_t *text) const
 
bool operator== (const char *text) const
 
bool operator!= (const iaString &text) const
 
iaString operator= (const iaString &text)
 
iaString operator= (const wchar_t *text)
 
iaString operator= (const char *text)
 
iaString operator= (const wchar_t character)
 
iaString operator= (const char character)
 
bool operator< (const iaString &text) const
 
bool operator> (const iaString &text) const
 
wchar_t & operator[] (const int64 index)
 
const wchar_t & operator[] (const int64 index) const
 
iaString getSubString (const int64 pos, const int64 len=INVALID_POSITION) const
 
void split (const iaString &delimiters, std::vector< iaString > &tokens, iaStringSplitMode splitMode=iaStringSplitMode::Normal) const
 
void split (const wchar_t delimiter, std::vector< iaString > &tokens, iaStringSplitMode splitMode=iaStringSplitMode::Normal) const
 
void split (const char delimiter, std::vector< iaString > &tokens, iaStringSplitMode splitMode=iaStringSplitMode::Normal) const
 
int64 findFirstOf (const iaString &characters, const int64 from=INVALID_POSITION) const
 
int64 findFirstOf (const wchar_t *characters, const int64 from=INVALID_POSITION) const
 
int64 findFirstOf (const wchar_t character, const int64 from=INVALID_POSITION) const
 
int64 findFirstNotOf (const wchar_t *characters, const int64 from=INVALID_POSITION) const
 
int64 findFirstNotOf (const wchar_t character, const int64 from=INVALID_POSITION) const
 
int64 findLastOf (const wchar_t character) const
 
int64 findLastOf (const wchar_t *characters) const
 
int64 findLastNotOf (const wchar_t character) const
 
int64 findLastNotOf (const wchar_t *characters) const
 
void clear ()
 
bool isEmpty () const
 
const wchar_t * getData () const
 
int64 getData (char *buffer, const int64 size) const
 
int64 getUTF8 (char *buffer, const int64 size) const
 
int64 getUTF8Size () const
 
void setUTF8 (const char *buffer, const int64 size)
 
void reverse ()
 
void insert (const iaString &text, int64 pos)
 
void remove (int64 pos, int64 length)
 

Static Public Member Functions

static iaString align (const iaString &text, int width, Alignment alignment, wchar_t character=L' ')
 
static iaString toString (uint64 value, int base=10)
 
static iaString toString (int64 value, int base=10)
 
static iaString toString (int32 value, int base=10)
 
static iaString toString (uint32 value, int base=10)
 
static iaString toString (float64 value, int afterPoint=4)
 
static iaString toString (float32 value, int afterPoint=4)
 
static iaString toStringUnits (int64 value)
 
static float64 toFloat (const iaString &text)
 
static int64 toInt (const iaString &text)
 
static uint64 toUInt (const iaString &text, int base=10)
 
static bool toBool (const iaString &text)
 
template<class T >
static void toVector (const iaString &text, iaVector2< T > &vector)
 
template<class T >
static void toVector (const iaString &text, iaVector3< T > &vector)
 
template<class T >
static void toVector (const iaString &text, iaVector4< T > &vector)
 
static iaString wildcardToRegex (const iaString &pattern)
 
static iaString trimLeft (const iaString &text)
 
static iaString trimRight (const iaString &text)
 
static iaString trim (const iaString &text)
 
static bool matchRegex (const iaString &text, const iaString &regex)
 
static void replaceRegex (const iaString &src, const iaString &regex, const iaString &replaceWith, iaString &dst)
 
static bool searchRegex (const iaString &src, const iaString &regex, std::vector< iaString > &matches)
 

Static Public Attributes

static const int64 INVALID_POSITION = -1
 

Detailed Description

wide char (unicode) character string with trailing zero and length

Member Enumeration Documentation

◆ Alignment

enum class iaux::iaString::Alignment
strong
Enumerator
Left 
Right 
Center 

Constructor & Destructor Documentation

◆ iaString() [1/6]

iaux::iaString::iaString ( )
default

default ctor does nothing

◆ iaString() [2/6]

iaux::iaString::iaString ( const char *  text,
const int64  length = INVALID_POSITION 
)

ctor with byte string

Parameters
textbyte string
lengthif input string is not zero terminated or a custom length is needed

◆ iaString() [3/6]

iaux::iaString::iaString ( const wchar_t *  text,
const int64  length = INVALID_POSITION 
)

copies unicode string

Parameters
textunicode string
lengthif input string is not zero terminated or a custom length is needed

◆ iaString() [4/6]

iaux::iaString::iaString ( const wchar_t  character,
int  count = 1 
)

creates a string using given character

Parameters
characterthe wide character to create the string with
counthow many times the character will be added to this string

◆ iaString() [5/6]

iaux::iaString::iaString ( const char  character,
int  count = 1 
)

creates a string with only one character

Parameters
characterthe character to create the string with
counthow many times the character will be added to this string

◆ iaString() [6/6]

iaux::iaString::iaString ( const iaString text)

copy ctor

Parameters
textthe string to copy from

◆ ~iaString()

iaux::iaString::~iaString ( )

dtor releases allocated memory

Member Function Documentation

◆ align()

iaString iaux::iaString::align ( const iaString text,
int  width,
Alignment  alignment,
wchar_t  character = L' ' 
)
static

adds padding to text so target width is reached

Parameters
textthe given text
widththe target text length
alignmentthe desired alignment of the text
characterthe character used to fill up the string

◆ clear()

void iaux::iaString::clear ( )

empties the string

◆ findFirstNotOf() [1/2]

int64 iaux::iaString::findFirstNotOf ( const wchar_t *  characters,
const int64  from = INVALID_POSITION 
) const
Returns
position of first occurrence NOT of specified characters

if not found INVALID_POSITION will be returned

Parameters
charactersthe characters to NOT search for
fromoptional parameter to define start index to search from

◆ findFirstNotOf() [2/2]

int64 iaux::iaString::findFirstNotOf ( const wchar_t  character,
const int64  from = INVALID_POSITION 
) const
Returns
position of first occurrence NOT of specified character

if not found INVALID_POSITION will be returned

Parameters
characterthe character to NOT search for
fromoptional parameter to define start index to search from

◆ findFirstOf() [1/3]

int64 iaux::iaString::findFirstOf ( const iaString characters,
const int64  from = INVALID_POSITION 
) const
Returns
position of first occurrence of on of the specified characters

if not found iaString::INVALID_POSITION will be returned

Parameters
charactersthe characters to search for
fromoptional parameter to define start index to search from

◆ findFirstOf() [2/3]

int64 iaux::iaString::findFirstOf ( const wchar_t *  characters,
const int64  from = INVALID_POSITION 
) const
Returns
position of first occurrence of on of the specified characters

if not found iaString::INVALID_POSITION will be returned

Parameters
charactersthe characters to search for
fromoptional parameter to define start index to search from

◆ findFirstOf() [3/3]

int64 iaux::iaString::findFirstOf ( const wchar_t  character,
const int64  from = INVALID_POSITION 
) const
Returns
position of first occurrence of on of the specified characters

if not found INVALID_POSITION will be returned

Parameters
characterthe character to search for
fromoptional parameter to define start index to search from

◆ findLastNotOf() [1/2]

int64 iaux::iaString::findLastNotOf ( const wchar_t *  characters) const
Returns
position of last occurrence NOT of specified characters

if not found INVALID_POSITION will be returned

Parameters
charactersthe characters to search for

◆ findLastNotOf() [2/2]

int64 iaux::iaString::findLastNotOf ( const wchar_t  character) const
Returns
position of last occurrence NOT of specified character

if not found INVALID_POSITION will be returned

Parameters
characterthe character to search for

◆ findLastOf() [1/2]

int64 iaux::iaString::findLastOf ( const wchar_t *  characters) const
Returns
position of last occurrence of specified characters

if not found INVALID_POSITION will be returned

Parameters
charactersthe characters to search for

◆ findLastOf() [2/2]

int64 iaux::iaString::findLastOf ( const wchar_t  character) const
Returns
position of last occurrence of specified character

if not found INVALID_POSITION will be returned

Parameters
characterthe character to search for

◆ getData() [1/2]

const wchar_t * iaux::iaString::getData ( ) const
Returns
pointer to raw data

◆ getData() [2/2]

int64 iaux::iaString::getData ( char *  buffer,
const int64  size 
) const

returns null terminated byte string

Parameters
bufferpre allocated buffer to write the string to
sizesize of preallocated buffer
Returns
actual size of written data including ending zero

◆ getHashValue()

int64 iaux::iaString::getHashValue ( ) const
Returns
hash value for current text

◆ getLength()

int64 iaux::iaString::getLength ( ) const
Returns
character count of the string without trailing zero

◆ getSize()

int64 iaux::iaString::getSize ( ) const
Returns
size of data in bytes

◆ getSubString()

iaString iaux::iaString::getSubString ( const int64  pos,
const int64  len = INVALID_POSITION 
) const
Returns
specified substring
Parameters
possubstring from
lensubstring length

◆ getUTF8()

int64 iaux::iaString::getUTF8 ( char *  buffer,
const int64  size 
) const

returns utf8 encoded string

Parameters
bufferthe destination buffer for the utf8 string
sizethe size of the destination buffer
Returns
bytes written to destination buffer

◆ getUTF8Size()

int64 iaux::iaString::getUTF8Size ( ) const

calculates the size in bytes of the string encoded in utf8

Returns
size in bytes

◆ insert()

void iaux::iaString::insert ( const iaString text,
int64  pos 
)

insert text at given position

Parameters
textthe text to insert
posthe position where to insert the text

◆ isEmpty()

bool iaux::iaString::isEmpty ( ) const
Returns
true: if string is empty; false if not

◆ matchRegex()

bool iaux::iaString::matchRegex ( const iaString text,
const iaString regex 
)
static
Returns
true if the text matches the regular expression
Parameters
textthe given text
regexthe given regular expression

◆ operator!=()

bool iaux::iaString::operator!= ( const iaString text) const

++ operator to compare to strings

Parameters
textthe strin to compare with
Returns
true: if not equal; false if equal

◆ operator+() [1/2]

iaString iaux::iaString::operator+ ( const iaString text) const
  • operator concatanates two strings
Parameters
textthe string to add
Returns
resulting concatanated string

◆ operator+() [2/2]

iaString iaux::iaString::operator+ ( const wchar_t &  character) const
  • operator to add a single character
Parameters
charactercharacter to add

◆ operator+=() [1/2]

void iaux::iaString::operator+= ( const iaString text)

+= operator concatanates strings

Parameters
textthe string to add to the current string

◆ operator+=() [2/2]

void iaux::iaString::operator+= ( const wchar_t &  character)

+= operator to add a single character

Parameters
charactercharacter to add

◆ operator<()

bool iaux::iaString::operator< ( const iaString text) const

compares two strings and returns true if the left hand side string is considered smaller

Parameters
textthe right hand side string

◆ operator=() [1/5]

iaString iaux::iaString::operator= ( const char *  text)

= operator overwrites current string with new string

Parameters
textthe new string
Returns
the new string

◆ operator=() [2/5]

iaString iaux::iaString::operator= ( const char  character)

= operator overwrites current string with one character

Parameters
characterthe character
Returns
the new string

◆ operator=() [3/5]

iaString iaux::iaString::operator= ( const iaString text)

= operator overwrites current string with new string

Parameters
textthe new string
Returns
the new string

◆ operator=() [4/5]

iaString iaux::iaString::operator= ( const wchar_t *  text)

= operator overwrites current string with new string

Parameters
textthe new string
Returns
the new string

◆ operator=() [5/5]

iaString iaux::iaString::operator= ( const wchar_t  character)

= operator overwrites current string with one character

Parameters
characterthe character
Returns
the new string

◆ operator==() [1/3]

bool iaux::iaString::operator== ( const char *  text) const

== operator to compare to strings

Parameters
textthe string to compare with
Returns
true: if equal; false if not equal

◆ operator==() [2/3]

bool iaux::iaString::operator== ( const iaString text) const

== operator to compare to strings

Parameters
textthe string to compare with
Returns
true: if equal; false if not equal

◆ operator==() [3/3]

bool iaux::iaString::operator== ( const wchar_t *  text) const

== operator to compare to strings

Parameters
textthe string to compare with
Returns
true: if equal; false if not equal

◆ operator>()

bool iaux::iaString::operator> ( const iaString text) const

compares two strings and returns true if the left hand side string is considered bigger

Parameters
textthe right hand side string

◆ operator[]() [1/2]

wchar_t & iaux::iaString::operator[] ( const int64  index)
Returns
character at given position for manipulation
Parameters
indexthe position to get the character from

◆ operator[]() [2/2]

const wchar_t & iaux::iaString::operator[] ( const int64  index) const
Returns
character at given position
Parameters
indexthe position to get the character from

◆ remove()

void iaux::iaString::remove ( int64  pos,
int64  length 
)

removed characters from string

Parameters
posindex of first character to remove
lengthamount of characters to remove

◆ replaceRegex()

void iaux::iaString::replaceRegex ( const iaString src,
const iaString regex,
const iaString replaceWith,
iaString dst 
)
static

replace sections in source text and return destination text

Parameters
[out]dstthe destination text
srcthe source text
regexthe regular expression to find the patterns to replace
replaceWiththe text to replace the patterns with

◆ reverse()

void iaux::iaString::reverse ( )

reverses the string

◆ searchRegex()

bool iaux::iaString::searchRegex ( const iaString src,
const iaString regex,
std::vector< iaString > &  matches 
)
static

searches for matches in string with given regular expression

Parameters
srcthe source string to search
regexthe regular expression
[out]thefound matches

◆ setUTF8()

void iaux::iaString::setUTF8 ( const char *  buffer,
const int64  size 
)

set string with utf8 encoded string

Parameters
buffersource buffer with utf8 string
sizethe size of the source buffer

◆ split() [1/3]

void iaux::iaString::split ( const char  delimiter,
std::vector< iaString > &  tokens,
iaStringSplitMode  splitMode = iaStringSplitMode::Normal 
) const

same as split with delimiter string but only for one delimiter character

Parameters
delimitersingle delimiter character
tokensthe resulting tokens

◆ split() [2/3]

void iaux::iaString::split ( const iaString delimiters,
std::vector< iaString > &  tokens,
iaStringSplitMode  splitMode = iaStringSplitMode::Normal 
) const

splits a string based on delimiter in to tokens (or substrings)

Parameters
delimitersstring with delimiter characters
tokensthe resulting tokens

◆ split() [3/3]

void iaux::iaString::split ( const wchar_t  delimiter,
std::vector< iaString > &  tokens,
iaStringSplitMode  splitMode = iaStringSplitMode::Normal 
) const

same as split with delimiter string but only for one delimiter character

Parameters
delimitersingle delimiter character
tokensthe resulting tokens

◆ toBool()

bool iaux::iaString::toBool ( const iaString text)
static

converts string in to bool value

on error it falls back to false

Parameters
textthe text to convert
Returns
true of false depending on the text

◆ toFloat()

float64 iaux::iaString::toFloat ( const iaString text)
static

transforms a iaString to a float

Parameters
textthe string
Returns
value

◆ toInt()

int64 iaux::iaString::toInt ( const iaString text)
static

transforms a iaString to a int64

Parameters
textthe string
Returns
value

◆ toLower()

void iaux::iaString::toLower ( )

change string to lower case letters

◆ toString() [1/6]

iaString iaux::iaString::toString ( float32  value,
int  afterPoint = 4 
)
static

transforms a float to a iaString

Parameters
valuethe float value
afterPointdefines how many digits after the point
Returns
isString

◆ toString() [2/6]

iaString iaux::iaString::toString ( float64  value,
int  afterPoint = 4 
)
static

transforms a float to a iaString

Parameters
valuethe float value
afterPointdefines how many digits after the point
Returns
isString

◆ toString() [3/6]

iaString iaux::iaString::toString ( int32  value,
int  base = 10 
)
static

transforms an integer to a iaString

Parameters
valuethe integer value
basethe number base
Returns
isString

◆ toString() [4/6]

iaString iaux::iaString::toString ( int64  value,
int  base = 10 
)
static

transforms an integer to a iaString

Parameters
valuethe integer value
basethe number base
Returns
isString

◆ toString() [5/6]

iaString iaux::iaString::toString ( uint32  value,
int  base = 10 
)
static

transforms an integer to a iaString

Parameters
valuethe integer value
basethe number base
Returns
isString

◆ toString() [6/6]

iaString iaux::iaString::toString ( uint64  value,
int  base = 10 
)
static

transforms an integer to a iaString

Parameters
valuethe integer value
basethe number base
Returns
isString

◆ toStringUnits()

iaString iaux::iaString::toStringUnits ( int64  value)
static

human readabile number

3000 -> 3k 3000000 -> 3M 3000000000 -> 3G 3000000000000 -> 3T

Parameters
valueinput value
Returns
human readable number

◆ toUInt()

uint64 iaux::iaString::toUInt ( const iaString text,
int  base = 10 
)
static

transforms a iaString to a uint64

Parameters
textthe string
basethe number base
Returns
value

◆ toUpper()

void iaux::iaString::toUpper ( )

change string to upper case letters

◆ toVector() [1/3]

template<class T >
void iaux::iaString::toVector ( const iaString text,
iaVector2< T > &  vector 
)
static

converts a string to a 2d vector

expect two comma separated values

Parameters
textthe text to parse
[out]vectorthe resulting vector

◆ toVector() [2/3]

template<class T >
void iaux::iaString::toVector ( const iaString text,
iaVector3< T > &  vector 
)
static

converts a string to a 3d vector

expect two comma separated values

Parameters
textthe text to parse
[out]vectorthe resulting vector

◆ toVector() [3/3]

template<class T >
void iaux::iaString::toVector ( const iaString text,
iaVector4< T > &  vector 
)
static

converts a string to a 4d vector

expect two comma separated values

Parameters
textthe text to parse
[out]vectorthe resulting vector

◆ trim()

iaString iaux::iaString::trim ( const iaString text)
static

trims white spaces on both ends of the string

Parameters
textthe source text
Returns
the trimmed text

◆ trimLeft()

iaString iaux::iaString::trimLeft ( const iaString text)
static

trims white spaces on the left hand side

Parameters
textthe source text
Returns
the trimmed text

◆ trimRight()

iaString iaux::iaString::trimRight ( const iaString text)
static

trims white spaces on the right hand side

Parameters
textthe source text
Returns
the trimmed text

◆ wildcardToRegex()

iaString iaux::iaString::wildcardToRegex ( const iaString pattern)
static

turn wildcard expression in to regex expression

Parameters
patternthe wildcard expression
Returns
regular expression

Member Data Documentation

◆ INVALID_POSITION

const int64 iaux::iaString::INVALID_POSITION = -1
static

this defines a position that is out of range


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