Constructor: takes memory address, length, and endianness
| 24 | public: |
| 25 | // Constructor: takes memory address, length, and endianness |
| 26 | StreamReader(const uint8_t* data, size_t length, Endian endian = Endian::Little) |
| 27 | : data_(data), length_(length), pos_(0), endian_(endian) { |
| 28 | // Detect native endian |
| 29 | uint16_t test = 0x0001; |
| 30 | native_is_little_ = (*reinterpret_cast<uint8_t*>(&test) == 0x01); |
| 31 | |
| 32 | // Determine if we need to swap bytes |
| 33 | if (endian_ == Endian::Native) { |
| 34 | needs_swap_ = false; |
| 35 | } else { |
| 36 | bool data_is_little = (endian_ == Endian::Little); |
| 37 | needs_swap_ = (data_is_little != native_is_little_); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // Read n bytes into destination buffer |
| 42 | // Returns false on out-of-bounds or error |
nothing calls this directly
no outgoing calls
no test coverage detected