Definitions of a generic block of bytes. More...
Public Types | |
| enum | ByteOrder { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian } |
| Byte order for integer serializing and deserializing. More... | |
| typedef QVector< quint8 > | ByteVector |
| Type definition for the superclass, a Qt vector of bytes. More... | |
Public Member Functions | |
| QtlByteBlock (int size=0, quint8 value=0) | |
| Default constructor. More... | |
| QtlByteBlock (const ByteVector &other) | |
| Copy constructor. More... | |
| QtlByteBlock (const void *addr, int size) | |
| Constructor from a data block. More... | |
| QtlByteBlock (const QByteArray &ba) | |
| Constructor from a QByteArray. More... | |
| QtlByteBlock (const char *str) | |
| Constructor from a C string. More... | |
| void | append (const void *addr, int size) |
| Append raw data to a byte block. More... | |
| void | append (const QtlByteBlock &bb) |
| Append a byte block to a byte block. More... | |
| void | append (const QByteArray &ba) |
| Append a QByteArray to a byte block. More... | |
| void | append (int count, quint8 value) |
| Append n bytes with value i. More... | |
| void | appendInt16 (qint16 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendInt16LittleEndian (qint16 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendInt32 (qint32 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendInt32LittleEndian (qint32 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendInt64 (qint64 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendInt64LittleEndian (qint64 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendInt8 (qint8 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendString (const char *str) |
| Append a C-string to a byte block. More... | |
| template<typename INT > | |
| void | appendToBigEndian (INT i) |
| Add an integer in big endian representation at the end. More... | |
| template<> | |
| void | appendToBigEndian (quint8 i) |
| Add an integer in big endian representation at the end. More... | |
| template<> | |
| void | appendToBigEndian (qint8 i) |
| Add an integer in big endian representation at the end. More... | |
| template<typename INT > | |
| void | appendToByteOrder (INT i, ByteOrder order) |
| Add an integer in a given byte order at the end. More... | |
| template<typename INT > | |
| void | appendToLittleEndian (INT i) |
| Add an integer in little endian representation at the end. More... | |
| template<> | |
| void | appendToLittleEndian (quint8 i) |
| Add an integer in little endian representation at the end. More... | |
| template<> | |
| void | appendToLittleEndian (qint8 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendUInt16 (quint16 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendUInt16LittleEndian (quint16 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendUInt32 (quint32 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendUInt32LittleEndian (quint32 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendUInt64 (quint64 i) |
| Add an integer in big endian representation at the end. More... | |
| void | appendUInt64LittleEndian (quint64 i) |
| Add an integer in little endian representation at the end. More... | |
| void | appendUInt8 (quint8 i) |
| Add an integer in big endian representation at the end. More... | |
| void | copy (const void *addr, int size) |
| Replace the content with a data block. More... | |
| void * | enlarge (int n) |
| Increase size by n and return pointer to new n-byte area at end of block. More... | |
| void * | enlargeFrom (int index, int n) |
| Make sure there are at bytes available at the specified index. More... | |
| template<typename INT > | |
| bool | fromBigEndian (int &index, INT &i) const |
| Get an integer in big endian representation at a given position. More... | |
| template<typename INT > | |
| INT | fromBigEndian (int index) const |
| Get an integer in big endian representation at a given position. More... | |
| template<typename INT > | |
| bool | fromByteOrder (int &index, INT &i, ByteOrder order) const |
| Get an integer in a given byte order at a given position. More... | |
| template<typename INT > | |
| INT | fromByteOrder (int index, ByteOrder order) const |
| Get an integer in a given byte order at a given position. More... | |
| template<typename INT > | |
| bool | fromLittleEndian (int &index, INT &i) const |
| Get an integer in little endian representation at a given position. More... | |
| template<typename INT > | |
| INT | fromLittleEndian (int index) const |
| Get an integer in little endian representation at a given position. More... | |
| bool | getLatin1 (int &index, int stringSize, QString &s) const |
| Get a Latin-1 string at a given position. More... | |
| QString | getLatin1 (int index, int stringSize) const |
| Get a Latin1 string at a given position. More... | |
| bool | getUtf8 (int &index, int stringSize, QString &s) const |
| Get an UTF-8 string at a given position. More... | |
| QString | getUtf8 (int index, int stringSize) const |
| Get an UTF-8 string at a given position. More... | |
| void | storeInt16 (int index, qint16 i) |
| Store an integer in big endian representation at a given index. More... | |
| void | storeInt16LittleEndian (int index, qint16 i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeInt32 (int index, qint32 i) |
| Store an integer in big endian representation at a given index. More... | |
| void | storeInt32LittleEndian (int index, qint32 i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeInt64 (int index, qint64 i) |
| Store an integer in big endian representation at a given index. More... | |
| void | storeInt64LittleEndian (int index, qint64 i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeInt8 (int index, qint8 i) |
| Store an integer in big endian representation at a given index. More... | |
| template<typename INT > | |
| void | storeToBigEndian (int index, INT i) |
| Store an integer in big endian representation at a given index. More... | |
| template<typename INT > | |
| void | storeToByteOrder (int index, INT i, ByteOrder order) |
| Store an integer in a given byte order at a given index. More... | |
| template<typename INT > | |
| void | storeToLittleEndian (int index, INT i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeUInt16 (int index, quint16 i) |
| Store an integer in big endian representation at a given index. More... | |
| void | storeUInt16LittleEndian (int index, quint16 i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeUInt32 (int index, quint32 i) |
| Store an integer in big endian representation at a given index. More... | |
| void | storeUInt32LittleEndian (int index, quint32 i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeUInt64 (int index, quint64 i) |
| Store an integer in big endian representation at a given index. More... | |
| void | storeUInt64LittleEndian (int index, quint64 i) |
| Store an integer in little endian representation at a given index. More... | |
| void | storeUInt8 (int index, quint8 i) |
| Store an integer in big endian representation at a given index. More... | |
| QByteArray | toByteArray () const |
| Convert a QtlByteBlock into a QByteArray. More... | |
Definitions of a generic block of bytes.
| typedef QVector<quint8> QtlByteBlock::ByteVector |
Type definition for the superclass, a Qt vector of bytes.
|
inlineexplicit |
Default constructor.
| [in] | size | Size of the byte block. |
| [in] | value | Value to assign to each byte. |
|
inline |
Copy constructor.
| [in] | other | Other instance to copy. |
|
inline |
Constructor from a data block.
| [in] | addr | Address of the data block. |
| [in] | size | Size of the data block. |
|
inline |
Constructor from a QByteArray.
| [in] | ba | Byte array to copy. |
|
inline |
Constructor from a C string.
| [in] | str | A nul-terminated string. |
|
inline |
Convert a QtlByteBlock into a QByteArray.
| void QtlByteBlock::copy | ( | const void * | addr, |
| int | size | ||
| ) |
Replace the content with a data block.
| [in] | addr | Address of the data block. |
| [in] | size | Size of the data block. |
| void * QtlByteBlock::enlarge | ( | int | n | ) |
Increase size by n and return pointer to new n-byte area at end of block.
| [in] | n | Number of bytes to add. |
| void * QtlByteBlock::enlargeFrom | ( | int | index, |
| int | n | ||
| ) |
Make sure there are at
bytes available at the specified index.
The byte block is enlarged if necessary.
| [in] | index | Index of area. If negative, append at end of data block. |
| [in] | n | Number of bytes to make available. |
| void QtlByteBlock::append | ( | const void * | addr, |
| int | size | ||
| ) |
Append raw data to a byte block.
| [in] | addr | Address of the data block. |
| [in] | size | Size of the data block. |
|
inline |
Append a byte block to a byte block.
| [in] | bb | Byte block to append. |
|
inline |
Append a C-string to a byte block.
| [in] | str | A nul-terminated string. |
|
inline |
Append a QByteArray to a byte block.
| [in] | ba | Byte array to append. |
|
inline |
Append n bytes with value i.
| [in] | count | Number of bytes to add. |
| [in] | value | Value to assign to each byte. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
Template variant
| INT | An integer type. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in big endian representation at a given index.
The byte block is enlarged if necessary. Template variant
| INT | An integer type. |
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
Template variant
| INT | An integer type. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary.
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Store an integer in little endian representation at a given index.
The byte block is enlarged if necessary. Template variant
| INT | An integer type. |
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
|
inline |
Add an integer in a given byte order at the end.
| INT | An integer type. |
| [in] | i | Integer value to append. |
| [in] | order | The byte order to serialize i. |
|
inline |
Store an integer in a given byte order at a given index.
The byte block is enlarged if necessary.
| INT | An integer type. |
| [in] | index | Index where to store the integer. If negative, append at end of data block. |
| [in] | i | Integer value to append. |
| [in] | order | The byte order to serialize i. |
| bool QtlByteBlock::getUtf8 | ( | int & | index, |
| int | stringSize, | ||
| QString & | s | ||
| ) | const |
Get an UTF-8 string at a given position.
| [in,out] | index | Index in the byte block where to read the data. If the data is correctly read, index is updated to point after the read data. |
| [in] | stringSize | Requested string size in bytes. |
| [out] | s | Returned string. |
| QString QtlByteBlock::getUtf8 | ( | int | index, |
| int | stringSize | ||
| ) | const |
Get an UTF-8 string at a given position.
| [in] | index | Index in the byte block where to read the data. |
| [in] | stringSize | Requested string size in bytes. |
| bool QtlByteBlock::getLatin1 | ( | int & | index, |
| int | stringSize, | ||
| QString & | s | ||
| ) | const |
Get a Latin-1 string at a given position.
| [in,out] | index | Index in the byte block where to read the data. If the data is correctly read, index is updated to point after the read data. |
| [in] | stringSize | Requested string size in bytes. |
| [out] | s | Returned string. |
| QString QtlByteBlock::getLatin1 | ( | int | index, |
| int | stringSize | ||
| ) | const |
Get a Latin1 string at a given position.
| [in] | index | Index in the byte block where to read the data. |
| [in] | stringSize | Requested string size in bytes. |
|
inline |
Get an integer in big endian representation at a given position.
| [in,out] | index | Index in the byte block where to read the data. If the data is correctly read, index is updated to point after the read data. |
| [out] | i | Returned integer value. |
|
inline |
Get an integer in big endian representation at a given position.
| [in] | index | Index in the byte block where to read the data. |
|
inline |
Get an integer in little endian representation at a given position.
| [in,out] | index | Index in the byte block where to read the data. If the data is correctly read, index is updated to point after the read data. |
| [out] | i | Returned integer value. |
|
inline |
Get an integer in little endian representation at a given position.
| [in] | index | Index in the byte block where to read the data. |
|
inline |
Get an integer in a given byte order at a given position.
| [in,out] | index | Index in the byte block where to read the data. If the data is correctly read, index is updated to point after the read data. |
| [out] | i | Returned integer value. |
| [in] | order | The byte order to deserialize i. |
|
inline |
Get an integer in a given byte order at a given position.
| [in] | index | Index in the byte block where to read the data. |
| [in] | order | The byte order to deserialize the integer. |
|
inline |
Add an integer in big endian representation at the end.
Template specializations for performance
| [in] | i | Integer value to append. |
|
inline |
Add an integer in big endian representation at the end.
Template specializations for performance
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
Template specializations for performance
| [in] | i | Integer value to append. |
|
inline |
Add an integer in little endian representation at the end.
Template specializations for performance
| [in] | i | Integer value to append. |