Qx v0.5.8
Qt Extensions Library
|
The ByteArray class is a collection of static functions pertaining to QByteArray.
#include <qx/core/qx-bytearray.h>
Public Member Functions | |
template<> | |
QByteArray | fromPrimitive (bool primitive, QSysInfo::Endian endianness) |
Static Public Member Functions | |
template<typename T > requires arithmetic<T> | |
static QByteArray | fromPrimitive (T primitive, QSysInfo::Endian endianness=QSysInfo::ByteOrder) |
template<typename T > requires arithmetic<T> | |
static T | toPrimitive (QByteArray ba, QSysInfo::Endian endianness=QSysInfo::ByteOrder) |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Template specialization of the above for T == bool
.
Returns a byte array consisting of the single byte 0x01
or 0x00
for true
and false
respectively.
endianness is ignored.
|
inlinestatic |
Creates a byte array from the integer value primitive, using endianness byte-ordering if T requires multiple bytes to store, and returns it.
|
inlinestatic |
Returns the raw binary data in ba reinterpreted as fundamental type T, according to the byte-order specified by endianness for multi-byte values.
If the requested type is not large enough to store the reinterpreted contents of ba, the conversion will be performed on the first n-bytes that will fit instead.
If the requested type is stored using more bytes than are present within ba, the conversion will be performed as if ba was padded with zeros to reach that size, in accordance with endianness,
T == bool
, this function will return false
if the first byte of ba is zero, or true
if it is any other value.