24 char* arr = (
char*)&src;
25 uint16_t res = (uint16_t)arr[0] << 8 |
27 memcpy(dest, &res, 2);
76 char* arr = (
char*)&src;
77 uint32_t res = (uint32_t)arr[0] << 24 |
78 (uint32_t)arr[1] << 16 |
79 (uint32_t)arr[2] << 8 |
81 memcpy(dest, &res, 4);
91 char* arr = (
char*)&src;
92 uint64_t res = (uint64_t)arr[0] << 56 |
93 (uint64_t)arr[1] << 48 |
94 (uint64_t)arr[2] << 40 |
95 (uint64_t)arr[3] << 32 |
96 (uint64_t)arr[4] << 24 |
97 (uint64_t)arr[5] << 16 |
98 (uint64_t)arr[6] << 8 |
100 memcpy(dest, &res, 8);
111 stream.write(buffer, 2);
122 stream.write(buffer, 4);
133 stream.write(buffer, 8);
Abort compilation if a char has not 8 bits, as functions for this case aren't implemented yet.
void toBigEndian32(uint32_t src, char *dest)
void toBigEndian16(uint16_t src, char *dest)
void writeBigEndian32(uint32_t number, std::ostream &stream)
void writeBigEndian16(uint16_t number, std::ostream &stream)
void writeBigEndian64(uint64_t number, std::ostream &stream)
void toBigEndian64(uint64_t src, char *dest)