veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
altintegration::Blob< N > Struct Template Reference

Contiguous byte array of fixed size. More...

Detailed Description

template<size_t N>
struct altintegration::Blob< N >
Template Parameters
N

Definition at line 25 of file blob.hpp.

#include <blob.hpp>

+ Inheritance diagram for altintegration::Blob< N >:
+ Collaboration diagram for altintegration::Blob< N >:

Public Types

using value_type = uint8_t
 
using storage_t = std::array< value_type, N >
 
using pointer = typename storage_t::pointer
 
using const_pointer = typename storage_t::const_pointer
 
using reference = typename storage_t::reference
 
using const_reference = typename storage_t::const_reference
 
using iterator = typename storage_t::iterator
 
using const_iterator = typename storage_t::const_iterator
 
using size_type = typename storage_t::size_type
 
using difference_type = typename storage_t::difference_type
 
using reverse_iterator = typename storage_t::reverse_iterator
 
using const_reverse_iterator = typename storage_t::const_reverse_iterator
 

Public Member Functions

 Blob (const std::initializer_list< uint8_t > &list)
 
 Blob (Slice< const uint8_t > slice)
 
 Blob (const std::vector< uint8_t > &v)
 
 Blob (const std::string &hex)
 
Blob< N > & operator= (const Slice< const uint8_t > slice)
 
Blob< N > & operator= (const std::vector< uint8_t > &vec)
 
Blob< N > reverse () const
 
Blob< N > & operator~ ()
 
std::vector< value_type > asVector () const
 
std::string asString () const
 
const value_type & operator[] (size_t index) noexcept
 
const value_type & operator[] (size_t index) const noexcept
 
int compareTo (const Blob< N > &b) const
 

Public Attributes

template<size_t M>
 data_ = other.data_
 
return * this
 

Friends

bool operator== (const Blob< N > &a, const Blob< N > &b)
 
bool operator!= (const Blob< N > &a, const Blob< N > &b)
 
bool operator> (const Blob< N > &a, const Blob< N > &b)
 
bool operator< (const Blob< N > &a, const Blob< N > &b)
 
bool operator>= (const Blob< N > &a, const Blob< N > &b)
 
bool operator<= (const Blob< N > &a, const Blob< N > &b)
 

Member Typedef Documentation

◆ const_iterator

template<size_t N>
using altintegration::Blob< N >::const_iterator = typename storage_t::const_iterator

Definition at line 33 of file blob.hpp.

◆ const_pointer

template<size_t N>
using altintegration::Blob< N >::const_pointer = typename storage_t::const_pointer

Definition at line 29 of file blob.hpp.

◆ const_reference

template<size_t N>
using altintegration::Blob< N >::const_reference = typename storage_t::const_reference

Definition at line 31 of file blob.hpp.

◆ const_reverse_iterator

template<size_t N>
using altintegration::Blob< N >::const_reverse_iterator = typename storage_t::const_reverse_iterator

Definition at line 37 of file blob.hpp.

◆ difference_type

template<size_t N>
using altintegration::Blob< N >::difference_type = typename storage_t::difference_type

Definition at line 35 of file blob.hpp.

◆ iterator

template<size_t N>
using altintegration::Blob< N >::iterator = typename storage_t::iterator

Definition at line 32 of file blob.hpp.

◆ pointer

template<size_t N>
using altintegration::Blob< N >::pointer = typename storage_t::pointer

Definition at line 28 of file blob.hpp.

◆ reference

template<size_t N>
using altintegration::Blob< N >::reference = typename storage_t::reference

Definition at line 30 of file blob.hpp.

◆ reverse_iterator

template<size_t N>
using altintegration::Blob< N >::reverse_iterator = typename storage_t::reverse_iterator

Definition at line 36 of file blob.hpp.

◆ size_type

template<size_t N>
using altintegration::Blob< N >::size_type = typename storage_t::size_type

Definition at line 34 of file blob.hpp.

◆ storage_t

template<size_t N>
using altintegration::Blob< N >::storage_t = std::array<value_type, N>

Definition at line 27 of file blob.hpp.

◆ value_type

template<size_t N>
using altintegration::Blob< N >::value_type = uint8_t

Definition at line 26 of file blob.hpp.

Constructor & Destructor Documentation

◆ Blob() [1/5]

template<size_t N>
altintegration::Blob< N >::Blob ( )
inline

Definition at line 39 of file blob.hpp.

39{ data_.fill(0); };

◆ Blob() [2/5]

template<size_t N>
altintegration::Blob< N >::Blob ( const std::initializer_list< uint8_t > &  list)
inline

Definition at line 41 of file blob.hpp.

41 {
42 data_.fill(0);
43 assign(list);
44 }

◆ Blob() [3/5]

template<size_t N>
altintegration::Blob< N >::Blob ( Slice< const uint8_t >  slice)
inline

Definition at line 46 of file blob.hpp.

46 {
47 data_.fill(0);
48 assign(slice);
49 }

◆ Blob() [4/5]

template<size_t N>
altintegration::Blob< N >::Blob ( const std::vector< uint8_t > &  v)
inline

Definition at line 50 of file blob.hpp.

50 {
51 data_.fill(0);
52 assign(v);
53 }

◆ Blob() [5/5]

template<size_t N>
altintegration::Blob< N >::Blob ( const std::string &  hex)
inlineexplicit

Definition at line 54 of file blob.hpp.

54 {
55 data_.fill(0);
56 auto data = ParseHex(hex);
57 assign(data);
58 }
std::vector< uint8_t > ParseHex(const char *psz)
Parse bytes from hex.

Member Function Documentation

◆ asString()

template<size_t N>
std::string altintegration::Blob< N >::asString ( ) const
inline

Definition at line 146 of file blob.hpp.

146 {
147 return std::string{data_.begin(), data_.end()};
148 }

◆ asVector()

template<size_t N>
std::vector< value_type > altintegration::Blob< N >::asVector ( ) const
inline

Definition at line 142 of file blob.hpp.

142 {
143 return std::vector<value_type>{data_.begin(), data_.end()};
144 }

◆ compareTo()

template<size_t N>
int altintegration::Blob< N >::compareTo ( const Blob< N > &  b) const
inline

Definition at line 159 of file blob.hpp.

159 {
160 for (int i = N - 1; i >= 0; i--) {
161 if (data_[i] < b.data_[i]) {
162 return -1;
163 }
164 if (data_[i] > b.data_[i]) {
165 return 1;
166 }
167 }
168 return 0;
169 }

◆ operator=() [1/2]

template<size_t N>
Blob< N > & altintegration::Blob< N >::operator= ( const Slice< const uint8_t >  slice)
inline

Definition at line 121 of file blob.hpp.

121 {
122 assign(slice);
123 return *this;
124 }

◆ operator=() [2/2]

template<size_t N>
Blob< N > & altintegration::Blob< N >::operator= ( const std::vector< uint8_t > &  vec)
inline

Definition at line 126 of file blob.hpp.

126 {
127 *this = Blob<N>(vec);
128 return *this;
129 }

◆ operator[]() [1/2]

template<size_t N>
const value_type & altintegration::Blob< N >::operator[] ( size_t  index) const
inlinenoexcept

Definition at line 154 of file blob.hpp.

154 {
155 VBK_ASSERT(index < N);
156 return data_[index];
157 }

◆ operator[]() [2/2]

template<size_t N>
const value_type & altintegration::Blob< N >::operator[] ( size_t  index)
inlinenoexcept

Definition at line 150 of file blob.hpp.

150 {
151 VBK_ASSERT(index < N);
152 return data_[index];
153 }

◆ operator~()

template<size_t N>
Blob< N > & altintegration::Blob< N >::operator~ ( )
inline

Definition at line 137 of file blob.hpp.

137 {
138 for (unsigned i = 0; i < N; ++i) data_[i] = ~data_[i];
139 return *this;
140 }

◆ reverse()

template<size_t N>
Blob< N > altintegration::Blob< N >::reverse ( ) const
inline

Definition at line 131 of file blob.hpp.

131 {
132 Blob<N> ret = *this;
133 std::reverse(ret.begin(), ret.end());
134 return ret;
135 }

Friends And Related Function Documentation

◆ operator!=

template<size_t N>
bool operator!= ( const Blob< N > &  a,
const Blob< N > &  b 
)
friend

Definition at line 174 of file blob.hpp.

174 {
175 return memcmp(a.data_.data(), b.data_.data(), a.size()) != 0;
176 }

◆ operator<

template<size_t N>
bool operator< ( const Blob< N > &  a,
const Blob< N > &  b 
)
friend

Definition at line 180 of file blob.hpp.

180 {
181 return a.compareTo(b) < 0;
182 }

◆ operator<=

template<size_t N>
bool operator<= ( const Blob< N > &  a,
const Blob< N > &  b 
)
friend

Definition at line 186 of file blob.hpp.

186 {
187 return a.compareTo(b) <= 0;
188 }

◆ operator==

template<size_t N>
bool operator== ( const Blob< N > &  a,
const Blob< N > &  b 
)
friend

Definition at line 171 of file blob.hpp.

171 {
172 return memcmp(a.data_.data(), b.data_.data(), a.size()) == 0;
173 }

◆ operator>

template<size_t N>
bool operator> ( const Blob< N > &  a,
const Blob< N > &  b 
)
friend

Definition at line 177 of file blob.hpp.

177 {
178 return a.compareTo(b) > 0;
179 }

◆ operator>=

template<size_t N>
bool operator>= ( const Blob< N > &  a,
const Blob< N > &  b 
)
friend

Definition at line 183 of file blob.hpp.

183 {
184 return a.compareTo(b) >= 0;
185 }

Member Data Documentation

◆ data_

template<size_t N>
template<size_t M>
altintegration::Blob< N >::data_ = other.data_

Definition at line 117 of file blob.hpp.

◆ this

template<size_t N>
return* altintegration::Blob< N >::this

Definition at line 118 of file blob.hpp.


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