20 #ifndef RIPPLE_PROTOCOL_SERIALIZER_H_INCLUDED
21 #define RIPPLE_PROTOCOL_SERIALIZER_H_INCLUDED
23 #include <ripple/basics/Blob.h>
24 #include <ripple/basics/Buffer.h>
25 #include <ripple/basics/Slice.h>
26 #include <ripple/basics/base_uint.h>
27 #include <ripple/basics/contract.h>
28 #include <ripple/basics/safe_cast.h>
29 #include <ripple/protocol/HashPrefix.h>
30 #include <ripple/protocol/SField.h>
57 assert(
data !=
nullptr);
82 add8(
unsigned char i);
92 template <
typename Integer>
95 template <std::
size_t Bits,
class Tag>
105 addRaw(
const void* ptr,
int len);
113 template <
class Iter>
117 addVL(
const void* ptr,
int len);
121 get8(
int&,
int offset)
const;
123 template <
typename Integer>
127 static const auto bytes =
sizeof(Integer);
132 auto ptr = &
mData[offset];
133 for (
auto i = 0; i < bytes; ++i)
142 template <std::
size_t Bits,
typename Tag =
void>
146 auto success = (offset + (Bits / 8)) <=
mData.
size();
157 return addFieldID(safe_cast<int>(type), name);
225 Blob ::const_iterator
230 Blob ::const_iterator
288 template <
class Iter>
326 static_assert(N > 0,
"");
341 return static_cast<int>(
remain_);
357 template <std::
size_t Bits,
class Tag =
void>
364 return getBitString<128>();
370 return getBitString<160>();
376 return getBitString<256>();
410 template <std::
size_t Bits,
class Tag>
414 auto const n = Bits / 8;
417 Throw<std::runtime_error>(
"invalid SerialIter getBitString");
SerialIter(Slice const &slice)
int addFieldID(int type, int name)
An immutable linear range of bytes.
bool operator==(Blob const &v)
std::string getString() const
int add8(unsigned char i)
void getFieldID(int &type, int &name)
static int decodeVLLength(int b1)
Like std::vector<char> but better.
uint256 getSHA512Half() const
int add64(std::uint64_t i)
static int decodeLengthLength(int b1)
constexpr static std::size_t size()
SerialIter(void const *data, std::size_t size) noexcept
void const * data() const noexcept
bool getInteger(Integer &number, int offset)
int getDataLength() const
Integers of any length that is a multiple of 32-bits.
bool operator!=(Blob const &v)
HashPrefix
Prefix for hashing functions.
bool operator!=(const Serializer &v)
const void * getDataPtr() const
std::size_t empty() const noexcept
int addRaw(Blob const &vector)
bool get8(int &, int offset) const
Slice slice() const noexcept
int addEncoded(int length)
Blob ::const_iterator end() const
base_uint< Bits, Tag > getBitString()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
int addBitString(base_uint< Bits, Tag > const &v)
bool getBitString(base_uint< Bits, Tag > &data, int offset) const
int getBytesLeft() const noexcept
std::size_t size() const noexcept
static base_uint fromVoid(void const *data)
Blob const & peekData() const
Serializer(void const *data, std::size_t size)
int addVL(Blob const &vector)
Blob ::const_iterator begin() const
int add32(std::uint32_t i)
static int encodeLengthLength(int length)
int addFieldID(SerializedTypeID type, int name)
bool operator==(const Serializer &v)
int add16(std::uint16_t i)
Slice getSlice(std::size_t bytes)
SerialIter(std::uint8_t const (&data)[N])