PcapPlusPlus
24.09
|
#include <PointerVector.h>
Public Types | |
using | VectorIterator = typename std::vector< T * >::iterator |
using | ConstVectorIterator = typename std::vector< T * >::const_iterator |
Public Member Functions | |
PointerVector () | |
PointerVector (const PointerVector &other) | |
PointerVector (PointerVector &&other) noexcept | |
~PointerVector () | |
PointerVector & | operator= (const PointerVector &other) |
PointerVector & | operator= (PointerVector &&other) noexcept |
void | clear () |
void | pushBack (std::nullptr_t element, bool freeElementOnError=true)=delete |
void | pushBack (T *element, bool freeElementOnError=true) |
void | pushBack (std::unique_ptr< T > element) |
VectorIterator | begin () |
ConstVectorIterator | begin () const |
VectorIterator | end () |
ConstVectorIterator | end () const |
size_t | size () const |
T * | front () |
T const * | front () const |
T * | back () |
VectorIterator | erase (VectorIterator position) |
T * | getAndRemoveFromVector (VectorIterator &position) |
std::unique_ptr< T > | getAndDetach (size_t index) |
std::unique_ptr< T > | getAndDetach (VectorIterator &position) |
std::unique_ptr< T > | getAndDetach (VectorIterator const &position) |
T * | at (int index) |
const T * | at (int index) const |
A template class for representing a std::vector of pointers. Once (a pointer to) an element is added to this vector, the element responsibility moves to the vector, meaning the PointerVector will free the object once it's removed from the vector This class wraps std::vector and adds the capability of freeing objects once they're removed from it
using pcpp::PointerVector< T >::ConstVectorIterator = typename std::vector<T*>::const_iterator |
Const iterator object that is used for iterating all elements in a constant vector
using pcpp::PointerVector< T >::VectorIterator = typename std::vector<T*>::iterator |
Iterator object that is used for iterating all elements in the vector
|
inline |
A constructor that create an empty instance of this object
|
inline |
Copies the vector along with all elements inside it. All elements inside the copied vector are duplicates and the originals remain unchanged.
[in] | other | The vector to copy from. |
|
inlinenoexcept |
Move constructor. All elements along with their ownership is transferred to the new vector.
[in] | other | The vector to move from. |
|
inline |
A destructor for this class. The destructor frees all elements that are binded to the vector
|
inline |
Return a pointer to the element in a certain index
[in] | index | The index to retrieve the element from |
|
inline |
Return a const pointer to the element in a certain index
[in] | index | The index to retrieve the element from |
|
inline |
|
inline |
Get the first element of the vector
|
inline |
Get the first element of a constant vector
|
inline |
Clears all elements of the vector while freeing them
|
inline |
Get the last element of the vector
|
inline |
Get the last element of a constant vector
|
inline |
Removes from the vector a single element (position). Once the element is erased, it's also freed
[in] | position | The position of the element to erase |
|
inline |
|
inline |
|
inline |
Removes an element from the vector and transfers ownership to the returned unique pointer.
[in] | index | The index of the element to detach. |
|
inline |
Removes an element from the vector and transfers ownership to the returned unique pointer.
[in,out] | position | An iterator pointing to the element to detach. The iterator is shifted to the following element after the detach completes. |
|
inline |
Removes an element from the vector and transfers ownership to the returned unique pointer.
[in] | position | An iterator pointing to the element to detach. |
|
inline |
Remove an element from the vector without freeing it
[in,out] | position | The position of the element to remove from the vector. The iterator is shifted to the following element after the removal is completed. |
|
inline |
A copy assignment operator. Replaces the contents with a copy of the contents of other. See copy constructor for more information on the specific copy procedure.
[in] | other | The vector to copy from. |
|
inlinenoexcept |
A move assignment operator. Replaces the contents with those of other via move semantics. The other vector is left empty.
[in] | other | The vector to move from. |
|
delete |
Adding a nullptr to the vector is not allowed.
|
inline |
Add a new element to the vector that has been managed by an unique pointer.
[in] | element | A unique pointer holding an element. |
std::invalid_argument | The provided pointer is a nullptr. |
|
inline |
Add a new (pointer to an) element to the vector
[in] | element | A pointer to an element to assume ownership of. |
[in] | freeElementOnError | If set to true, the element is freed if an exception is thrown during the push. |
std::invalid_argument | The provided pointer is a nullptr. |
|
inline |
Get number of elements in the vector