IDA SDK
Static Public Attributes | Public Member Functions | Public Types | List of all members
_qstring< qchar > Class Template Reference

Detailed Description

template<class qchar>
class _qstring< qchar >

Reimplementation of the string class from STL.

Only the most essential functions are implemented. The reason why we have this is because it is not compiler dependent (hopefully) and therefore can be used in IDA API

Static Public Attributes

static const size_t npos = (size_t) -1
 Invalid position.
 

Public Member Functions

 _qstring (void)
 Constructor.
 
 _qstring (const qchar *ptr)
 Constructor - creates a new qstring from an existing char *.
 
 _qstring (const qchar *ptr, size_t len)
 Constructor - creates a new qstring using first 'len' chars from 'ptr'.
 
void swap (_qstring< qchar > &r)
 Swap contents of two qstrings. see qvector::swap()
 
size_t length (void) const
 Get number of chars in this qstring (not including terminating zero)
 
size_t size (void) const
 Get number of chars in this qstring (including terminating zero)
 
size_t capacity (void) const
 Get number of chars this qstring can contain (including terminating zero)
 
void resize (size_t s, qchar c)
 Resize to the given size. More...
 
void resize (size_t s)
 Similar to resize(size_t, qchar) - but any extra space is filled with zeroes.
 
void remove_last (int cnt=1)
 
void reserve (size_t cnt)
 Increase capacity the qstring. see qvector::reserve()
 
void clear (void)
 Clear qstring and free memory.
 
void qclear (void)
 Clear qstring but do not free memory yet.
 
bool empty (void) const
 Does the qstring have 0 non-null elements?
 
const qchar * c_str (void) const
 Convert the qstring to a char *.
 
iterator begin (void)
 Get a pointer to the beginning of the qstring.
 
const_iterator begin (void) const
 Get a const pointer to the beginning of the qstring.
 
iterator end (void)
 Get a pointer to the end of the qstring (this is not the terminating zero)
 
const_iterator end (void) const
 Get a const pointer to the end of the qstring (this is not the terminating zero)
 
_qstringoperator= (const qchar *str)
 Allow assignment of qstrings using '='.
 
_qstringoperator= (const _qstring &qstr)
 
_qstringoperator+= (qchar c)
 Append a char using '+='.
 
_qstringoperator+= (const _qstring &r)
 Append another qstring using '+='.
 
_qstring operator+ (const _qstring &r) const
 Get result of appending two qstrings using '+'.
 
bool operator== (const _qstring &r) const
 Test equality of two qstrings using '=='.
 
bool operator== (const qchar *r) const
 Test equality of a qstring and a const char* using '=='.
 
bool operator!= (const _qstring &r) const
 Test equality of two qstrings using '!='.
 
bool operator!= (const qchar *r) const
 Test equality of a qstring and a const char* with '!='.
 
bool operator< (const _qstring &r) const
 Compare two qstrings using '<'. see qstrcmp()
 
bool operator< (const qchar *r) const
 Compare two qstrings using '<'. see qstrcmp()
 
const qchar & operator[] (size_t idx) const
 Retrieve char at index 'idx' using '[]'.
 
qchar & operator[] (size_t idx)
 Retrieve char at index 'idx' using '[]'.
 
const qchar & at (size_t idx) const
 Retrieve const char at index 'idx'.
 
qchar & at (size_t idx)
 Retrieve char at index 'idx'.
 
qchar * extract (void)
 Extract C string from _qstring. Must qfree() it.
 
void inject (qchar *s, size_t len)
 Assign this qstring to an existing char *. More...
 
void inject (qchar *s)
 Same as to inject(qchar *, size_t), with len = strlen(s)
 
qchar last (void) const
 Get the last qchar in the string (for concatenation checks)
 
size_t find (const qchar *str, size_t pos=0) const
 Find a substring. More...
 
bool replace (const qchar *what, const qchar *with)
 Replace all occurrences of 'what' with 'with'. More...
 
size_t find (const _qstring &str, size_t pos=0) const
 Same as find(const qchar *, size_t), but takes a qstring parameter.
 
size_t find (qchar c, size_t pos=0) const
 Find a character in the qstring. More...
 
size_t rfind (qchar c, size_t pos=0) const
 Search backwards for a character in the qstring. More...
 
_qstring< qchar > substr (size_t pos=0, size_t n=npos) const
 Get a substring. More...
 
_qstringremove (size_t idx, size_t cnt)
 Remove characters from the qstring. More...
 
_qstringinsert (size_t idx, qchar c)
 Insert a character into the qstring. More...
 
_qstringinsert (size_t idx, const qchar *str, size_t addlen)
 Insert a string into the qstring. More...
 
_qstringinsert (size_t idx, const qchar *str)
 Same as insert(size_t, const qchar *, size_t), but all chars in str are inserted.
 
_qstringinsert (size_t idx, const _qstring &qstr)
 Same as insert(size_t, const qchar *), but takes a qstring parameter.
 
_qstringinsert (qchar c)
 Prepend the qstring with 'c'.
 
_qstringinsert (const qchar *str)
 Prepend the qstring with 'str'.
 
_qstringinsert (const _qstring &qstr)
 Prepend the qstring with 'qstr'.
 
_qstringappend (qchar c)
 Append c to the end of the qstring.
 
_qstringappend (const qchar *str, size_t addlen)
 Append a string to the qstring. More...
 
_qstringappend (const qchar *str)
 Same as append(const qchar *, size_t), but all chars in 'str' are appended.
 
_qstringappend (const _qstring &qstr)
 Same as append(const qchar *), but takes a qstring argument.
 
_qstringcat_vsprnt (const char *format, va_list va)
 Append result of qvsnprintf() to qstring.
 
_qstringvsprnt (const char *format, va_list va)
 Replace qstring with the result of qvsnprintf()
 
_qstringcat_sprnt (const char *format,...)
 Append result of qsnprintf() to qstring.
 
_qstringsprnt (const char *format,...)
 Replace qstring with the result of qsnprintf()
 
 GCC_DIAG_OFF (format-nonliteral)
 Replace qstring with the result of qsnprintf() More...
 
_qstringnowarn_sprnt (const char *format,...)
 
 GCC_DIAG_ON (format-nonliteral)
 
_qstringfill (size_t pos, qchar c, size_t len)
 Fill qstring with a character. More...
 
_qstringfill (qchar c, size_t len)
 Clear contents of qstring and fill with 'c'.
 
_qstringltrim (qchar blank= ' ')
 Remove all instances of the specified char from the beginning of the qstring.
 
_qstringrtrim (qchar blank= ' ')
 Remove all instances of the specified char from the end of the qstring.
 
_qstringtrim2 (qchar blank= ' ')
 Remove all instances of the specified char from both ends of the qstring.
 

Public Types

typedef qchar * iterator
 
typedef const qchar * const_iterator
 

Member Function Documentation

template<class qchar>
void _qstring< qchar >::resize ( size_t  s,
qchar  c 
)
inline

Resize to the given size.

The resulting qstring will have length() = s, and size() = s+1
if 's' is greater than the current size then the extra space is filled with 'c'.
if 's' is less than the current size then the trailing chars are removed

template<class qchar>
void _qstring< qchar >::inject ( qchar *  s,
size_t  len 
)
inline

Assign this qstring to an existing char *.

See qvector::inject(T *, size_t)

template<class qchar>
size_t _qstring< qchar >::find ( const qchar *  str,
size_t  pos = 0 
) const
inline

Find a substring.

Parameters
strthe substring to look for
posstarting position
Returns
the position of the beginning of the first occurrence of str, _qstring::npos of none exists
template<class qchar>
bool _qstring< qchar >::replace ( const qchar *  what,
const qchar *  with 
)
inline

Replace all occurrences of 'what' with 'with'.

Returns
false if 'what' is not found in the qstring, true otherwise
template<class qchar>
size_t _qstring< qchar >::find ( qchar  c,
size_t  pos = 0 
) const
inline

Find a character in the qstring.

Parameters
cthe character to look for
posstarting position
Returns
index of first occurrence of 'c' if c is found, _qstring::npos otherwise
template<class qchar>
size_t _qstring< qchar >::rfind ( qchar  c,
size_t  pos = 0 
) const
inline

Search backwards for a character in the qstring.

Parameters
cthe char to look for
posstarting position
Returns
index of first occurrence of 'c' if c is found, _qstring::npos otherwise
template<class qchar>
_qstring<qchar> _qstring< qchar >::substr ( size_t  pos = 0,
size_t  n = npos 
) const
inline

Get a substring.

Parameters
posstarting position
nending position (non-inclusive)
Returns
the resulting substring
template<class qchar>
_qstring& _qstring< qchar >::remove ( size_t  idx,
size_t  cnt 
)
inline

Remove characters from the qstring.

Parameters
idxstarting position
cntnumber of characters to remove
template<class qchar>
_qstring& _qstring< qchar >::insert ( size_t  idx,
qchar  c 
)
inline

Insert a character into the qstring.

Parameters
idxposition of insertion (if idx >= length(), the effect is the same as append)
cchar to insert
template<class qchar>
_qstring& _qstring< qchar >::insert ( size_t  idx,
const qchar *  str,
size_t  addlen 
)
inline

Insert a string into the qstring.

Parameters
idxposition of insertion (if idx >= length(), the effect is the same as append)
strthe string to insert
addlennumber of chars from 'str' to insert
template<class qchar>
_qstring& _qstring< qchar >::append ( const qchar *  str,
size_t  addlen 
)
inline

Append a string to the qstring.

Parameters
strthe string to append
addlennumber of characters from 'str' to append
template<class qchar>
_qstring< qchar >::GCC_DIAG_OFF ( format-  nonliteral)

Replace qstring with the result of qsnprintf()

See also
inline int nowarn_qsnprintf(char *buf, size_t size, const char *format, ...)
template<class qchar>
_qstring& _qstring< qchar >::fill ( size_t  pos,
qchar  c,
size_t  len 
)
inline

Fill qstring with a character.

The qstring is resized if necessary until 'len' chars have been filled

Parameters
posstarting position
cthe character to fill
lennumber of positions to fill with 'c'

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