IDA C++ SDK 9.2
Loading...
Searching...
No Matches
_qstring< qchar > Class Template Reference

Reimplementation of the string class from STL. More...

#include <pro.h>

Public Types

using value_type = qchar
typedef qchar * iterator
typedef const qchar * const_iterator

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'.
 _qstring (size_t count, qchar ch)
 Constructor - constructs the string with 'count' copies of character 'ch'.
 _qstring (_qstring &&x)
 Move constructor.
 _qstring (const _qstring &r)
 Copy constructor (if not declared, move constructor causes it to be deleted)
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.
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= (_qstring &&x) noexcept
 Move assignment operator.
_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 '+'.
 DECLARE_COMPARISONS (_qstring)
bool operator== (const qchar *r) const
 Test equality of a qstring and a const char* using '=='.
bool operator!= (const qchar *r) const
 Test equality of a qstring and a const char* with '!='.
bool operator< (const qchar *r) const
 Compare two qstrings using '<'. see qstrcmp()
bool starts_with (const _qstring &str) const
 Does the string start with the specified prefix?
bool starts_with (const qchar *ptr, ssize_t len=-1) const
bool ends_with (const _qstring &str) const
 Does the string end with the specified suffix?
bool ends_with (const qchar *ptr, ssize_t len=-1) const
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 *.
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.
bool replace (const qchar *what, const qchar *with)
 Replace all occurrences of 'what' with 'with'.
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.
size_t rfind (qchar c, size_t pos=0) const
 Search backwards for a character in the qstring.
_qstring< qchar > substr (size_t pos=0, size_t n=npos) const
 Get a substring.
_qstringremove (size_t idx, size_t cnt)
 Remove characters from the qstring.
_qstringinsert (size_t idx, qchar c)
 Insert a character into the qstring.
_qstringinsert (size_t idx, const qchar *str, size_t addlen)
 Insert a string into the qstring.
_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.
_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.
 AS_PRINTF (2, 0) _qstring &cat_vsprnt(const char *format
 Append result of qvsnprintf() to qstring.
 va_copy (copy, va)
 if (add !=0)
 va_end (copy)
 AS_PRINTF (2, 0) _qstring &vsprnt(const char *format
 Replace qstring with the result of qvsnprintf()
 va_copy (copy, va)
body clear ()
 if (add !=0)
 va_end (copy)
 AS_PRINTF (2, 3) _qstring &cat_sprnt(const char *format
 Append result of qsnprintf() to qstring.
 va_start (va, format)
 cat_vsprnt (format, va)
 va_end (va)
 AS_PRINTF (2, 3) _qstring &sprnt(const char *format
 Replace qstring with the result of qsnprintf()
 va_start (va, format)
 vsprnt (format, va)
 va_end (va)
 GCC_DIAG_OFF (format-nonliteral)
 Replace qstring with the result of qsnprintf()
_qstringnowarn_sprnt (const char *format,...)
 GCC_DIAG_ON (format-nonliteral)
_qstringfill (size_t pos, qchar c, size_t len)
 Fill qstring with a character.
_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, size_t minlen=0)
 Remove all instances of the specified char from the end of the qstring.
_qstringrtrim ()
 Remove all whitespace from the end of the qstring.
_qstringtrim2 (qchar blank=' ')
 Remove all instances of the specified char from both ends of the qstring.
void push_back (qchar c)
void split (qvector< _qstring< qchar > > *out, const qchar *sep, uint32 flags=0) const
 Split a string on SEP, appending the parts to OUT.

Static Public Member Functions

static _qstring< qchar > join (const qvector< _qstring< qchar > > &parts, const qchar *sep)
 Join the provided parts into a single string with each element separated by SEP.

Public Attributes

va_list va
size_t add = ::qvsnprintf(nullptr, 0, format, va)
return * this

Static Public Attributes

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

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

Member Typedef Documentation

◆ value_type

template<class qchar>
using _qstring< qchar >::value_type = qchar

◆ iterator

template<class qchar>
typedef qchar* _qstring< qchar >::iterator

◆ const_iterator

template<class qchar>
typedef const qchar* _qstring< qchar >::const_iterator

Constructor & Destructor Documentation

◆ _qstring() [1/6]

template<class qchar>
_qstring< qchar >::_qstring ( void )
inline

Constructor.

◆ _qstring() [2/6]

template<class qchar>
_qstring< qchar >::_qstring ( const qchar * ptr)
inline

Constructor - creates a new qstring from an existing char *.

◆ _qstring() [3/6]

template<class qchar>
_qstring< qchar >::_qstring ( const qchar * ptr,
size_t len )
inline

Constructor - creates a new qstring using first 'len' chars from 'ptr'.

◆ _qstring() [4/6]

template<class qchar>
_qstring< qchar >::_qstring ( size_t count,
qchar ch )
inline

Constructor - constructs the string with 'count' copies of character 'ch'.

◆ _qstring() [5/6]

template<class qchar>
_qstring< qchar >::_qstring ( _qstring< qchar > && x)
inline

Move constructor.

◆ _qstring() [6/6]

template<class qchar>
_qstring< qchar >::_qstring ( const _qstring< qchar > & r)
inline

Copy constructor (if not declared, move constructor causes it to be deleted)

Member Function Documentation

◆ swap()

template<class qchar>
void _qstring< qchar >::swap ( _qstring< qchar > & r)
inline

Swap contents of two qstrings. see qvector::swap()

◆ length()

template<class qchar>
size_t _qstring< qchar >::length ( void ) const
inline

Get number of chars in this qstring (not including terminating zero)

◆ size()

template<class qchar>
size_t _qstring< qchar >::size ( void ) const
inline

Get number of chars in this qstring (including terminating zero)

◆ capacity()

template<class qchar>
size_t _qstring< qchar >::capacity ( void ) const
inline

Get number of chars this qstring can contain (including terminating zero)

◆ resize() [1/2]

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

◆ resize() [2/2]

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

Similar to resize(size_t, qchar) - but any extra space is filled with zeroes.

◆ remove_last()

template<class qchar>
void _qstring< qchar >::remove_last ( int cnt = 1)
inline

◆ reserve()

template<class qchar>
void _qstring< qchar >::reserve ( size_t cnt)
inline

Increase capacity the qstring. see qvector::reserve()

◆ clear() [1/2]

template<class qchar>
void _qstring< qchar >::clear ( void )
inline

Clear qstring and free memory.

◆ qclear()

template<class qchar>
void _qstring< qchar >::qclear ( void )
inline

Clear qstring but do not free memory yet.

◆ empty()

template<class qchar>
bool _qstring< qchar >::empty ( void ) const
inline

Does the qstring have 0 non-null elements?

◆ c_str()

template<class qchar>
const qchar * _qstring< qchar >::c_str ( void ) const
inline

Convert the qstring to a char *.

◆ begin() [1/2]

template<class qchar>
iterator _qstring< qchar >::begin ( void )
inline

Get a pointer to the beginning of the qstring.

◆ begin() [2/2]

template<class qchar>
const_iterator _qstring< qchar >::begin ( void ) const
inline

Get a const pointer to the beginning of the qstring.

◆ end() [1/2]

template<class qchar>
iterator _qstring< qchar >::end ( void )
inline

Get a pointer to the end of the qstring (this is not the terminating zero)

◆ end() [2/2]

template<class qchar>
const_iterator _qstring< qchar >::end ( void ) const
inline

Get a const pointer to the end of the qstring (this is not the terminating zero)

◆ operator=() [1/3]

template<class qchar>
_qstring & _qstring< qchar >::operator= ( const qchar * str)
inline

Allow assignment of qstrings using '='.

◆ operator=() [2/3]

template<class qchar>
_qstring & _qstring< qchar >::operator= ( const _qstring< qchar > & qstr)
inline

◆ operator=() [3/3]

template<class qchar>
_qstring & _qstring< qchar >::operator= ( _qstring< qchar > && x)
inlinenoexcept

Move assignment operator.

◆ operator+=() [1/2]

template<class qchar>
_qstring & _qstring< qchar >::operator+= ( qchar c)
inline

Append a char using '+='.

◆ operator+=() [2/2]

template<class qchar>
_qstring & _qstring< qchar >::operator+= ( const _qstring< qchar > & r)
inline

Append another qstring using '+='.

◆ operator+()

template<class qchar>
_qstring _qstring< qchar >::operator+ ( const _qstring< qchar > & r) const
inline

Get result of appending two qstrings using '+'.

◆ DECLARE_COMPARISONS()

template<class qchar>
_qstring< qchar >::DECLARE_COMPARISONS ( _qstring< qchar > )
inline

◆ operator==()

template<class qchar>
bool _qstring< qchar >::operator== ( const qchar * r) const
inline

Test equality of a qstring and a const char* using '=='.

◆ operator!=()

template<class qchar>
bool _qstring< qchar >::operator!= ( const qchar * r) const
inline

Test equality of a qstring and a const char* with '!='.

◆ operator<()

template<class qchar>
bool _qstring< qchar >::operator< ( const qchar * r) const
inline

Compare two qstrings using '<'. see qstrcmp()

◆ starts_with() [1/2]

template<class qchar>
bool _qstring< qchar >::starts_with ( const _qstring< qchar > & str) const
inline

Does the string start with the specified prefix?

◆ starts_with() [2/2]

template<class qchar>
bool _qstring< qchar >::starts_with ( const qchar * ptr,
ssize_t len = -1 ) const
inline

◆ ends_with() [1/2]

template<class qchar>
bool _qstring< qchar >::ends_with ( const _qstring< qchar > & str) const
inline

Does the string end with the specified suffix?

◆ ends_with() [2/2]

template<class qchar>
bool _qstring< qchar >::ends_with ( const qchar * ptr,
ssize_t len = -1 ) const
inline

◆ operator[]() [1/2]

template<class qchar>
const qchar & _qstring< qchar >::operator[] ( size_t idx) const
inline

Retrieve char at index 'idx' using '[]'.

◆ operator[]() [2/2]

template<class qchar>
qchar & _qstring< qchar >::operator[] ( size_t idx)
inline

Retrieve char at index 'idx' using '[]'.

◆ at() [1/2]

template<class qchar>
const qchar & _qstring< qchar >::at ( size_t idx) const
inline

Retrieve const char at index 'idx'.

◆ at() [2/2]

template<class qchar>
qchar & _qstring< qchar >::at ( size_t idx)
inline

Retrieve char at index 'idx'.

◆ extract()

template<class qchar>
qchar * _qstring< qchar >::extract ( void )
inline

Extract C string from _qstring. Must qfree() it.

◆ inject() [1/2]

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)

◆ inject() [2/2]

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

Same as to inject(qchar *, size_t), with len = strlen(s)

◆ last()

template<class qchar>
qchar _qstring< qchar >::last ( void ) const
inline

Get the last qchar in the string (for concatenation checks)

◆ find() [1/3]

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

◆ replace()

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

◆ find() [2/3]

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

Same as find(const qchar *, size_t), but takes a qstring parameter.

◆ find() [3/3]

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

◆ rfind()

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

◆ substr()

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

◆ remove()

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

◆ insert() [1/7]

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

◆ insert() [2/7]

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

◆ insert() [3/7]

template<class qchar>
_qstring & _qstring< qchar >::insert ( size_t idx,
const qchar * str )
inline

Same as insert(size_t, const qchar *, size_t), but all chars in str are inserted.

◆ insert() [4/7]

template<class qchar>
_qstring & _qstring< qchar >::insert ( size_t idx,
const _qstring< qchar > & qstr )
inline

Same as insert(size_t, const qchar *), but takes a qstring parameter.

◆ insert() [5/7]

template<class qchar>
_qstring & _qstring< qchar >::insert ( qchar c)
inline

Prepend the qstring with 'c'.

◆ insert() [6/7]

template<class qchar>
_qstring & _qstring< qchar >::insert ( const qchar * str)
inline

Prepend the qstring with 'str'.

◆ insert() [7/7]

template<class qchar>
_qstring & _qstring< qchar >::insert ( const _qstring< qchar > & qstr)
inline

Prepend the qstring with 'qstr'.

◆ append() [1/4]

template<class qchar>
_qstring & _qstring< qchar >::append ( qchar c)
inline

Append c to the end of the qstring.

◆ append() [2/4]

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

◆ append() [3/4]

template<class qchar>
_qstring & _qstring< qchar >::append ( const qchar * str)
inline

Same as append(const qchar *, size_t), but all chars in 'str' are appended.

◆ append() [4/4]

template<class qchar>
_qstring & _qstring< qchar >::append ( const _qstring< qchar > & qstr)
inline

Same as append(const qchar *), but takes a qstring argument.

◆ AS_PRINTF() [1/4]

template<class qchar>
_qstring< qchar >::AS_PRINTF ( 2 ,
0  ) const &

Append result of qvsnprintf() to qstring.

◆ va_copy() [1/2]

template<class qchar>
_qstring< qchar >::va_copy ( copy ,
va  )

◆ if() [1/2]

template<class qchar>
_qstring< qchar >::if ( add ! = 0)
inline

◆ va_end() [1/4]

template<class qchar>
_qstring< qchar >::va_end ( copy )

◆ AS_PRINTF() [2/4]

template<class qchar>
_qstring< qchar >::AS_PRINTF ( 2 ,
0  ) const &

Replace qstring with the result of qvsnprintf()

◆ va_copy() [2/2]

template<class qchar>
_qstring< qchar >::va_copy ( copy ,
va  )

◆ clear() [2/2]

template<class qchar>
body _qstring< qchar >::clear ( )

◆ if() [2/2]

template<class qchar>
_qstring< qchar >::if ( add ! = 0)
inline

◆ va_end() [2/4]

template<class qchar>
_qstring< qchar >::va_end ( copy )

◆ AS_PRINTF() [3/4]

template<class qchar>
_qstring< qchar >::AS_PRINTF ( 2 ,
3  ) const &

Append result of qsnprintf() to qstring.

◆ va_start() [1/2]

template<class qchar>
_qstring< qchar >::va_start ( va ,
format  )

◆ cat_vsprnt()

template<class qchar>
_qstring< qchar >::cat_vsprnt ( format ,
va  )

◆ va_end() [3/4]

template<class qchar>
_qstring< qchar >::va_end ( va )

◆ AS_PRINTF() [4/4]

template<class qchar>
_qstring< qchar >::AS_PRINTF ( 2 ,
3  ) const &

Replace qstring with the result of qsnprintf()

◆ va_start() [2/2]

template<class qchar>
_qstring< qchar >::va_start ( va ,
format  )

◆ vsprnt()

template<class qchar>
_qstring< qchar >::vsprnt ( format ,
va  )

◆ va_end() [4/4]

template<class qchar>
_qstring< qchar >::va_end ( va )

◆ GCC_DIAG_OFF()

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, ...)

◆ nowarn_sprnt()

template<class qchar>
_qstring & _qstring< qchar >::nowarn_sprnt ( const char * format,
... )
inline

◆ GCC_DIAG_ON()

template<class qchar>
_qstring< qchar >::GCC_DIAG_ON ( format- nonliteral)

◆ fill() [1/2]

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'

◆ fill() [2/2]

template<class qchar>
_qstring & _qstring< qchar >::fill ( qchar c,
size_t len )
inline

Clear contents of qstring and fill with 'c'.

◆ ltrim()

template<class qchar>
_qstring & _qstring< qchar >::ltrim ( qchar blank = ' ')
inline

Remove all instances of the specified char from the beginning of the qstring.

◆ rtrim() [1/2]

template<class qchar>
_qstring & _qstring< qchar >::rtrim ( qchar blank,
size_t minlen = 0 )
inline

Remove all instances of the specified char from the end of the qstring.

◆ rtrim() [2/2]

template<class qchar>
_qstring & _qstring< qchar >::rtrim ( )
inline

Remove all whitespace from the end of the qstring.

◆ trim2()

template<class qchar>
_qstring & _qstring< qchar >::trim2 ( qchar blank = ' ')
inline

Remove all instances of the specified char from both ends of the qstring.

◆ push_back()

template<class qchar>
void _qstring< qchar >::push_back ( qchar c)
inline

◆ split()

template<class qchar>
void _qstring< qchar >::split ( qvector< _qstring< qchar > > * out,
const qchar * sep,
uint32 flags = 0 ) const

Split a string on SEP, appending the parts to OUT.

Parameters
outstorage
septhe separator to split on
flagsa combination of Flags for _qstring::split

◆ join()

template<class qchar>
_qstring< qchar > _qstring< qchar >::join ( const qvector< _qstring< qchar > > & parts,
const qchar * sep )
static

Join the provided parts into a single string with each element separated by SEP.

Parameters
partsthe parts to join
septhe separator to join on (it can be an empty string)
Returns
the combined string

Member Data Documentation

◆ va

template<class qchar>
va_list _qstring< qchar >::va
Initial value:
{
va_list copy

◆ add

template<class qchar>
size_t _qstring< qchar >::add = ::qvsnprintf(nullptr, 0, format, va)

◆ this

template<class qchar>
return * _qstring< qchar >::this

◆ npos

template<class qchar>
size_t _qstring< qchar >::npos = (size_t) -1
staticconstexpr

Invalid position.


The documentation for this class was generated from the following file:
  • ida-sdk/src/include/pro.h