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>
107 addRaw(
const void* ptr,
int len);
115 template <
class Iter>
119 addVL(
const void* ptr,
int len);
123 get8(
int&,
int offset)
const;
125 template <
typename Integer>
129 static const auto bytes =
sizeof(Integer);
134 auto ptr = &
mData[offset];
135 for (
auto i = 0; i < bytes; ++i)
144 template <std::
size_t Bits,
typename Tag =
void>
148 auto success = (offset + (Bits / 8)) <=
mData.
size();
159 return addFieldID(safe_cast<int>(type), name);
227 Blob ::const_iterator
232 Blob ::const_iterator
290 template <
class Iter>
328 static_assert(N > 0,
"");
343 return static_cast<int>(
remain_);
359 template <std::
size_t Bits,
class Tag =
void>
366 return getBitString<128>();
372 return getBitString<160>();
378 return getBitString<256>();
412 template <std::
size_t Bits,
class Tag>
416 auto const n = Bits / 8;
419 Throw<std::runtime_error>(
"invalid SerialIter getBitString");
SerialIter(Slice const &slice)
int addFieldID(int type, int name)
An immutable linear range of bytes.
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.
bool operator==(const Serializer &v) const
bool operator!=(Blob const &v) const
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.
HashPrefix
Prefix for hashing functions.
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)
bool operator==(Blob const &v) const
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 operator!=(const Serializer &v) const
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)
int add16(std::uint16_t i)
Slice getSlice(std::size_t bytes)
SerialIter(std::uint8_t const (&data)[N])