20 #include <ripple/basics/Log.h>
21 #include <ripple/basics/contract.h>
22 #include <ripple/protocol/Serializer.h>
23 #include <ripple/protocol/digest.h>
56 return add32(safe_cast<std::uint32_t>(p));
135 assert((type > 0) && (type < 256) && (name > 0) && (name < 256));
179 byte =
mData[offset];
238 bytes[0] =
static_cast<unsigned char>(length);
241 else if (length <= 12480)
244 bytes[0] = 193 +
static_cast<unsigned char>(length >> 8);
245 bytes[1] =
static_cast<unsigned char>(length & 0xff);
248 else if (length <= 918744)
251 bytes[0] = 241 +
static_cast<unsigned char>(length >> 16);
252 bytes[1] =
static_cast<unsigned char>((length >> 8) & 0xff);
253 bytes[2] =
static_cast<unsigned char>(length & 0xff);
257 Throw<std::overflow_error>(
"lenlen");
259 return addRaw(&bytes[0], numBytes);
266 Throw<std::overflow_error>(
"len<0");
274 if (length <= 918744)
277 Throw<std::overflow_error>(
"len>918744");
285 Throw<std::overflow_error>(
"b1<0");
296 Throw<std::overflow_error>(
"b1>254");
304 Throw<std::overflow_error>(
"b1<0");
307 Throw<std::overflow_error>(
"b1>254");
316 Throw<std::overflow_error>(
"b1<193");
319 Throw<std::overflow_error>(
"b1>240");
321 return 193 + (b1 - 193) * 256 + b2;
328 Throw<std::overflow_error>(
"b1<241");
331 Throw<std::overflow_error>(
"b1>254");
333 return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
339 : p_(
reinterpret_cast<std::uint8_t const*
>(data)), remain_(size)
355 Throw<std::runtime_error>(
"invalid SerialIter skip");
365 Throw<std::runtime_error>(
"invalid SerialIter get8");
366 unsigned char t = *
p_;
377 Throw<std::runtime_error>(
"invalid SerialIter get16");
389 Throw<std::runtime_error>(
"invalid SerialIter get32");
402 Throw<std::runtime_error>(
"invalid SerialIter get64");
425 Throw<std::runtime_error>(
434 Throw<std::runtime_error>(
447 Throw<std::runtime_error>(
"invalid SerialIter getRaw");
466 return getRawHelper<Blob>(size);
479 else if (lenLen == 2)
498 Throw<std::runtime_error>(
"invalid SerialIter getSlice");
std::size_t size() const noexcept
Returns the number of bytes in the storage.
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)
int addFieldID(int type, int name)
An immutable linear range of bytes.
const_iterator end() const noexcept
int add8(unsigned char i)
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
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)
SerialIter(void const *data, std::size_t size) noexcept
HashPrefix
Prefix for hashing functions.
int addRaw(Blob const &vector)
bool get8(int &, int offset) const
Slice slice() const noexcept
int addEncoded(int length)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
int addVL(Blob const &vector)
int add32(std::uint32_t i)
static int encodeLengthLength(int length)
int add16(std::uint16_t i)
Slice getSlice(std::size_t bytes)
const_iterator begin() const noexcept