20#include <xrpl/basics/Buffer.h>
21#include <xrpl/basics/Slice.h>
22#include <xrpl/basics/base_uint.h>
23#include <xrpl/basics/contract.h>
24#include <xrpl/basics/safe_cast.h>
25#include <xrpl/beast/utility/instrumentation.h>
26#include <xrpl/protocol/HashPrefix.h>
27#include <xrpl/protocol/Serializer.h>
28#include <xrpl/protocol/digest.h>
30#include <boost/endian/conversion.hpp>
59 return add32(safe_cast<std::uint32_t>(p));
124 (type > 0) && (type < 256) && (name > 0) && (name < 256),
125 "ripple::Serializer::addFieldID : inputs inside range");
169 byte =
mData[offset];
197 "ripple::Serializer::addVL : size matches expected");
229 bytes[0] =
static_cast<unsigned char>(length);
232 else if (length <= 12480)
235 bytes[0] = 193 +
static_cast<unsigned char>(length >> 8);
236 bytes[1] =
static_cast<unsigned char>(length & 0xff);
239 else if (length <= 918744)
242 bytes[0] = 241 +
static_cast<unsigned char>(length >> 16);
243 bytes[1] =
static_cast<unsigned char>((length >> 8) & 0xff);
244 bytes[2] =
static_cast<unsigned char>(length & 0xff);
248 Throw<std::overflow_error>(
"lenlen");
250 return addRaw(&bytes[0], numBytes);
257 Throw<std::overflow_error>(
"len<0");
265 if (length <= 918744)
268 Throw<std::overflow_error>(
"len>918744");
276 Throw<std::overflow_error>(
"b1<0");
287 Throw<std::overflow_error>(
"b1>254");
295 Throw<std::overflow_error>(
"b1<0");
298 Throw<std::overflow_error>(
"b1>254");
307 Throw<std::overflow_error>(
"b1<193");
310 Throw<std::overflow_error>(
"b1>240");
312 return 193 + (b1 - 193) * 256 + b2;
319 Throw<std::overflow_error>(
"b1<241");
322 Throw<std::overflow_error>(
"b1>254");
324 return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
330 : p_(
reinterpret_cast<std::uint8_t const*
>(data)), remain_(size)
346 Throw<std::runtime_error>(
"invalid SerialIter skip");
356 Throw<std::runtime_error>(
"invalid SerialIter get8");
357 unsigned char t = *
p_;
368 Throw<std::runtime_error>(
"invalid SerialIter get16");
380 Throw<std::runtime_error>(
"invalid SerialIter get32");
393 Throw<std::runtime_error>(
"invalid SerialIter get64");
408 Throw<std::runtime_error>(
"invalid SerialIter geti32");
413 return boost::endian::load_big_s32(t);
420 Throw<std::runtime_error>(
"invalid SerialIter geti64");
425 return boost::endian::load_big_s64(t);
440 Throw<std::runtime_error>(
449 Throw<std::runtime_error>(
462 Throw<std::runtime_error>(
"invalid SerialIter getRaw");
481 return getRawHelper<Blob>(size);
494 else if (lenLen == 2)
502 lenLen == 3,
"ripple::SerialIter::getVLDataLength : lenLen is 3");
514 Throw<std::runtime_error>(
"invalid SerialIter getSlice");
Like std::vector<char> but better.
SerialIter(void const *data, std::size_t size) noexcept
Slice getSlice(std::size_t bytes)
void getFieldID(int &type, int &name)
int addFieldID(int type, int name)
Slice slice() const noexcept
bool get8(int &, int offset) const
uint256 getSHA512Half() const
static int encodeLengthLength(int length)
int addEncoded(int length)
int addRaw(Blob const &vector)
int addVL(Blob const &vector)
static int decodeLengthLength(int b1)
int add16(std::uint16_t i)
int add8(unsigned char i)
static int decodeVLLength(int b1)
An immutable linear range of bytes.
const_iterator begin() const noexcept
const_iterator end() const noexcept
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
std::size_t size() const noexcept
Returns the number of bytes in the storage.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
HashPrefix
Prefix for hashing functions.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.