MCPcopy Create free account
hub / github.com/ElementsProject/elements / ReadVarInt

Function ReadVarInt

src/serialize.h:388–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386
387template<typename Stream, VarIntMode Mode, typename I>
388I ReadVarInt(Stream& is)
389{
390 CheckVarIntMode<Mode, I>();
391 I n = 0;
392 while(true) {
393 unsigned char chData = ser_readdata8(is);
394 if (n > (std::numeric_limits<I>::max() >> 7)) {
395 throw std::ios_base::failure("ReadVarInt(): size too large");
396 }
397 n = (n << 7) | (chData & 0x7F);
398 if (chData & 0x80) {
399 if (n == std::numeric_limits<I>::max()) {
400 throw std::ios_base::failure("ReadVarInt(): size too large");
401 }
402 n++;
403 } else {
404 return n;
405 }
406 }
407}
408
409/** Simple wrapper class to serialize objects using a formatter; used by Using(). */
410template<typename Formatter, typename T>

Callers

nothing calls this directly

Calls 1

ser_readdata8Function · 0.85

Tested by

no test coverage detected