Ring Daemon 16.0.0
Loading...
Searching...
No Matches
dev::vector_ref< _T > Class Template Reference

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

#include <vector_ref.h>

Collaboration diagram for dev::vector_ref< _T >:
Collaboration graph

Public Types

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

Public Member Functions

_T * begin ()
 
_T const * begin () const
 
void cleanse ()
 Securely overwrite the memory.
 
bool contentsEqual (std::vector< mutable_value_type > const &_c) const
 
size_t count () const
 
vector_ref< _T > cropped (size_t _begin) const
 
vector_ref< _T > cropped (size_t _begin, size_t _count) const
 
_T * data () const
 
bool empty () const
 
_T * end ()
 
_T const * end () const
 
vector_ref< _T > next () const
 
 operator bool () const
 
 operator vector_ref< _T const > () const
 
template<class _T2 >
 operator vector_ref< _T2 > () const
 
bool operator!= (vector_ref< _T > const &_cmp) const
 
bool operator== (vector_ref< _T > const &_cmp) const
 
_T & operator[] (size_t _i)
 
_T const & operator[] (size_t _i) const
 
void reset ()
 
void retarget (_T *_d, size_t _s)
 
void retarget (std::vector< _T > const &_t)
 
size_t size () const
 
std::vector< unsigned char > toBytes () const
 
std::string toString () const
 
std::vector< mutable_value_typetoVector () const
 
 vector_ref ()
 
 vector_ref (_T *_data, size_t _count)
 Creates a new vector_ref to point to _count elements starting at _data.
 
 vector_ref (typename std::conditional< std::is_const< _T >::value, std::string const &, std::string & >::type _data)
 Creates a new vector_ref pointing to the data part of a string (given as reference).
 
 vector_ref (typename std::conditional< std::is_const< _T >::value, std::string const *, std::string * >::type _data)
 Creates a new vector_ref pointing to the data part of a string (given as pointer).
 
 vector_ref (typename std::conditional< std::is_const< _T >::value, std::vector< typename std::remove_const< _T >::type > const *, std::vector< _T > * >::type _data)
 Creates a new vector_ref pointing to the data part of a vector (given as pointer).
 

Detailed Description

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

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

Definition at line 20 of file vector_ref.h.

Member Typedef Documentation

◆ element_type

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

Definition at line 24 of file vector_ref.h.

◆ 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

Definition at line 25 of file vector_ref.h.

◆ value_type

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

Definition at line 23 of file vector_ref.h.

Constructor & Destructor Documentation

◆ vector_ref() [1/5]

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

Definition at line 31 of file vector_ref.h.

◆ 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.

Definition at line 36 of file vector_ref.h.

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

Definition at line 41 of file vector_ref.h.

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

Definition at line 48 of file vector_ref.h.

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

Definition at line 55 of file vector_ref.h.

Member Function Documentation

◆ begin() [1/2]

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

Definition at line 155 of file vector_ref.h.

Referenced by dev::vector_ref< _T >::cleanse().

◆ begin() [2/2]

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

Definition at line 157 of file vector_ref.h.

◆ cleanse()

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

Securely overwrite the memory.

Note
adapted from OpenSSL's implementation.

Definition at line 137 of file vector_ref.h.

References dev::vector_ref< _T >::begin(), dev::vector_ref< _T >::count(), and dev::vector_ref< _T >::end().

Referenced by dev::SecureFixedHash< T >::clear(), dev::SecureFixedHash< T >::operator=(), and dev::SecureFixedHash< T >::~SecureFixedHash().

Here is the call graph for this function:

◆ contentsEqual()

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

Definition at line 63 of file vector_ref.h.

◆ count()

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

Definition at line 95 of file vector_ref.h.

Referenced by dev::vector_ref< _T >::cleanse().

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

Definition at line 118 of file vector_ref.h.

◆ 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.

Definition at line 110 of file vector_ref.h.

◆ data()

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

Definition at line 93 of file vector_ref.h.

Referenced by dev::asString(), and dev::FixedHash< N >::FixedHash().

◆ empty()

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

Definition at line 98 of file vector_ref.h.

◆ end() [1/2]

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

Definition at line 156 of file vector_ref.h.

Referenced by dev::vector_ref< _T >::cleanse().

◆ end() [2/2]

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

Definition at line 158 of file vector_ref.h.

◆ 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.

Definition at line 100 of file vector_ref.h.

◆ operator bool()

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

Definition at line 61 of file vector_ref.h.

◆ operator vector_ref< _T const >()

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

Definition at line 91 of file vector_ref.h.

◆ operator vector_ref< _T2 >()

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

Definition at line 86 of file vector_ref.h.

◆ operator!=()

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

Definition at line 177 of file vector_ref.h.

References dev::vector_ref< _T >::operator==().

Here is the call graph for this function:

◆ operator==()

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

Definition at line 173 of file vector_ref.h.

Referenced by dev::vector_ref< _T >::operator!=().

◆ operator[]() [1/2]

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

Definition at line 160 of file vector_ref.h.

◆ operator[]() [2/2]

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

Definition at line 166 of file vector_ref.h.

◆ reset()

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

Definition at line 179 of file vector_ref.h.

◆ retarget() [1/2]

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

Definition at line 125 of file vector_ref.h.

◆ retarget() [2/2]

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

Definition at line 130 of file vector_ref.h.

◆ size()

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

Definition at line 97 of file vector_ref.h.

Referenced by dev::asNibbles(), dev::asString(), and dev::FixedHash< N >::FixedHash().

◆ toBytes()

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

Definition at line 74 of file vector_ref.h.

◆ toString()

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

Definition at line 80 of file vector_ref.h.

◆ toVector()

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

Definition at line 70 of file vector_ref.h.


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