IDA C++ SDK 9.2
Loading...
Searching...
No Matches
qvector< T > Class Template Reference

Reimplementation of vector class from STL. More...

#include <pro.h>

Inheritance diagram for qvector< T >:
qstack< history_item_t > qstack< token_t > qstack< T >

Public Types

typedef T value_type
 the type of objects contained in this qvector
typedef T * iterator
typedef const T * const_iterator

Public Member Functions

 qvector (void)
 Constructor.
 qvector (const qvector< T > &x)
 Constructor - creates a new qvector identical to 'x'.
 qvector (qvector< T > &&x) noexcept
 Move constructor.
 ~qvector (void)
 Destructor.
 DEFINE_MEMORY_ALLOCATION_FUNCS () void push_back(const T &x)
 Append a new element to the end the qvector.
void push_back (T &&x)
 Append a new element to the end the qvector with a move semantics.
template<typename... Args>
void emplace_back (Args &&... args)
 Construct and append a new element to the end the qvector with a forwarding semantics.
T & push_back (void)
 Append a new empty element to the end of the qvector.
void pop_back (void)
 Remove the last element in the qvector.
size_t size (void) const
 Get the number of elements in the qvector.
bool empty (void) const
 Does the qvector have 0 elements?
const T & operator[] (size_t _idx) const
 Allows use of typical c-style array indexing for qvectors.
T & operator[] (size_t _idx)
 Allows use of typical c-style array indexing for qvectors.
const T & at (size_t _idx) const
 Get element at index '_idx'.
T & at (size_t _idx)
 Get element at index '_idx'.
const T & front (void) const
 Get the first element in the qvector.
T & front (void)
 Get the first element in the qvector.
const T & back (void) const
 Get the last element in the qvector.
T & back (void)
 Get the last element in the qvector.
void qclear (void)
 Destroy all elements but do not free memory.
void clear (void)
 Destroy all elements and free memory.
qvector< T > & operator= (const qvector< T > &x)
 Allow assignment of one qvector to another using '='.
qvector< T > & operator= (qvector< T > &&x) noexcept
 Move assignment operator.
void resize (size_t _newsize, const T &x)
 Resize to the given size.
void resize (size_t _newsize)
 Same as resize(size_t, const T &), but extra space is filled with empty elements.
void resize_noinit (size_t _newsize)
void grow (const T &x=T())
 Add an element to the end of the qvector, which will be a new T() if x is not given.
size_t capacity (void) const
 Get the number of elements that this qvector can contain - not the same as the number of elements currently in the qvector (size())
void reserve (size_t cnt)
 Increase the capacity of the qvector.
void truncate (void)
 Shrink the capacity down to the current number of elements.
void swap (qvector< T > &r) noexcept
 Replace all attributes of this qvector with that of 'r', and vice versa.
T * extract (void)
 Empty the qvector and return a pointer to it's contents.
void inject (T *s, size_t len)
 Populate the qvector with dynamic memory.
bool operator== (const qvector< T > &r) const
 Allow ability to test the equality of two qvectors using '=='.
bool operator!= (const qvector< T > &r) const
 Allow ability to test equality of two qvectors using '!='.
iterator begin (void)
 Get an iterator that points to the first element in the qvector.
iterator end (void)
 Get an iterator that points to the end of the qvector (NOT the last element)
const_iterator begin (void) const
 Get a const iterator that points to the first element in the qvector.
const_iterator end (void) const
 Get a const iterator that points to the end of the qvector (NOT the last element)
iterator insert (iterator it, const T &x)
 Insert an element into the qvector at a specified position.
iterator insert (iterator it, T &&x)
 Insert an element into the qvector with a move semantics.
template<class it2>
iterator insert (iterator it, it2 first, it2 last)
 Insert a several elements to the qvector at a specified position.
iterator erase (iterator it)
 Remove an element from the qvector.
iterator erase (iterator first, iterator last)
 Remove a subset of the qvector.
iterator find (const T &x)
 Find an element in the qvector.
const_iterator find (const T &x) const
 Find an element in the qvector.
ssize_t index (const T &x) const
 Find index of the specified value or return -1.
void add (const T &x)
 Add an element to the end of the qvector.
void add (T &&x)
bool has (const T &x) const
 Does the qvector contain x?
bool add_unique (const T &x)
 Add an element to the end of the qvector - only if it isn't already present.
bool del (const T &x)
 Find an element and remove it.
const char * dstr (void) const

Friends

void *ida_export qvector_reserve (void *vec, void *old, size_t cnt, size_t elsize)
 Change capacity of given qvector.

Detailed Description

template<class T>
class qvector< T >

Reimplementation of vector class from STL.

Only the most essential functions are implemented.
The vector container accepts objects agnostic to their positions in the memory because it will move them arbitrarily (realloc and memmove).
The reason why we have it is because it is not compiler dependent (hopefully) and therefore can be used in IDA API.

Member Typedef Documentation

◆ value_type

template<class T>
typedef T qvector< T >::value_type

the type of objects contained in this qvector

◆ iterator

template<class T>
typedef T* qvector< T >::iterator

◆ const_iterator

template<class T>
typedef const T* qvector< T >::const_iterator

Constructor & Destructor Documentation

◆ qvector() [1/3]

template<class T>
qvector< T >::qvector ( void )
inline

Constructor.

◆ qvector() [2/3]

template<class T>
qvector< T >::qvector ( const qvector< T > & x)
inline

Constructor - creates a new qvector identical to 'x'.

◆ qvector() [3/3]

template<class T>
qvector< T >::qvector ( qvector< T > && x)
inlinenoexcept

Move constructor.

◆ ~qvector()

template<class T>
qvector< T >::~qvector ( void )
inline

Destructor.

Member Function Documentation

◆ DEFINE_MEMORY_ALLOCATION_FUNCS()

template<class T>
qvector< T >::DEFINE_MEMORY_ALLOCATION_FUNCS ( ) const &
inline

Append a new element to the end the qvector.

◆ push_back() [1/2]

template<class T>
void qvector< T >::push_back ( T && x)
inline

Append a new element to the end the qvector with a move semantics.

◆ emplace_back()

template<class T>
template<typename... Args>
void qvector< T >::emplace_back ( Args &&... args)
inline

Construct and append a new element to the end the qvector with a forwarding semantics.

◆ push_back() [2/2]

template<class T>
T & qvector< T >::push_back ( void )
inline

Append a new empty element to the end of the qvector.

Returns
a reference to this new element

◆ pop_back()

template<class T>
void qvector< T >::pop_back ( void )
inline

Remove the last element in the qvector.

This helps to find use-after-frees in empty containers:

◆ size()

template<class T>
size_t qvector< T >::size ( void ) const
inline

Get the number of elements in the qvector.

◆ empty()

template<class T>
bool qvector< T >::empty ( void ) const
inline

Does the qvector have 0 elements?

◆ operator[]() [1/2]

template<class T>
const T & qvector< T >::operator[] ( size_t _idx) const
inline

Allows use of typical c-style array indexing for qvectors.

◆ operator[]() [2/2]

template<class T>
T & qvector< T >::operator[] ( size_t _idx)
inline

Allows use of typical c-style array indexing for qvectors.

◆ at() [1/2]

template<class T>
const T & qvector< T >::at ( size_t _idx) const
inline

Get element at index '_idx'.

◆ at() [2/2]

template<class T>
T & qvector< T >::at ( size_t _idx)
inline

Get element at index '_idx'.

◆ front() [1/2]

template<class T>
const T & qvector< T >::front ( void ) const
inline

Get the first element in the qvector.

◆ front() [2/2]

template<class T>
T & qvector< T >::front ( void )
inline

Get the first element in the qvector.

◆ back() [1/2]

template<class T>
const T & qvector< T >::back ( void ) const
inline

Get the last element in the qvector.

◆ back() [2/2]

template<class T>
T & qvector< T >::back ( void )
inline

Get the last element in the qvector.

◆ qclear()

template<class T>
void qvector< T >::qclear ( void )
inline

Destroy all elements but do not free memory.

◆ clear()

template<class T>
void qvector< T >::clear ( void )
inline

Destroy all elements and free memory.

◆ operator=() [1/2]

template<class T>
qvector< T > & qvector< T >::operator= ( const qvector< T > & x)
inline

Allow assignment of one qvector to another using '='.

◆ operator=() [2/2]

template<class T>
qvector< T > & qvector< T >::operator= ( qvector< T > && x)
inlinenoexcept

Move assignment operator.

◆ resize() [1/2]

template<class T>
void qvector< T >::resize ( size_t _newsize,
const T & x )
inline

Resize to the given size.

If the given size (_newsize) is less than the current size (n) of the qvector, then the last n - _newsize elements are simply deleted.
If the given size is greater than the current size, the qvector is grown to _newsize, and the last _newsize - n elements will be filled with copies of 'x'.
If the given size is equal to the current size, this function does nothing.

◆ resize() [2/2]

template<class T>
void qvector< T >::resize ( size_t _newsize)
inline

Same as resize(size_t, const T &), but extra space is filled with empty elements.

◆ resize_noinit()

template<class T>
void qvector< T >::resize_noinit ( size_t _newsize)
inline

◆ grow()

template<class T>
void qvector< T >::grow ( const T & x = T())
inline

Add an element to the end of the qvector, which will be a new T() if x is not given.

◆ capacity()

template<class T>
size_t qvector< T >::capacity ( void ) const
inline

Get the number of elements that this qvector can contain - not the same as the number of elements currently in the qvector (size())

◆ reserve()

template<class T>
void qvector< T >::reserve ( size_t cnt)
inline

Increase the capacity of the qvector.

If cnt is not greater than the current capacity this function does nothing.

◆ truncate()

template<class T>
void qvector< T >::truncate ( void )
inline

Shrink the capacity down to the current number of elements.

◆ swap()

template<class T>
void qvector< T >::swap ( qvector< T > & r)
inlinenoexcept

Replace all attributes of this qvector with that of 'r', and vice versa.

Effectively sets this = r and r = this without copying/allocating any memory.

◆ extract()

template<class T>
T * qvector< T >::extract ( void )
inline

Empty the qvector and return a pointer to it's contents.

The caller must free the result of this function

◆ inject()

template<class T>
void qvector< T >::inject ( T * s,
size_t len )
inline

Populate the qvector with dynamic memory.

The qvector must be empty before calling this method!

◆ operator==()

template<class T>
bool qvector< T >::operator== ( const qvector< T > & r) const
inline

Allow ability to test the equality of two qvectors using '=='.

◆ operator!=()

template<class T>
bool qvector< T >::operator!= ( const qvector< T > & r) const
inline

Allow ability to test equality of two qvectors using '!='.

◆ begin() [1/2]

template<class T>
iterator qvector< T >::begin ( void )
inline

Get an iterator that points to the first element in the qvector.

◆ end() [1/2]

template<class T>
iterator qvector< T >::end ( void )
inline

Get an iterator that points to the end of the qvector (NOT the last element)

◆ begin() [2/2]

template<class T>
const_iterator qvector< T >::begin ( void ) const
inline

Get a const iterator that points to the first element in the qvector.

◆ end() [2/2]

template<class T>
const_iterator qvector< T >::end ( void ) const
inline

Get a const iterator that points to the end of the qvector (NOT the last element)

◆ insert() [1/3]

template<class T>
iterator qvector< T >::insert ( iterator it,
const T & x )
inline

Insert an element into the qvector at a specified position.

Parameters
itan iterator that points to the desired position of the new element
xthe element to insert
Returns
an iterator that points to the newly inserted element

◆ insert() [2/3]

template<class T>
iterator qvector< T >::insert ( iterator it,
T && x )
inline

Insert an element into the qvector with a move semantics.

◆ insert() [3/3]

template<class T>
template<class it2>
iterator qvector< T >::insert ( iterator it,
it2 first,
it2 last )
inline

Insert a several elements to the qvector at a specified position.

Parameters
itposition at which new elements will be inserted
firstpointer to first element to be inserted
lastpointer to end of elements to be inserted (the element pointed to by 'last' will not be included)
Returns
an iterator that points to the first newly inserted element.

◆ erase() [1/2]

template<class T>
iterator qvector< T >::erase ( iterator it)
inline

Remove an element from the qvector.

Parameters
itpointer to element to be removed
Returns
pointer to the element that took its place

◆ erase() [2/2]

template<class T>
iterator qvector< T >::erase ( iterator first,
iterator last )
inline

Remove a subset of the qvector.

Parameters
firstpointer to head of subset to be removed
lastpointer to end of subset to be removed (element pointed to by last will not be removed)
Returns
a pointer to the element that took the place of 'first'

◆ find() [1/2]

template<class T>
iterator qvector< T >::find ( const T & x)
inline

Find an element in the qvector.

Parameters
xelement to find
Returns
an iterator that points to the first occurrence of 'x'

◆ find() [2/2]

template<class T>
const_iterator qvector< T >::find ( const T & x) const
inline

Find an element in the qvector.

Parameters
xelement to find
Returns
an iterator that points to the first occurrence of 'x'

◆ index()

template<class T>
ssize_t qvector< T >::index ( const T & x) const
inline

Find index of the specified value or return -1.

◆ add() [1/2]

template<class T>
void qvector< T >::add ( const T & x)
inline

Add an element to the end of the qvector.

◆ add() [2/2]

template<class T>
void qvector< T >::add ( T && x)
inline

◆ has()

template<class T>
bool qvector< T >::has ( const T & x) const
inline

Does the qvector contain x?

◆ add_unique()

template<class T>
bool qvector< T >::add_unique ( const T & x)
inline

Add an element to the end of the qvector - only if it isn't already present.

Parameters
xthe element to add
Returns
false if 'x' is already in the qvector, true otherwise

◆ del()

template<class T>
bool qvector< T >::del ( const T & x)
inline

Find an element and remove it.

Parameters
xthe element to remove
Returns
false if 'x' was not found, true otherwise

◆ dstr()

template<class T>
const char * qvector< T >::dstr ( void ) const

◆ qvector_reserve

template<class T>
void *ida_export qvector_reserve ( void * vec,
void * old,
size_t cnt,
size_t elsize )
friend

Change capacity of given qvector.

Parameters
veca pointer to a qvector
olda pointer to the qvector's array
cntnumber of elements to reserve
elsizesize of each element
Returns
a pointer to the newly allocated array

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