QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlHexa.h File Reference

Declare some utilities to manipulate hexadecimal strings. More...

Namespaces

 Qtl
 Qtl namespace.
 

Enumerations

enum  Qtl::HexaFlag {
  Qtl::HexHexa = 0x0001,
  Qtl::HexAscii = 0x0002,
  Qtl::HexOffset = 0x0004,
  Qtl::HexWideOffset = 0x0008,
  Qtl::HexSingleLine = 0x0010,
  Qtl::HexBytesPerLine = 0x0020,
  Qtl::HexCStyle = 0x0040,
  Qtl::HexBinary = 0x0080,
  Qtl::HexBinNibble = 0x0100,
  Qtl::HexCompact = 0x0200
}
 Flags for the qtlHexa family of functions. More...
 

Functions

QString qtlHexa (const void *data, int size, Qtl::HexaFlags flags=Qtl::HexaFlags(Qtl::HexHexa), int indent=0, int lineWidth=Qtl::DefautLineWidth, int initOffset=0)
 Build a multi-line string containing the hexadecimal dump of a memory area. More...
 
QString qtlHexa (const QtlByteBlock &data, Qtl::HexaFlags flags=Qtl::HexaFlags(Qtl::HexHexa), int indent=0, int lineWidth=Qtl::DefautLineWidth, int initOffset=0)
 Build a multi-line string containing the hexadecimal dump of the content of a byte array. More...
 
bool qtlHexaDecode (QtlByteBlock &result, const QString &hexaString)
 Interpret a string as a sequence of hexadecimal digits. More...
 
QtlByteBlock qtlHexaDecode (const QString &hexaString)
 Interpret a string as a sequence of hexadecimal digits and return a QtlByteBlock. More...
 
bool qtlHexaDecodeAndAppend (QtlByteBlock &result, const QString &hexaString)
 Interpret a string as a sequence of hexadecimal digits. More...
 
template<typename INT >
QString qtlHexaInt (INT i, int width=0, int groupSize=0)
 Build an hexadecimal string from an integer value. More...
 
template<>
QString qtlHexaInt (quint64 i, int width, int groupSize)
 Build an hexadecimal string from an integer value. More...
 
template<>
QString qtlHexaInt (qint64 i, int width, int groupSize)
 Build an hexadecimal string from an integer value. More...
 

Variables

const int Qtl::DefautLineWidth = 78
 Default line width for output formatting. More...
 

Detailed Description

Declare some utilities to manipulate hexadecimal strings.

Qtl, Qt utility library.

Function Documentation

◆ qtlHexaDecodeAndAppend()

bool qtlHexaDecodeAndAppend ( QtlByteBlock result,
const QString &  hexaString 
)

Interpret a string as a sequence of hexadecimal digits.

Interpret all hexadecimal digits in hexaString. Each pair of hexadecimal digits is interpreted as one byte value which is appended into a byte array. Space characters are ignored. Other characters generate an error.

Parameters
[in,out]resultA byte array. All decoded bytes are appended to this container.
[in]hexaStringThe string to decode.
Returns
True on success, false on error (invalid hexadecimal format). When returning false, result contains all bytes that could be decoded before getting the error.

◆ qtlHexaDecode() [1/2]

bool qtlHexaDecode ( QtlByteBlock result,
const QString &  hexaString 
)
inline

Interpret a string as a sequence of hexadecimal digits.

Interpret all hexadecimal digits in hexaString. Each pair of hexadecimal digits is interpreted as one byte value. A byte array is assigned with the result. Space characters are ignored. Other characters generate an error.

Parameters
[out]resultA byte array. All decoded bytes are stored into this vector.
[in]hexaStringThe string to decode.
Returns
True on success, false on error (invalid hexadecimal format). When returning false, result contains all bytes that could be decoded before getting the error.

◆ qtlHexaDecode() [2/2]

QtlByteBlock qtlHexaDecode ( const QString &  hexaString)
inline

Interpret a string as a sequence of hexadecimal digits and return a QtlByteBlock.

Interpret all hexadecimal digits in hexaString. Each pair of hexadecimal digits is interpreted as one byte value. A byte array is assigned with the result. Space characters are ignored. Other characters generate an error.

Parameters
[in]hexaStringThe string to decode.
Returns
A byte block. All decoded bytes are stored into this vector.

◆ qtlHexaInt() [1/3]

template<typename INT >
QString qtlHexaInt ( INT  i,
int  width = 0,
int  groupSize = 0 
)
inline

Build an hexadecimal string from an integer value.

Template Parameters
INTAn integer type.
Parameters
[in]iThe integer value to format.
[in]widthThe number of hexadecimal digits. If negative or zero, use the "natural" width for i.
[in]groupSizeThe number of characters between spaces. If negative or zero, do not insert spaces.

◆ qtlHexaInt() [2/3]

template<>
QString qtlHexaInt ( quint64  i,
int  width,
int  groupSize 
)
inline

Build an hexadecimal string from an integer value.

Template specialization.

Parameters
[in]iThe integer value to format.
[in]widthThe number of hexadecimal digits. If negative or zero, use the "natural" width for i.
[in]groupSizeThe number of characters between spaces. If negative or zero, do not insert spaces.

◆ qtlHexaInt() [3/3]

template<>
QString qtlHexaInt ( qint64  i,
int  width,
int  groupSize 
)
inline

Build an hexadecimal string from an integer value.

Template specialization.

Parameters
[in]iThe integer value to format.
[in]widthThe number of hexadecimal digits. If negative or zero, use the "natural" width for i.
[in]groupSizeThe number of characters between spaces. If negative or zero, do not insert spaces.

◆ qtlHexa() [1/2]

QString qtlHexa ( const void *  data,
int  size,
Qtl::HexaFlags  flags = Qtl::HexaFlags(Qtl::HexHexa),
int  indent = 0,
int  lineWidth = Qtl::DefautLineWidth,
int  initOffset = 0 
)

Build a multi-line string containing the hexadecimal dump of a memory area.

Parameters
[in]dataStarting address of the memory area to dump.
[in]sizeSize in bytes of the memory area to dump.
[in]flagsA combination of option flags indicating how to format the data.
[in]indentEach line is indented by this number of characters.
[in]lineWidthMaximum number of characters per line. If the flag HexBytesPerLine is specified, maxLineWidth is interpreted as the number of displayed byte values per line.
[in]initOffsetIf the flag HexOffset is specified, an offset in the memory area is displayed at the beginning of each line. In this case, initOffset specified the offset value for the first byte.
Returns
A string containing the formatted hexadecimal dump. Lines are separated with embedded new-line characters ('\n').
See also
Qtl::HexaFlag

◆ qtlHexa() [2/2]

QString qtlHexa ( const QtlByteBlock data,
Qtl::HexaFlags  flags = Qtl::HexaFlags(Qtl::HexHexa),
int  indent = 0,
int  lineWidth = Qtl::DefautLineWidth,
int  initOffset = 0 
)
inline

Build a multi-line string containing the hexadecimal dump of the content of a byte array.

Parameters
[in]dataThe vector of bytes to dump.
[in]flagsA combination of option flags indicating how to format the data.
[in]indentEach line is indented by this number of characters.
[in]lineWidthMaximum number of characters per line. If the flag HexBytesPerLine is specified, maxLineWidth is interpreted as the number of displayed byte values per line.
[in]initOffsetIf the flag HexOffset is specified, an offset in the memory area is displayed at the beginning of each line. In this case, initOffset specified the offset value for the first byte.
Returns
A string containing the formatted hexadecimal dump. Lines are separated with embedded new-line characters ('\n').
See also
Qtl::HexaFlag