SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
ByteOrder.h
Go to the documentation of this file.
1 /**
2  * \file ByteOrder.h
3  * \date January 2021
4  * \authors Marino von Wattenwyl
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLPROJECT_BYTEORDER_H
11 #define SLPROJECT_BYTEORDER_H
12 
13 #include <cstdint>
14 #include <climits>
15 #include <cstdlib>
16 #include <iostream>
17 
18 //-----------------------------------------------------------------------------
19 //! Abort compilation if a char has not 8 bits, as functions for this case aren't implemented yet
20 #if CHAR_BIT != 8
21 # error "Byte order functions require that the machine has a char width of 8 bit"
22 #endif
23 //-----------------------------------------------------------------------------
24 //! Utility functions for functions related to byte order conversions
25 namespace ByteOrder
26 {
27 //-----------------------------------------------------------------------------
28 void toBigEndian16(uint16_t src, char* dest);
29 void toBigEndian32(uint32_t src, char* dest);
30 void toBigEndian64(uint64_t src, char* dest);
31 //-----------------------------------------------------------------------------
32 void writeBigEndian16(uint16_t number, std::ostream& stream);
33 void writeBigEndian32(uint32_t number, std::ostream& stream);
34 void writeBigEndian64(uint64_t number, std::ostream& stream);
35 //-----------------------------------------------------------------------------
36 } // namespace ByteOrder
37 //-----------------------------------------------------------------------------
38 
39 #endif // SLPROJECT_BYTEORDER_H
Abort compilation if a char has not 8 bits, as functions for this case aren't implemented yet.
Definition: ByteOrder.cpp:15
void toBigEndian32(uint32_t src, char *dest)
Definition: ByteOrder.cpp:74
void toBigEndian16(uint16_t src, char *dest)
Definition: ByteOrder.cpp:22
void writeBigEndian32(uint32_t number, std::ostream &stream)
Definition: ByteOrder.cpp:118
void writeBigEndian16(uint16_t number, std::ostream &stream)
Definition: ByteOrder.cpp:107
void writeBigEndian64(uint64_t number, std::ostream &stream)
Definition: ByteOrder.cpp:129
void toBigEndian64(uint64_t src, char *dest)
Definition: ByteOrder.cpp:89