cardano::util namespace

Utility namespace.

Classes

template <typename IntType>
struct BytePacker
Object for packing and unpacking bytes as integers.

Enums

enum class Endianness { BigEndian, LittleEndian }
Enum class to represent byte order.

Functions

template <class SizedRange1, class SizedRange2>
auto concatBytes(SizedRange1 const& r1, SizedRange2 const& r2) →  auto
Concatenate two byte ranges.
template <std::size_t N>
auto makeByteArray(std::span<const uint8_t> vec) →  std::array< uint8_t, N > -> auto constexpr
Convert a span of bytes into a fixed size array.
auto rationalApprox(double f, int64_t md) →  std::pair< int64_t, int64_t > -> auto
Approximate a floating point number as a rational number.
void writeEnvelopeTextFile(const std::string_view file_path, const std::string_view type, const std::string_view description, const std::string_view cbor_hex)
Write CBOR date to file in the envelope format used by cardano node.

Function documentation

template <class SizedRange1, class SizedRange2>
auto cardano::util::concatBytes(SizedRange1 const& r1, SizedRange2 const& r2)

Concatenate two byte ranges.

Returns A vector containing the elements of both ranges.

template <std::size_t N>
auto cardano::util::makeByteArray(std::span<const uint8_t> vec) →  std::array< uint8_t, N > constexpr

Convert a span of bytes into a fixed size array.

Returns An array containing the elements from the input.

auto cardano::util::rationalApprox(double f, int64_t md) →  std::pair< int64_t, int64_t >

Approximate a floating point number as a rational number.

Parameters
f The floating point number to convert.
md The maximum denominator.
Returns The numerator and denominator as a pair of integers.

void cardano::util::writeEnvelopeTextFile(const std::string_view file_path, const std::string_view type, const std::string_view description, const std::string_view cbor_hex)

Write CBOR date to file in the envelope format used by cardano node.

Parameters
file_path Path to the generated key file.
type A string key type specifier.
description Description of the key (maybe empty).
cbor_hex The CBOR key data in hex string format.