Kagome
Polkadot Runtime Engine in C++17
kagome::common::Blob< size_ > Class Template Reference

#include <blob.hpp>

Inheritance diagram for kagome::common::Blob< size_ >:
Collaboration diagram for kagome::common::Blob< size_ >:

Public Types

using const_narref = const byte_t(&)[size_]
 
using const_narptr = const byte_t(*)[size_]
 

Public Member Functions

 Blob ()
 
const_narref internal_array_reference () const
 
 Blob (const std::array< byte_t, size_ > &l)
 constructor enabling initializer list More...
 
virtual ~Blob ()=default
 
std::string toString () const noexcept
 
std::string toHex () const noexcept
 

Static Public Member Functions

static constexpr size_t size ()
 
static outcome::result< Blob< size_ > > fromString (std::string_view data)
 
static outcome::result< Blob< size_ > > fromHex (std::string_view hex)
 
static outcome::result< Blob< size_ > > fromHexWithPrefix (std::string_view hex)
 
static outcome::result< Blob< size_ > > fromSpan (const gsl::span< const uint8_t > &span)
 

Static Public Attributes

static constexpr bool is_static_collection = true
 

Detailed Description

template<size_t size_>
class kagome::common::Blob< size_ >

Base type which represents blob of fixed size.

std::string is convenient to use but it is not safe. We can not specify the fixed length for string.

For std::array it is possible, so we prefer it over std::string.

Definition at line 115 of file blob.hpp.

Member Typedef Documentation

template<size_t size_>
using kagome::common::Blob< size_ >::const_narptr = const byte_t (*)[size_]

Definition at line 121 of file blob.hpp.

template<size_t size_>
using kagome::common::Blob< size_ >::const_narref = const byte_t (&)[size_]

Definition at line 120 of file blob.hpp.

Constructor & Destructor Documentation

template<size_t size_>
kagome::common::Blob< size_ >::Blob ( )
inline

Initialize blob value

Definition at line 125 of file blob.hpp.

template<size_t size_>
kagome::common::Blob< size_ >::Blob ( const std::array< byte_t, size_ > &  l)
inlineexplicit

constructor enabling initializer list

Parameters
linitializer list

Definition at line 137 of file blob.hpp.

template<size_t size_>
virtual kagome::common::Blob< size_ >::~Blob ( )
virtualdefault

Member Function Documentation

template<size_t size_>
static outcome::result<Blob<size_> > kagome::common::Blob< size_ >::fromHex ( std::string_view  hex)
inlinestatic

Create Blob from hex string

Parameters
hexhex string
Returns
result containing Blob object if hex string has proper size and is in hex format

Definition at line 186 of file blob.hpp.

template<size_t size_>
static outcome::result<Blob<size_> > kagome::common::Blob< size_ >::fromHexWithPrefix ( std::string_view  hex)
inlinestatic

Create Blob from hex string prefixed with 0x

Parameters
hexhex string
Returns
result containing Blob object if hex string has proper size and is in hex format

Definition at line 197 of file blob.hpp.

template<size_t size_>
static outcome::result<Blob<size_> > kagome::common::Blob< size_ >::fromSpan ( const gsl::span< const uint8_t > &  span)
inlinestatic

Create Blob from span of uint8_t

Parameters
buffer
Returns

Definition at line 208 of file blob.hpp.

template<size_t size_>
static outcome::result<Blob<size_> > kagome::common::Blob< size_ >::fromString ( std::string_view  data)
inlinestatic

Create Blob from arbitrary string, putting its bytes into the blob

Parameters
dataarbitrary string containing
Returns
result containing Blob object if string has proper size

Definition at line 169 of file blob.hpp.

template<size_t size_>
const_narref kagome::common::Blob< size_ >::internal_array_reference ( ) const
inline

Definition at line 129 of file blob.hpp.

template<size_t size_>
static constexpr size_t kagome::common::Blob< size_ >::size ( )
inlinestatic

In compile-time returns size of current blob.

Definition at line 146 of file blob.hpp.

template<size_t size_>
std::string kagome::common::Blob< size_ >::toHex ( ) const
inlinenoexcept

Converts current blob to hex string.

Definition at line 160 of file blob.hpp.

template<size_t size_>
std::string kagome::common::Blob< size_ >::toString ( ) const
inlinenoexcept

Converts current blob to std::string

Definition at line 153 of file blob.hpp.

Member Data Documentation

template<size_t size_>
constexpr bool kagome::common::Blob< size_ >::is_static_collection = true
static

Definition at line 118 of file blob.hpp.


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