20#ifndef RIPPLE_PROTOCOL_SERIALIZER_H_INCLUDED
21#define RIPPLE_PROTOCOL_SERIALIZER_H_INCLUDED
23#include <xrpl/basics/Blob.h>
24#include <xrpl/basics/Buffer.h>
25#include <xrpl/basics/Slice.h>
26#include <xrpl/basics/base_uint.h>
27#include <xrpl/basics/contract.h>
28#include <xrpl/basics/safe_cast.h>
29#include <xrpl/basics/strHex.h>
30#include <xrpl/beast/utility/instrumentation.h>
31#include <xrpl/protocol/HashPrefix.h>
32#include <xrpl/protocol/SField.h>
60 "ripple::Serializer::Serializer(void const*) : non-null input");
85 add8(
unsigned char i);
107 template <
typename T>
126 template <
typename Integer>
129 template <std::
size_t Bits,
class Tag>
141 addRaw(
void const* ptr,
int len);
149 template <
class Iter>
153 addVL(
void const* ptr,
int len);
157 get8(
int&,
int offset)
const;
159 template <
typename Integer>
163 static auto const bytes =
sizeof(Integer);
168 auto ptr = &
mData[offset];
169 for (
auto i = 0; i < bytes; ++i)
178 template <std::
size_t Bits,
typename Tag =
void>
193 return addFieldID(safe_cast<int>(type), name);
261 Blob ::const_iterator
266 Blob ::const_iterator
333 len -=
begin->size();
337 len == 0,
"ripple::Serializer::addVL : length matches distance");
363 static_assert(N > 0,
"");
378 return static_cast<int>(
remain_);
398 template <std::
size_t Bits,
class Tag =
void>
405 return getBitString<128>();
411 return getBitString<160>();
417 return getBitString<192>();
423 return getBitString<256>();
457template <std::
size_t Bits,
class Tag>
461 auto const n = Bits / 8;
464 Throw<std::runtime_error>(
"invalid SerialIter getBitString");
Like std::vector<char> but better.
SerialIter(std::uint8_t const (&data)[N])
int getBytesLeft() const noexcept
Slice getSlice(std::size_t bytes)
SerialIter(Slice const &slice)
void getFieldID(int &type, int &name)
base_uint< Bits, Tag > getBitString()
std::size_t empty() const noexcept
std::size_t size() const noexcept
void const * data() const noexcept
int addFieldID(int type, int name)
bool operator==(Blob const &v) const
bool getBitString(base_uint< Bits, Tag > &data, int offset) const
int addFieldID(SerializedTypeID type, int name)
Slice slice() const noexcept
bool getInteger(Integer &number, int offset)
bool get8(int &, int offset) const
Blob const & peekData() const
Blob::const_iterator end() const
uint256 getSHA512Half() const
Serializer(void const *data, std::size_t size)
int getDataLength() const
bool operator==(Serializer const &v) const
static int encodeLengthLength(int length)
int addEncoded(int length)
int addRaw(Blob const &vector)
int addBitString(base_uint< Bits, Tag > const &v)
bool operator!=(Serializer const &v) const
int addVL(Blob const &vector)
Blob::const_iterator begin() const
static int decodeLengthLength(int b1)
int add16(std::uint16_t i)
int add8(unsigned char i)
bool operator!=(Blob const &v) const
static int decodeVLLength(int b1)
void const * getDataPtr() const
std::string getString() const
An immutable linear range of bytes.
Integers of any length that is a multiple of 32-bits.
static base_uint fromVoid(void const *data)
static constexpr std::size_t size()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
HashPrefix
Prefix for hashing functions.