TARAXA
dev::vector_ref< _T > Class Template Reference

#include <vector_ref.h>

Collaboration diagram for dev::vector_ref< _T >:

Public Types

using value_type = _T
 
using element_type = _T
 
using mutable_value_type = typename std::conditional< std::is_const< _T >::value, typename std::remove_const< _T >::type, _T >::type
 

Public Member Functions

 vector_ref ()
 
 vector_ref (_T *_data, size_t _count)
 
 vector_ref (typename std::conditional< std::is_const< _T >::value, std::string const *, std::string * >::type _data)
 
 vector_ref (typename std::conditional< std::is_const< _T >::value, std::vector< typename std::remove_const< _T >::type > const *, std::vector< _T > * >::type _data)
 
 vector_ref (typename std::conditional< std::is_const< _T >::value, std::string const &, std::string & >::type _data)
 
 operator bool () const
 
bool contentsEqual (std::vector< mutable_value_type > const &_c) const
 
std::vector< mutable_value_typetoVector () const
 
std::vector< unsigned char > toBytes () const
 
std::string toString () const
 
template<class _T2 >
 operator vector_ref< _T2 > () const
 
 operator vector_ref< _T const > () const
 
_T * data () const
 
size_t count () const
 
size_t size () const
 
bool empty () const
 
vector_ref< _T > next () const
 
vector_ref< _T > cropped (size_t _begin, size_t _count) const
 
vector_ref< _T > cropped (size_t _begin) const
 
void retarget (_T *_d, size_t _s)
 
void retarget (std::vector< _T > const &_t)
 
template<class T >
bool overlapsWith (vector_ref< T > _t) const
 
void copyTo (vector_ref< typename std::remove_const< _T >::type > _t) const
 
void populate (vector_ref< typename std::remove_const< _T >::type > _t) const
 
void cleanse ()
 
_T * begin ()
 
_T * end ()
 
_T const * begin () const
 
_T const * end () const
 
_T & operator[] (size_t _i)
 
_T const & operator[] (size_t _i) const
 
bool operator== (vector_ref< _T > const &_cmp) const
 
bool operator!= (vector_ref< _T > const &_cmp) const
 
void reset ()
 

Private Attributes

_T * m_data
 
size_t m_count
 

Detailed Description

template<class _T>
class dev::vector_ref< _T >

A modifiable reference to an existing object or vector in memory.

Member Typedef Documentation

◆ element_type

template<class _T >
using dev::vector_ref< _T >::element_type = _T

◆ mutable_value_type

template<class _T >
using dev::vector_ref< _T >::mutable_value_type = typename std::conditional<std::is_const<_T>::value, typename std::remove_const<_T>::type, _T>::type

◆ value_type

template<class _T >
using dev::vector_ref< _T >::value_type = _T

Constructor & Destructor Documentation

◆ vector_ref() [1/5]

template<class _T >
dev::vector_ref< _T >::vector_ref ( )
inline

◆ vector_ref() [2/5]

template<class _T >
dev::vector_ref< _T >::vector_ref ( _T *  _data,
size_t  _count 
)
inline

Creates a new vector_ref to point to _count elements starting at _data.

◆ vector_ref() [3/5]

template<class _T >
dev::vector_ref< _T >::vector_ref ( typename std::conditional< std::is_const< _T >::value, std::string const *, std::string * >::type  _data)
inline

Creates a new vector_ref pointing to the data part of a string (given as pointer).

◆ vector_ref() [4/5]

template<class _T >
dev::vector_ref< _T >::vector_ref ( typename std::conditional< std::is_const< _T >::value, std::vector< typename std::remove_const< _T >::type > const *, std::vector< _T > * >::type  _data)
inline

Creates a new vector_ref pointing to the data part of a vector (given as pointer).

◆ vector_ref() [5/5]

template<class _T >
dev::vector_ref< _T >::vector_ref ( typename std::conditional< std::is_const< _T >::value, std::string const &, std::string & >::type  _data)
inline

Creates a new vector_ref pointing to the data part of a string (given as reference).

Member Function Documentation

◆ begin() [1/2]

template<class _T >
_T* dev::vector_ref< _T >::begin ( )
inline

◆ begin() [2/2]

template<class _T >
_T const* dev::vector_ref< _T >::begin ( ) const
inline

◆ cleanse()

template<class _T >
void dev::vector_ref< _T >::cleanse ( )
inline

Securely overwrite the memory.

Note
adapted from OpenSSL's implementation.

◆ contentsEqual()

template<class _T >
bool dev::vector_ref< _T >::contentsEqual ( std::vector< mutable_value_type > const &  _c) const
inline

◆ copyTo()

template<class _T >
void dev::vector_ref< _T >::copyTo ( vector_ref< typename std::remove_const< _T >::type >  _t) const
inline

Copies the contents of this vector_ref to the contents of _t, up to the max size of _t.

◆ count()

template<class _T >
size_t dev::vector_ref< _T >::count ( ) const
inline
Returns
the number of elements referenced (not necessarily number of bytes).

◆ cropped() [1/2]

template<class _T >
vector_ref<_T> dev::vector_ref< _T >::cropped ( size_t  _begin) const
inline
Returns
a new vector_ref which is a shifted view of the original data (not going beyond it).

◆ cropped() [2/2]

template<class _T >
vector_ref<_T> dev::vector_ref< _T >::cropped ( size_t  _begin,
size_t  _count 
) const
inline
Returns
a new vector_ref which is a shifted and shortened view of the original data. If this goes out of bounds in any way, returns an empty vector_ref. If _count is ~size_t(0), extends the view to the end of the data.

◆ data()

template<class _T >
_T* dev::vector_ref< _T >::data ( ) const
inline

◆ empty()

template<class _T >
bool dev::vector_ref< _T >::empty ( ) const
inline

◆ end() [1/2]

template<class _T >
_T* dev::vector_ref< _T >::end ( )
inline

◆ end() [2/2]

template<class _T >
_T const* dev::vector_ref< _T >::end ( ) const
inline

◆ next()

template<class _T >
vector_ref<_T> dev::vector_ref< _T >::next ( ) const
inline
Returns
a new vector_ref pointing at the next chunk of size() elements.

◆ operator bool()

template<class _T >
dev::vector_ref< _T >::operator bool ( ) const
inlineexplicit

◆ operator vector_ref< _T const >()

template<class _T >
dev::vector_ref< _T >::operator vector_ref< _T const > ( ) const
inline

◆ operator vector_ref< _T2 >()

template<class _T >
template<class _T2 >
dev::vector_ref< _T >::operator vector_ref< _T2 > ( ) const
inlineexplicit

◆ operator!=()

template<class _T >
bool dev::vector_ref< _T >::operator!= ( vector_ref< _T > const &  _cmp) const
inline

◆ operator==()

template<class _T >
bool dev::vector_ref< _T >::operator== ( vector_ref< _T > const &  _cmp) const
inline

◆ operator[]() [1/2]

template<class _T >
_T& dev::vector_ref< _T >::operator[] ( size_t  _i)
inline

◆ operator[]() [2/2]

template<class _T >
_T const& dev::vector_ref< _T >::operator[] ( size_t  _i) const
inline

◆ overlapsWith()

template<class _T >
template<class T >
bool dev::vector_ref< _T >::overlapsWith ( vector_ref< T >  _t) const
inline

◆ populate()

template<class _T >
void dev::vector_ref< _T >::populate ( vector_ref< typename std::remove_const< _T >::type >  _t) const
inline

Copies the contents of this vector_ref to the contents of _t, and zeros further trailing elements in _t.

◆ reset()

template<class _T >
void dev::vector_ref< _T >::reset ( )
inline

◆ retarget() [1/2]

template<class _T >
void dev::vector_ref< _T >::retarget ( _T *  _d,
size_t  _s 
)
inline

◆ retarget() [2/2]

template<class _T >
void dev::vector_ref< _T >::retarget ( std::vector< _T > const &  _t)
inline

◆ size()

template<class _T >
size_t dev::vector_ref< _T >::size ( ) const
inline
Returns
the number of elements referenced (not necessarily number of bytes).

◆ toBytes()

template<class _T >
std::vector<unsigned char> dev::vector_ref< _T >::toBytes ( ) const
inline

◆ toString()

template<class _T >
std::string dev::vector_ref< _T >::toString ( ) const
inline

◆ toVector()

template<class _T >
std::vector<mutable_value_type> dev::vector_ref< _T >::toVector ( ) const
inline

Member Data Documentation

◆ m_count

template<class _T >
size_t dev::vector_ref< _T >::m_count
private

◆ m_data

template<class _T >
_T* dev::vector_ref< _T >::m_data
private

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