MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / StreamReader

Method StreamReader

Source/ThirdParty/streamreader.hh:26–39  ·  view source on GitHub ↗

Constructor: takes memory address, length, and endianness

Source from the content-addressed store, hash-verified

24public:
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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected