sgns::base¶
Namespaces¶
| Name |
|---|
| sgns::base::detail |
Classes¶
| Name | |
|---|---|
| class | sgns::base::Blob |
| class | sgns::base::Buffer Class represents arbitrary (including empty) byte buffer. |
| struct | sgns::base::Wrapper Make strongly typed structures from different concepts of the equal types. E.g. block height and round number are both uint64_t, but better to be different types. Or, ID and Signature both vectors. |
Types¶
| Name | |
|---|---|
| enum class | BlobError |
| enum class | UnhexError { NOT_ENOUGH_INPUT = 1, NON_HEX_INPUT, VALUE_OUT_OF_RANGE, MISSING_0X_PREFIX, UNKNOWN} error codes for exceptions that may occur during unhexing |
| using Blob< 8 > | Hash64 |
| using Blob< 16 > | Hash128 |
| using Blob< 32 > | Hash256 |
| using Blob< 64 > | Hash512 |
| using std::shared_ptr< spdlog::logger > | Logger |
Functions¶
| Name | |
|---|---|
| template <class Stream ,size_t size,typename =std::enable_if_t Stream & |
operator<<(Stream & s, const Blob< size > & blob) scale-encodes blob instance to stream |
| template <class Stream ,size_t size,typename =std::enable_if_t Stream & |
operator>>(Stream & s, Blob< size > & blob) decodes blob instance from stream |
| template <size_t N> std::ostream & |
operator<<(std::ostream & os, const Blob< N > & blob) |
| std::ostream & | operator<<(std::ostream & os, const Buffer & buffer) |
| template <class Stream ,typename =std::enable_if_t Stream & |
operator<<(Stream & s, const Buffer & buffer) override operator<< for all streams except std::ostream |
| template <class Stream ,typename =std::enable_if_t Stream & |
operator>>(Stream & s, Buffer & buffer) decodes buffer object from stream |
| std::string | hex_upper(gsl::span< const uint8_t > bytes) Converts bytes to uppercase hex representation. |
| std::string | hex_lower(gsl::span< const uint8_t > bytes) Converts bytes to hex representation. |
| outcome::result< std::vector< uint8_t > > | unhex(std::string_view hex) Converts hex representation to bytes. |
| outcome::result< std::vector< uint8_t > > | unhexWith0x(std::string_view hex) Unhex hex-string with 0x in the begining. |
| Logger | createLogger(const std::string & tag, const std::string & basepath ="") Create a logger instance. |
| std::array< uint8_t, 8 > | uint64_t_to_bytes(uint64_t number) |
| uint64_t | bytes_to_uint64_t(gsl::span< uint8_t, 8 > bytes) |
| std::array< uint8_t, 16 > | uint128_t_to_bytes(const boost::multiprecision::uint128_t & i) |
| boost::multiprecision::uint128_t | bytes_to_uint128_t(gsl::span< uint8_t, 16 > bytes) |
| std::array< uint8_t, 32 > | uint256_t_to_bytes(const boost::multiprecision::uint256_t & i) |
| boost::multiprecision::uint256_t | bytes_to_uint256_t(gsl::span< uint8_t, 32 > bytes) |
| template <typename T ,typename =std::enable_if_t void |
raise(T t) throws outcome::result error as boost exception |
| template <typename T ,typename =std::enable_if_t<!std::is_enum_v void |
raise(const T & t) throws outcome::result error made of error as boost exception |
| template <typename T ,typename Tag ,typename =std::enable_if_t bool |
operator<(const Wrapper< T, Tag > & a, const Wrapper< T, Tag > & b) |
Types Documentation¶
enum BlobError¶
| Enumerator | Value | Description |
|---|---|---|
| INCORRECT_LENGTH | 1 |
Error codes for exceptions that may occur during blob initialization
enum UnhexError¶
| Enumerator | Value | Description |
|---|---|---|
| NOT_ENOUGH_INPUT | 1 | |
| NON_HEX_INPUT | ||
| VALUE_OUT_OF_RANGE | ||
| MISSING_0X_PREFIX | ||
| UNKNOWN |
error codes for exceptions that may occur during unhexing
using Hash64¶
using Hash128¶
using Hash256¶
using Hash512¶
using Logger¶
Functions Documentation¶
function operator<<¶
template <class Stream ,
size_t size,
typename =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
Stream & s,
const Blob< size > & blob
)
scale-encodes blob instance to stream
Parameters:
- s output stream reference
- blob value to encode
Template Parameters:
- Stream output stream type
- size blob size
Return: reference to stream
function operator>>¶
template <class Stream ,
size_t size,
typename =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
Stream & s,
Blob< size > & blob
)
decodes blob instance from stream
Parameters:
- s input stream reference
- blob value to encode
Template Parameters:
- Stream output stream type
- size blob size
Return: reference to stream
function operator<<¶
function operator<<¶
function operator<<¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
Stream & s,
const Buffer & buffer
)
override operator<< for all streams except std::ostream
Parameters:
- s stream reference
- buffer value to encode
Template Parameters:
- Stream stream type
Return: reference to stream
function operator>>¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
Stream & s,
Buffer & buffer
)
decodes buffer object from stream
Parameters:
- s stream reference
- buffer value to decode
Template Parameters:
- Stream input stream type
Return: reference to stream
function hex_upper¶
Converts bytes to uppercase hex representation.
Parameters:
- bytes input bytes
Return: hexstring
function hex_lower¶
Converts bytes to hex representation.
Parameters:
- bytes input bytes
Return: hexstring
function unhex¶
Converts hex representation to bytes.
Parameters:
- hex hex string input
Return: result containing array of bytes if input string is hex encoded and has even length
Note: reads both uppercase and lowercase hexstrings
function unhexWith0x¶
Unhex hex-string with 0x in the begining.
Parameters:
- hex hex string with 0x in the beginning
Return: unhexed buffer
function createLogger¶
Create a logger instance.
Parameters:
- tag Tagging name for identifying logger.
- basepath Optional base path for log output (platform dependent).
Return: Logger object.
function uint64_t_to_bytes¶
function bytes_to_uint64_t¶
function uint128_t_to_bytes¶
function bytes_to_uint128_t¶
function uint256_t_to_bytes¶
function bytes_to_uint256_t¶
function raise¶
throws outcome::result error as boost exception
Parameters:
- t error value
Template Parameters:
- T enum error type, only outcome::result enums are allowed
function raise¶
throws outcome::result error made of error as boost exception
Parameters:
- t outcome error value
Template Parameters:
- T outcome error type
function operator<¶
template <typename T ,
typename Tag ,
typename =std::enable_if_t<std::is_arithmetic_v<T>>>
bool operator<(
const Wrapper< T, Tag > & a,
const Wrapper< T, Tag > & b
)
Updated on 2026-03-04 at 13:10:43 -0800