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));
127 assert((type > 0) && (type < 256) && (name > 0) && (name < 256));
171 byte =
mData[offset];
230 bytes[0] =
static_cast<unsigned char>(length);
233 else if (length <= 12480)
236 bytes[0] = 193 +
static_cast<unsigned char>(length >> 8);
237 bytes[1] =
static_cast<unsigned char>(length & 0xff);
240 else if (length <= 918744)
243 bytes[0] = 241 +
static_cast<unsigned char>(length >> 16);
244 bytes[1] =
static_cast<unsigned char>((length >> 8) & 0xff);
245 bytes[2] =
static_cast<unsigned char>(length & 0xff);
249 Throw<std::overflow_error>(
"lenlen");
251 return addRaw(&bytes[0], numBytes);
258 Throw<std::overflow_error>(
"len<0");
266 if (length <= 918744)
269 Throw<std::overflow_error>(
"len>918744");
277 Throw<std::overflow_error>(
"b1<0");
288 Throw<std::overflow_error>(
"b1>254");
296 Throw<std::overflow_error>(
"b1<0");
299 Throw<std::overflow_error>(
"b1>254");
308 Throw<std::overflow_error>(
"b1<193");
311 Throw<std::overflow_error>(
"b1>240");
313 return 193 + (b1 - 193) * 256 + b2;
320 Throw<std::overflow_error>(
"b1<241");
323 Throw<std::overflow_error>(
"b1>254");
325 return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
331 : p_(
reinterpret_cast<std::uint8_t const*
>(data)), remain_(size)
347 Throw<std::runtime_error>(
"invalid SerialIter skip");
357 Throw<std::runtime_error>(
"invalid SerialIter get8");
358 unsigned char t = *
p_;
369 Throw<std::runtime_error>(
"invalid SerialIter get16");
381 Throw<std::runtime_error>(
"invalid SerialIter get32");
394 Throw<std::runtime_error>(
"invalid SerialIter get64");
417 Throw<std::runtime_error>(
426 Throw<std::runtime_error>(
439 Throw<std::runtime_error>(
"invalid SerialIter getRaw");
458 return getRawHelper<Blob>(size);
471 else if (lenLen == 2)
490 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.
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)