Hopsan
HString Class Reference
Inheritance diagram for HString:
HFilePath HTextBlock

Public Member Functions

 HString (const char *str)
 
 HString (const char *str, const size_t len)
 
 HString (char c)
 
 HString (const int value)
 This constructor is used to catch mistakes made by Hospan component developers. More...
 
 HString (const HString &rOther)
 Copy constructor.
 
 HString (const HString &rOther, size_t pos, size_t len=npos)
 
void setString (const char *str)
 Set the string by copying const char*. More...
 
void setString (const char *str, const size_t len)
 Set the string by copying a specific number of chars from const char*. More...
 
HStringappend (const char *str)
 
HStringappend (const char chr)
 
HStringappend (const HString &str)
 
HStringerase (size_t pos=0, size_t len=npos)
 
void clear ()
 Clear the string.
 
void replace (const size_t pos, const size_t len, const char *str)
 
HStringreplace (const char *oldstr, const char *newstr)
 
HStringreplace (const HString &rOldstr, const HString &rNewstr)
 
const char * c_str () const
 Returns a c_str pointer to internal data. More...
 
size_t size () const
 
bool empty () const
 Check if string is empty. More...
 
bool compare (const char *other) const
 Compare string to const char*. More...
 
bool compare (const HString &rOther) const
 
bool startsWith (const HString &rOther) const
 
bool isNummeric () const
 Check if the string can be interpreted as a number.
 
bool isBool () const
 Check if the string can be interpreted as bool (true, false, 1, 0)
 
double toDouble (bool *isOK) const
 
long int toLongInt (bool *isOK) const
 
bool toBool (bool *isOK) const
 
HString substr (const size_t pos, const size_t len=npos) const
 Extract substring. More...
 
HVector< HStringsplit (const char delim) const
 
size_t find_first_of (const char c, size_t pos=0) const
 
size_t rfind (const char c, size_t pos=npos) const
 
size_t find (const char c, size_t pos=0) const
 
size_t find (const char *s, size_t pos=0) const
 
size_t find (const HString &s, size_t pos=0) const
 
bool containes (const HString &rString) const
 
bool containes (const char c) const
 
bool containes (const char *s) const
 
char front () const
 
char & front ()
 
char back () const
 
char & back ()
 
char at (const size_t pos) const
 
char & operator[] (const size_t idx)
 
const char & operator[] (const size_t idx) const
 
bool operator< (const HString &rhs) const
 
HStringoperator+= (const HString &rhs)
 
HStringoperator+= (const char *rhs)
 
HStringoperator+= (const char rhs)
 
HStringoperator= (const char *rhs)
 
HStringoperator= (const char rhs)
 
HStringoperator= (const HString &rhs)
 

Static Public Attributes

static const size_t npos = std::numeric_limits<size_t>::max()
 

Constructor & Destructor Documentation

◆ HString()

HString ( const int  value)

This constructor is used to catch mistakes made by Hospan component developers.

Member Function Documentation

◆ c_str()

const char * c_str ( ) const

Returns a c_str pointer to internal data.

Note
The pointer is only valid, while the HString object is alive

◆ compare()

bool compare ( const char *  other) const

Compare string to const char*.

Parameters
[in]otherThe string to compare to
Returns
True if same, else False

◆ empty()

bool empty ( ) const

Check if string is empty.

Returns
True if empty, else False

◆ operator+=()

HString & operator+= ( const HString rhs)

◆ replace()

void replace ( const size_t  pos,
const size_t  len,
const char *  str 
)

◆ setString() [1/2]

void setString ( const char *  str)

Set the string by copying const char*.

Parameters
[in]strThe string data to copy

◆ setString() [2/2]

void setString ( const char *  str,
const size_t  len 
)

Set the string by copying a specific number of chars from const char*.

Parameters
[in]strThe string data to copy
[in]lenThe number of bytes to copy

◆ substr()

HString substr ( const size_t  pos,
const size_t  len = npos 
) const

Extract substring.

Parameters
[in]posFirst index of substring
[in]lenNum bytes in substring, or HString::npos for all
Returns
A substring

◆ toLongInt()

long int toLongInt ( bool *  isOK) const