MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / read_bigendian_number

Function read_bigendian_number

libCacheSim/dataStructure/sparsepp/spp.h:266–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264 // --------------------------------------------------------------------
265 template <typename INPUT, typename IntType>
266 bool read_bigendian_number(INPUT* fp, IntType* value, size_t length)
267 {
268 *value = 0;
269 unsigned char byte;
270 // We require IntType to be unsigned or else the shifting gets all screwy.
271 SPP_COMPILE_ASSERT(static_cast<IntType>(-1) > static_cast<IntType>(0), "serializing_int_requires_an_unsigned_type");
272 for (size_t i = 0; i < length; ++i)
273 {
274 if (!read_data(fp, &byte, sizeof(byte)))
275 return false;
276 *value |= static_cast<IntType>(byte) << ((length - 1 - i) * 8);
277 }
278 return true;
279 }
280
281 template <typename OUTPUT, typename IntType>
282 bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length)

Callers 1

read_32_or_64Method · 0.85

Calls 1

read_dataFunction · 0.70

Tested by

no test coverage detected