20 #include <ripple/basics/Log.h>
21 #include <ripple/basics/contract.h>
22 #include <ripple/protocol/Serializer.h>
23 #include <ripple/protocol/digest.h>
67 return add32(safe_cast<std::uint32_t>(p));
164 assert((type > 0) && (type < 256) && (name > 0) && (name < 256));
208 byte =
mData[offset];
286 if (!
get8(b1, offset++))
295 else if (lenLen == 2)
299 if (!
get8(b2, offset++))
304 else if (lenLen == 3)
308 if (!
get8(b2, offset++))
311 if (!
get8(b3, offset++))
324 length = lenLen + datLen;
325 return getRaw(objectVL, offset, datLen);
333 if (!
get8(b1, offset++))
342 else if (lenLen == 2)
346 if (!
get8(b2, offset++))
351 else if (lenLen == 3)
355 if (!
get8(b2, offset++))
358 if (!
get8(b3, offset++))
382 bytes[0] =
static_cast<unsigned char>(length);
385 else if (length <= 12480)
388 bytes[0] = 193 +
static_cast<unsigned char>(length >> 8);
389 bytes[1] =
static_cast<unsigned char>(length & 0xff);
392 else if (length <= 918744)
395 bytes[0] = 241 +
static_cast<unsigned char>(length >> 16);
396 bytes[1] =
static_cast<unsigned char>((length >> 8) & 0xff);
397 bytes[2] =
static_cast<unsigned char>(length & 0xff);
401 Throw<std::overflow_error>(
"lenlen");
403 return addRaw(&bytes[0], numBytes);
410 Throw<std::overflow_error>(
"len<0");
418 if (length <= 918744)
421 Throw<std::overflow_error>(
"len>918744");
429 Throw<std::overflow_error>(
"b1<0");
440 Throw<std::overflow_error>(
"b1>254");
448 Throw<std::overflow_error>(
"b1<0");
451 Throw<std::overflow_error>(
"b1>254");
460 Throw<std::overflow_error>(
"b1<193");
463 Throw<std::overflow_error>(
"b1>240");
465 return 193 + (b1 - 193) * 256 + b2;
472 Throw<std::overflow_error>(
"b1<241");
475 Throw<std::overflow_error>(
"b1>254");
477 return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
483 : p_(
reinterpret_cast<std::uint8_t const*
>(data)), remain_(size)
499 Throw<std::runtime_error>(
"invalid SerialIter skip");
509 Throw<std::runtime_error>(
"invalid SerialIter get8");
510 unsigned char t = *
p_;
521 Throw<std::runtime_error>(
"invalid SerialIter get16");
533 Throw<std::runtime_error>(
"invalid SerialIter get32");
546 Throw<std::runtime_error>(
"invalid SerialIter get64");
568 if (type == 0 || type < 16)
569 Throw<std::runtime_error>(
577 if (name == 0 || name < 16)
578 Throw<std::runtime_error>(
591 Throw<std::runtime_error>(
"invalid SerialIter getRaw");
610 return getRawHelper<Blob>(size);
623 else if (lenLen == 2)
642 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 add8(unsigned char byte)
int addFieldID(int type, int name)
bool getVLLength(int &length, int offset) const
An immutable linear range of bytes.
bool getVL(Blob &objectVL, int offset, int &length) const
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
static int decodeLengthLength(int b1)
bool get256(uint256 &, int offset) const
SerialIter(void const *data, std::size_t size) noexcept
HashPrefix
Prefix for hashing functions.
bool getRaw(Blob &, int offset, int length) const
int addRaw(Blob const &vector)
bool get8(int &, int offset) const
Slice slice() const noexcept
int add128(const uint128 &)
int addEncoded(int length)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
int addZeros(size_t uBytes)
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
int addVL(Blob const &vector)
static int encodeLengthLength(int length)
Slice getSlice(std::size_t bytes)
int add256(uint256 const &)