XX CMake Package
Loading...
Searching...
No Matches
XXByteConversion.h
Go to the documentation of this file.
1#ifndef XXByteConversionH
2#define XXByteConversionH
3
4#include <QByteArray>
5
6namespace XX
7{
10
11 template <typename DataType>
13 {
14 public:
15 static QByteArray toBytes(const DataType& value, bool swap);
16 static DataType fromBytes(const QByteArray& data, bool swap);
17
18 private:
19 void setBytes(const QByteArray& input);
20 QByteArray getBytes() const;
21 void swapBytes();
22
23 private:
24 union
25 {
26 DataType value = DataType{};
27 char bytes[sizeof(DataType)];
28 };
29 };
30} // namespace XX
31
32#ifndef XXBytesHPP
33#include "XXByteConversion.hpp"
34#endif // NOT XXBytesHPP
35
36#endif // NOT XXByteConversionH
convert data types to and from byte arrays
Definition XXByteConversion.h:13
char bytes[sizeof(DataType)]
Definition XXByteConversion.h:27
static DataType fromBytes(const QByteArray &data, bool swap)
static QByteArray toBytes(const DataType &value, bool swap)
DataType value
Definition XXByteConversion.h:26
Definition XXPopulatedAbstract.h:11