Skip to content

sgns::scale::ScaleEncoderStream

Scale-encodes data into a byte stream.

#include <scale_encoder_stream.hpp>

Public Functions

Name
std::vector< uint8_t > data() const
Getters.
template <class F ,class S >
ScaleEncoderStream &
operator<<(const std::pair< F, S > & p)
scale-encodes pair of values
template <class... Ts>
ScaleEncoderStream &
operator<<(const std::tuple< Ts... > & v)
scale-encodes tuple of values
template <class... T>
ScaleEncoderStream &
operator<<(const boost::variant< T... > & v)
scale-encodes variant value
template <class T >
ScaleEncoderStream &
operator<<(const std::shared_ptr< T > & v)
scale-encodes sharead_ptr value
template <class T >
ScaleEncoderStream &
operator<<(const std::unique_ptr< T > & v)
scale-encodes unique_ptr value
template <class T >
ScaleEncoderStream &
operator<<(const std::vector< T > & c)
scale-encodes collection of same time items
template <class T >
ScaleEncoderStream &
operator<<(const std::list< T > & c)
scale-encodes collection of same time items
template <class T >
ScaleEncoderStream &
operator<<(const boost::optional< T > & v)
scale-encodes optional value
template <class T >
ScaleEncoderStream &
operator<<(const gsl::span< T > & v)
appends sequence of bytes
template <typename T ,size_t size>
ScaleEncoderStream &
operator<<(const std::array< T, size > & a)
scale-encodes array of items
ScaleEncoderStream & operator<<(const boost::multiprecision::uint256_t & i)
scale-encodes uint256_t to stream
template <class T >
ScaleEncoderStream &
operator<<(const std::reference_wrapper< T > & v)
scale-encodes std::reference_wrapper of a type
ScaleEncoderStream & operator<<(std::string_view sv)
scale-encodes a string view
template <typename T ,typename I =std::decay_t,typename =std::enable_if_t>>
ScaleEncoderStream &
operator<<(T && v)
scale-encodes any integral type including bool
ScaleEncoderStream & operator<<(const CompactInteger & v)
scale-encodes CompactInteger value as compact integer

Protected Functions

Name
template <size_t I,class... Ts>
void
encodeElementOfTuple(const std::tuple< Ts... > & v)
template <uint8_t I,class... Ts>
void
tryEncodeAsOneOfVariant(const boost::variant< Ts... > & v)
template <class It >
ScaleEncoderStream &
encodeCollection(const CompactInteger & size, It && begin, It && end)
scale-encodes any collection
ScaleEncoderStream & putByte(uint8_t v)
Appenders.

Public Attributes

Name
auto is_encoder_stream

Public Functions Documentation

function data

std::vector< uint8_t > data() const

Getters.

Return: vector of bytes containing encoded data

function operator<<

template <class F ,
class S >
inline ScaleEncoderStream & operator<<(
    const std::pair< F, S > & p
)

scale-encodes pair of values

Parameters:

  • p pair of values to encode

Template Parameters:

  • F first value type
  • S second value type

Return: reference to stream

function operator<<

template <class... Ts>
inline ScaleEncoderStream & operator<<(
    const std::tuple< Ts... > & v
)

scale-encodes tuple of values

Parameters:

  • v tuple value

Template Parameters:

  • T enumeration of types

Return: reference to stream

function operator<<

template <class... T>
inline ScaleEncoderStream & operator<<(
    const boost::variant< T... > & v
)

scale-encodes variant value

Parameters:

  • v value to encode

Template Parameters:

  • T type list

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const std::shared_ptr< T > & v
)

scale-encodes sharead_ptr value

Parameters:

  • v value to encode

Template Parameters:

  • T type list

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const std::unique_ptr< T > & v
)

scale-encodes unique_ptr value

Parameters:

  • v value to encode

Template Parameters:

  • T type list

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const std::vector< T > & c
)

scale-encodes collection of same time items

Parameters:

  • c collection to encode

Template Parameters:

  • T type of item

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const std::list< T > & c
)

scale-encodes collection of same time items

Parameters:

  • c collection to encode

Template Parameters:

  • T type of item

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const boost::optional< T > & v
)

scale-encodes optional value

Parameters:

  • v value to encode

Template Parameters:

  • T value type

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const gsl::span< T > & v
)

appends sequence of bytes

Parameters:

  • v bytes sequence

Return: reference to stream

function operator<<

template <typename T ,
size_t size>
inline ScaleEncoderStream & operator<<(
    const std::array< T, size > & a
)

scale-encodes array of items

Parameters:

  • a reference to the array

Template Parameters:

  • T item type
  • size of the array

Return: reference to stream

function operator<<

inline ScaleEncoderStream & operator<<(
    const boost::multiprecision::uint256_t & i
)

scale-encodes uint256_t to stream

Parameters:

  • i value to decode

Return: reference to stream

function operator<<

template <class T >
inline ScaleEncoderStream & operator<<(
    const std::reference_wrapper< T > & v
)

scale-encodes std::reference_wrapper of a type

Parameters:

  • v value to encode

Template Parameters:

  • T underlying type

Return: reference to stream;

function operator<<

inline ScaleEncoderStream & operator<<(
    std::string_view sv
)

scale-encodes a string view

Parameters:

  • sv string_view item

Return: reference to stream

function operator<<

template <typename T ,
typename I  =std::decay_t<T>,
typename  =std::enable_if_t<std::is_integral_v<I>>>
inline ScaleEncoderStream & operator<<(
    T && v
)

scale-encodes any integral type including bool

Parameters:

  • v value of integral type

Template Parameters:

  • T integral type

Return: reference to stream

function operator<<

ScaleEncoderStream & operator<<(
    const CompactInteger & v
)

scale-encodes CompactInteger value as compact integer

Parameters:

  • v value to encode

Return: reference to stream

Protected Functions Documentation

function encodeElementOfTuple

template <size_t I,
class... Ts>
inline void encodeElementOfTuple(
    const std::tuple< Ts... > & v
)

function tryEncodeAsOneOfVariant

template <uint8_t I,
class... Ts>
inline void tryEncodeAsOneOfVariant(
    const boost::variant< Ts... > & v
)

function encodeCollection

template <class It >
inline ScaleEncoderStream & encodeCollection(
    const CompactInteger & size,
    It && begin,
    It && end
)

scale-encodes any collection

Parameters:

  • size size of the collection
  • begin iterator pointing to the begin of collection
  • end iterator pointing to the end of collection

Template Parameters:

  • It iterator over collection of bytes

Return: reference to stream

function putByte

ScaleEncoderStream & putByte(
    uint8_t v
)

Appenders.

Parameters:

  • v byte value

Return: reference to stream

puts a byte to buffer

Public Attributes Documentation

variable is_encoder_stream

static auto is_encoder_stream = true;

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