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));
130 (type > 0) && (type < 256) && (name > 0) && (name < 256),
131 "ripple::Serializer::addFieldID : inputs inside range");
175 byte =
mData[offset];
203 "ripple::Serializer::addVL : size matches expected");
235 bytes[0] =
static_cast<unsigned char>(length);
238 else if (length <= 12480)
241 bytes[0] = 193 +
static_cast<unsigned char>(length >> 8);
242 bytes[1] =
static_cast<unsigned char>(length & 0xff);
245 else if (length <= 918744)
248 bytes[0] = 241 +
static_cast<unsigned char>(length >> 16);
249 bytes[1] =
static_cast<unsigned char>((length >> 8) & 0xff);
250 bytes[2] =
static_cast<unsigned char>(length & 0xff);
254 Throw<std::overflow_error>(
"lenlen");
256 return addRaw(&bytes[0], numBytes);
263 Throw<std::overflow_error>(
"len<0");
271 if (length <= 918744)
274 Throw<std::overflow_error>(
"len>918744");
282 Throw<std::overflow_error>(
"b1<0");
293 Throw<std::overflow_error>(
"b1>254");
301 Throw<std::overflow_error>(
"b1<0");
304 Throw<std::overflow_error>(
"b1>254");
313 Throw<std::overflow_error>(
"b1<193");
316 Throw<std::overflow_error>(
"b1>240");
318 return 193 + (b1 - 193) * 256 + b2;
325 Throw<std::overflow_error>(
"b1<241");
328 Throw<std::overflow_error>(
"b1>254");
330 return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
336 : p_(
reinterpret_cast<std::uint8_t const*
>(data)), remain_(size)
352 Throw<std::runtime_error>(
"invalid SerialIter skip");
362 Throw<std::runtime_error>(
"invalid SerialIter get8");
363 unsigned char t = *
p_;
374 Throw<std::runtime_error>(
"invalid SerialIter get16");
386 Throw<std::runtime_error>(
"invalid SerialIter get32");
399 Throw<std::runtime_error>(
"invalid SerialIter get64");
414 Throw<std::runtime_error>(
"invalid SerialIter geti32");
419 return boost::endian::load_big_s32(t);
426 Throw<std::runtime_error>(
"invalid SerialIter geti64");
431 return boost::endian::load_big_s64(t);
446 Throw<std::runtime_error>(
455 Throw<std::runtime_error>(
468 Throw<std::runtime_error>(
"invalid SerialIter getRaw");
487 return getRawHelper<Blob>(size);
500 else if (lenLen == 2)
508 lenLen == 3,
"ripple::SerialIter::getVLDataLength : lenLen is 3");
520 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.