| 8 | // TODO: something better here that doesn't assume little-endian architecture |
| 9 | template<bool littleEndian=true> |
| 10 | struct BigEndian { |
| 11 | static uint32_t read16(std::istream& in) { |
| 12 | unsigned char a[2]; |
| 13 | in.read((char*)a, sizeof(a)); |
| 14 | return ((uint32_t)a[0]) + ((uint32_t)a[1])*256; |
| 15 | } |
| 16 | static uint32_t read32(std::istream& in) { |
| 17 | unsigned char a[4]; |
| 18 | in.read((char*)a, sizeof(a)); |
| 19 | return ((uint32_t)a[0]&0xff) + ((uint32_t)a[1])*256 + ((uint32_t)a[2])*65536 + ((uint32_t)a[3])*256*65536; |
| 20 | } |
| 21 | |
| 22 | static void write16(std::ostream& out, uint16_t value) { |
| 23 | char a[2] = {(char)(value>>0), (char)(value>>8)}; |
| 24 | out.write(a, sizeof(a)); |
| 25 | } |
| 26 | static void write32(std::ostream& out, uint32_t value) { |
| 27 | char a[4] = {(char)(value>>0), (char)(value>>8), (char)(value>>16), (char)(value>>24)}; |
| 28 | out.write(a, sizeof(a)); |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | class Wav : BigEndian<true> { |
| 33 | // Little-endian versions of text values |
nothing calls this directly
no outgoing calls
no test coverage detected