Read 4 bytes (uint32_t) with endian swap if needed
| 78 | |
| 79 | // Read 4 bytes (uint32_t) with endian swap if needed |
| 80 | bool read4(uint32_t* dst) { |
| 81 | if (!dst) { |
| 82 | return false; |
| 83 | } |
| 84 | uint8_t buf[4]; |
| 85 | if (!read(4, buf)) { |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | if (needs_swap_) { |
| 90 | *dst = static_cast<uint32_t>(buf[3]) << 24 | |
| 91 | static_cast<uint32_t>(buf[2]) << 16 | |
| 92 | static_cast<uint32_t>(buf[1]) << 8 | |
| 93 | static_cast<uint32_t>(buf[0]); |
| 94 | } else { |
| 95 | std::memcpy(dst, buf, 4); |
| 96 | } |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | // Read 8 bytes (uint64_t) with endian swap if needed |
| 101 | bool read8(uint64_t* dst) { |
nothing calls this directly
no outgoing calls
no test coverage detected