| 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) |
no test coverage detected