IDA SDK

- Main Page
- Header Files
- Classes
- Modules

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

## 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)
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)
_qstring & | operator= (const qchar *str)
| Allow assignment of qstrings using '='.
_qstring & | operator+= (qchar c)
| Append a char using '+='.
_qstring & | operator+= (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...
_qstring & | remove (size_t idx, size_t cnt)
| Remove characters from the qstring. More...
_qstring & | insert (size_t idx, qchar c)
| Insert a character into the qstring. More...
_qstring & | insert (size_t idx, const qchar *str, size_t addlen)
| Insert a string into the qstring. More...
_qstring & | insert (size_t idx, const qchar *str)
| Same as insert(size_t, const qchar *, size_t), but all chars in str are inserted.
_qstring & | insert (size_t idx, const _qstring &qstr)
| Same as insert(size_t, const qchar *), but takes a qstring parameter.
_qstring & | insert (qchar c)
| Prepend the qstring with 'c'.
_qstring & | insert (const qchar *str)
| Prepend the qstring with 'str'.
_qstring & | insert (const _qstring &qstr)
| Prepend the qstring with 'qstr'.
_qstring & | append (qchar c)
| Append c to the end of the qstring.
_qstring & | append (const qchar *str, size_t addlen)
| Append a string to the qstring. More...
_qstring & | append (const qchar *str)
| Same as append(const qchar *, size_t), but all chars in 'str' are appended.
_qstring & | append (const _qstring &qstr)
| Same as append(const qchar *), but takes a qstring argument.
_qstring & | cat_vsprnt (const char *format, va_list va)
| Append result of qvsnprintf() to qstring.
_qstring & | vsprnt (const char *format, va_list va)
| Replace qstring with the result of qvsnprintf()
_qstring & | cat_sprnt (const char *format,...)
| Append result of qsnprintf() to qstring.
_qstring & | sprnt (const char *format,...)
| Replace qstring with the result of qsnprintf()
_qstring & | fill (size_t pos, qchar c, size_t len)
| Fill qstring with a character. More...
_qstring & | fill (qchar c, size_t len)
| Clear contents of qstring and fill with 'c'.
_qstring & | ltrim (qchar blank= ' ')
| Remove all instances of the specified char from the beginning of the qstring.
_qstring & | rtrim (qchar blank= ' ')
| Remove all instances of the specified char from the end of the qstring.
_qstring & | trim2 (qchar blank= ' ')
| Remove all instances of the specified char from both ends of the qstring.

## Public Types
enum | { npos = -1 }
| Invalid position.
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

  str | the substring to look for
  pos | starting position

Returns
  the position of the beginning of the first occurrence of str, -1 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

  c | the character to look for
  pos | starting position

Returns
  index of first occurrence of 'c' if c is found, -1 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

  c | the char to look for
  pos | starting position

Returns
  index of first occurrence of 'c' if c is found, -1 otherwise

template<class qchar>

_qstring<qchar> _qstring< qchar >::substr | ( | size_t | pos = `0`,
|  | size_t | n = `npos`
| ) |  | const
| inline

Get a substring.

Parameters

  pos | starting position
  n | ending 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

  idx | starting position
  cnt | number of characters to remove

template<class qchar>

_qstring& _qstring< qchar >::insert | ( | size_t | idx,
|  | qchar | c
| ) |  |
| inline

Insert a character into the qstring.

Parameters

  idx | position of insertion (if idx >= length(), the effect is the same as append)
  c | char 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

  idx | position of insertion (if idx >= length(), the effect is the same as append)
  str | the string to insert
  addlen | number 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

  str | the string to append
  addlen | number of characters from 'str' to append

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

  pos | starting position
  c | the character to fill
  len | number of positions to fill with 'c'

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

- pro.h