20 #include <ripple/basics/contract.h>
21 #include <ripple/basics/Log.h>
22 #include <ripple/protocol/digest.h>
23 #include <ripple/protocol/Serializer.h>
64 return add32(safe_cast<std::uint32_t>(p));
123 if ((offset + (256 / 8)) >
mData.
size ())
return false;
132 assert ((type > 0) && (type < 256) && (name > 0) && (name < 256));
137 mData.
push_back (
static_cast<unsigned char> ((type << 4) | name));
171 if (offset >=
mData.
size ())
return false;
173 byte =
mData[offset];
187 if ((offset + length) >
mData.
size ())
return false;
197 if ((offset + length) >
mData.
size ())
return o;
238 if (!
get8 (b1, offset++))
return false;
246 else if (lenLen == 2)
250 if (!
get8 (b2, offset++))
return false;
254 else if (lenLen == 3)
258 if (!
get8 (b2, offset++))
return false;
260 if (!
get8 (b3, offset++))
return false;
271 length = lenLen + datLen;
272 return getRaw (objectVL, offset, datLen);
279 if (!
get8 (b1, offset++))
return false;
287 else if (lenLen == 2)
291 if (!
get8 (b2, offset++))
return false;
295 else if (lenLen == 3)
299 if (!
get8 (b2, offset++))
return false;
301 if (!
get8 (b3, offset++))
return false;
322 bytes[0] =
static_cast<unsigned char> (length);
325 else if (length <= 12480)
328 bytes[0] = 193 +
static_cast<unsigned char> (length >> 8);
329 bytes[1] =
static_cast<unsigned char> (length & 0xff);
332 else if (length <= 918744)
335 bytes[0] = 241 +
static_cast<unsigned char> (length >> 16);
336 bytes[1] =
static_cast<unsigned char> ((length >> 8) & 0xff);
337 bytes[2] =
static_cast<unsigned char> (length & 0xff);
340 else Throw<std::overflow_error> (
"lenlen");
342 return addRaw (&bytes[0], numBytes);
347 if (length < 0) Throw<std::overflow_error> (
"len<0");
349 if (length <= 192)
return 1;
351 if (length <= 12480)
return 2;
353 if (length <= 918744)
return 3;
355 Throw<std::overflow_error> (
"len>918744");
361 if (b1 < 0) Throw<std::overflow_error> (
"b1<0");
363 if (b1 <= 192)
return 1;
365 if (b1 <= 240)
return 2;
367 if (b1 <= 254)
return 3;
369 Throw<std::overflow_error> (
"b1>254");
375 if (b1 < 0) Throw<std::overflow_error> (
"b1<0");
377 if (b1 > 254) Throw<std::overflow_error> (
"b1>254");
384 if (b1 < 193) Throw<std::overflow_error> (
"b1<193");
386 if (b1 > 240) Throw<std::overflow_error> (
"b1>240");
388 return 193 + (b1 - 193) * 256 + b2;
393 if (b1 < 241) Throw<std::overflow_error> (
"b1<241");
395 if (b1 > 254) Throw<std::overflow_error> (
"b1>254");
397 return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
404 : p_ (
reinterpret_cast<
422 Throw<std::runtime_error> (
423 "invalid SerialIter skip");
433 Throw<std::runtime_error> (
434 "invalid SerialIter get8");
435 unsigned char t = *
p_;
446 Throw<std::runtime_error> (
447 "invalid SerialIter get16");
461 Throw<std::runtime_error> (
462 "invalid SerialIter get32");
478 Throw<std::runtime_error> (
479 "invalid SerialIter get64");
506 if (type == 0 || type < 16)
507 Throw<std::runtime_error> (
508 "gFID: uncommon type out of range " +
516 if (name == 0 || name < 16)
517 Throw<std::runtime_error> (
518 "gFID: uncommon name out of range " +
530 Throw<std::runtime_error> (
531 "invalid SerialIter getRaw");
550 return getRawHelper<Blob> (size);
562 else if (lenLen == 2)
581 Throw<std::runtime_error> (
582 "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 &)