Skip to content

sgns::scale

Namespaces

Name
sgns::scale::detail
sgns::scale::compact

Classes

Name
class sgns::scale::ScaleDecoderStream
class sgns::scale::ScaleEncoderStream
Scale-encodes data into a byte stream.

Types

Name
enum class EncodeError { COMPACT_INTEGER_TOO_BIG = 1, NEGATIVE_COMPACT_INTEGER, WRONG_CATEGORY, WRONG_ALTERNATIVE, DEREF_NULLPOINTER}
EncodeError enum provides error codes for Encode methods.
enum class DecodeError { NOT_ENOUGH_DATA = 1, UNEXPECTED_VALUE, TOO_MANY_ITEMS, WRONG_TYPE_INDEX, INVALID_DATA, OUT_OF_BOUNDARIES}
DecoderError enum provides codes of errors for Decoder methods.
enum class CommonError { UNKNOWN_ERROR = 1}
base errors
enum class uint8_t OptionalBool { NONE_ = 0u, FALSE_ = 1u, TRUE_ = 2u}
OptionalBool is internal extended bool type.
using std::vector< uint8_t > ByteArray
convenience alias for arrays of bytes
using boost::multiprecision::cpp_int CompactInteger
represents compact integer value

Functions

Name
template <typename... Args>
outcome::result< std::vector< uint8_t > >
encode(Args &&... args)
convenience function for encoding primitives data to stream
template <class T >
outcome::result< T >
decode(gsl::span< const uint8_t > span)
convenience function for decoding primitives data from stream

Types Documentation

enum EncodeError

Enumerator Value Description
COMPACT_INTEGER_TOO_BIG 1 compact integer can't be more than 2**536
NEGATIVE_COMPACT_INTEGER cannot compact-encode negative integers
WRONG_CATEGORY wrong compact category
WRONG_ALTERNATIVE wrong cast to alternative
DEREF_NULLPOINTER dereferencing a null pointer

EncodeError enum provides error codes for Encode methods.

enum DecodeError

Enumerator Value Description
NOT_ENOUGH_DATA 1 not enough data to decode value
UNEXPECTED_VALUE unexpected value
TOO_MANY_ITEMS too many items, cannot address them in memory
WRONG_TYPE_INDEX wrong type index, cannot decode variant
INVALID_DATA invalid data
OUT_OF_BOUNDARIES advance went out of boundaries

DecoderError enum provides codes of errors for Decoder methods.

enum CommonError

Enumerator Value Description
UNKNOWN_ERROR 1 unknown error

base errors

enum OptionalBool

Enumerator Value Description
NONE_ 0u
FALSE_ 1u
TRUE_ 2u

OptionalBool is internal extended bool type.

using ByteArray

using sgns::scale::ByteArray = std::vector<uint8_t>;

convenience alias for arrays of bytes

using CompactInteger

using sgns::scale::CompactInteger = boost::multiprecision::cpp_int;

represents compact integer value

Functions Documentation

function encode

template <typename... Args>
outcome::result< std::vector< uint8_t > > encode(
    Args &&... args
)

convenience function for encoding primitives data to stream

Parameters:

  • args data to encode

Template Parameters:

  • Args primitive types to be encoded

Return: encoded data

function decode

template <class T >
outcome::result< T > decode(
    gsl::span< const uint8_t > span
)

convenience function for decoding primitives data from stream

Parameters:

  • span of bytes with encoded data

Template Parameters:

  • T primitive type that is decoded from provided span

Return: decoded T


Updated on 2026-03-04 at 13:10:44 -0800