OpenHantek
Loading...
Searching...
No Matches
printutils.cpp File Reference
#include <cmath>
#include <QApplication>
#include <QLocale>
#include <QStringList>
#include "utils/printutils.h"

Functions

QString valueToString (double value, Unit unit, int precision)
 Converts double to string containing value and (prefix+)unit (Counterpart to stringToValue).
double stringToValue (const QString &text, Unit unit, bool *ok)
 Converts string containing value and (prefix+)unit to double (Counterpart to valueToString).
QString hexDump (unsigned char *data, unsigned int length)
 Returns the hex or decimal dump for the given data.
QString decDump (unsigned char *data, unsigned int length)
QString hexdecDump (unsigned char *data, unsigned int length)
unsigned int hexParse (const QString dump, uint8_t *data, unsigned int length)

Function Documentation

◆ decDump()

QString decDump ( unsigned char * data,
unsigned int length )

◆ hexdecDump()

QString hexdecDump ( unsigned char * data,
unsigned int length )

◆ hexDump()

QString hexDump ( unsigned char * data,
unsigned int length )

Returns the hex or decimal dump for the given data.

Parameters
dataPointer to the data bytes that should be dumped.
lengthThe length of the data array in bytes.
Returns
String with the dump of the data.

◆ hexParse()

unsigned int hexParse ( const QString dump,
uint8_t * data,
unsigned int length )

◆ stringToValue()

double stringToValue ( const QString & text,
Unit unit,
bool * ok = nullptr )

Converts string containing value and (prefix+)unit to double (Counterpart to valueToString).

Parameters
textThe text containing the value and its unit.
unitThe base unit of the value.
okPointer to a success-flag, true on success, false on error.
Returns
Decoded value.

◆ valueToString()

QString valueToString ( double value,
Unit unit,
int precision = -1 )

Converts double to string containing value and (prefix+)unit (Counterpart to stringToValue).

Parameters
valueThe value in prefixless units.
unitThe unit for the value.
precisionSignificant digits, 0 for integer, -1 for auto.
Returns
String with the value and unit.