9 #ifdef __INTEL_COMPILER 10 #pragma warning(disable:597) //will not be called for implicit or explicit conversions 27 static_assert(std::is_pod<value_type>::value,
"vector_ref can only be used with PODs due to its low-level treatment of data.");
33 vector_ref(
typename std::conditional<std::is_const<_T>::value, std::string
const*, std::string*>::
type _data):
m_data(reinterpret_cast<_T*>(_data->
data())),
m_count(_data->
size() / sizeof(_T)) {}
35 vector_ref(
typename std::conditional<std::is_const<_T>::value, std::vector<
typename std::remove_const<_T>::type>
const*, std::vector<_T>*>::
type _data):
m_data(_data->
data()),
m_count(_data->
size()) {}
37 vector_ref(
typename std::conditional<std::is_const<_T>::value, std::string
const&, std::string&>::
type _data):
m_data(reinterpret_cast<_T*>(_data.
data())),
m_count(_data.
size() / sizeof(_T)) {}
44 std::vector<mutable_value_type>
toVector()
const {
return std::vector<mutable_value_type>(
m_data, m_data +
m_count); }
45 std::vector<unsigned char>
toBytes()
const {
return std::vector<unsigned char>(
reinterpret_cast<unsigned char const*
>(
m_data), reinterpret_cast<unsigned char const*>(
m_data) +
m_count *
sizeof(_T)); }
76 static unsigned char s_cleanseCounter = 0;
77 uint8_t* p = (uint8_t*)
begin();
78 size_t const len = (uint8_t*)
end() - p;
80 size_t count = s_cleanseCounter;
83 *(p++) = (uint8_t)
count;
84 count += (17 + ((size_t)p & 0xf));
86 p = (uint8_t*)memchr((uint8_t*)
begin(), (uint8_t)count, len);
88 count += (63 + (size_t)p);
89 s_cleanseCounter = (uint8_t)count;
90 memset((uint8_t*)
begin(), 0, len);
105 operator ldb::Slice()
const {
return ldb::Slice((
char const*)
m_data,
m_count *
sizeof(_T)); }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
_T & operator[](size_t _i)
A modifiable reference to an existing object or vector in memory.
vector_ref< _T const > ref(_T const &_t)
void cleanse()
Securely overwrite the memory.
vector_ref(_T *_data, size_t _count)
Creates a new vector_ref to point to _count elements starting at _data.
assert(len-trim+(2 *lenIndices)<=WIDTH)
vector_ref< _T > cropped(size_t _begin) const
vector_ref< _T > cropped(size_t _begin, size_t _count) const
bool contentsEqual(std::vector< mutable_value_type > const &_c) const
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).
std::vector< mutable_value_type > toVector() const
bool operator==(vector_ref< _T > const &_cmp) const
void retarget(_T *_d, size_t _s)
std::vector< unsigned char > toBytes() const
vector_ref< _T > next() const
typename std::conditional< std::is_const< byte const >::value, typename std::remove_const< byte const >::type, byte const >::type mutable_value_type
void populate(vector_ref< typename std::remove_const< _T >::type > _t) const
Copies the contents of this vector_ref to the contents of _t, and zeros further trailing elements in ...
bool operator!=(vector_ref< _T > const &_cmp) const
bool overlapsWith(vector_ref< T > _t) const
PlatformStyle::TableColorType type
void retarget(std::vector< _T > const &_t)
void * memcpy(void *a, const void *b, size_t c)
void copyTo(vector_ref< typename std::remove_const< _T >::type > _t) const
Copies the contents of this vector_ref to the contents of _t, up to the max size of _t...
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).
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
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).
void * memmove(void *a, const void *b, size_t c)
std::string toString() const
_T const & operator[](size_t _i) const