Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Convert Class Reference

Class for various conversions. More...

#include <Convert.h>

List of all members.

Public Methods

 Convert ()
 Standard constructor.

QString X10ToBinStr (IOInfoBin)
 Converts a binary array into an string. More...

QString X10ToHexStr (IOInfoBin)
 Converts a binary array into a string containing the corresponding hexadecimal value. More...

bool X10ToASCII (IOInfoBin io, char *cres, int asciiarraylen, int &length, bool singlechar=TRUE)
 Converts a binary string into ASCII representation. More...

bool X10ToDec (IOInfoBin io, int &ires)
 Converts a binary string into decimal representation. More...

int binStrToInt (QString)
 Converts a string representing a binary number into an integer. More...

IOInfoBin binStrToX10 (int maxlen, const QString)
 Converts a string representing a binary value into a binary array. More...

QString binStrToHexStr (const QString)
 Converts a binary string into a hexadecimal string. More...

bool binStrToASCII (const QString, char *ascii, int arraymaxlen, int &len, bool singlechar=TRUE, int arrayoffset=0)
 Converts a string representing a binary number into ASCII representation. More...

bool hexStrToInt (QString, int &)
 Converts a string representing a hexadecimal number into an integer. More...

IOInfoBin hexStrToX10 (int, const QString)
 Converts a string representing a hexadecimal number into a binary array. More...

QString hexStrToBinStr (int maxlen, const QString)
 Converts a hexadecimal string into a binary string. More...

bool hexStrToASCII (const QString, char *ascii, int arraymaxlen, int &len, bool singlechar=TRUE)
 Converts a string representing a hexadecimal number into ASCII representation. More...

IOInfoBin asciiToX10 (int maxlen, const char ascii)
 Converts a single ASCII character into binary representation. More...

IOInfoBin asciiToX10 (int maxlen, const char *ascii, int asciilen)
 Converts a string of ASCII characters into binary representation. More...

QString asciiToBinStr (int maxlen, const char ascii)
 Converts a single ASCII character into a string representing the binary number. More...

QString asciiToBinStr (int maxlen, const char *ascii, int asciilen)
 Converts an ASCII string into a string representing the binary number. More...

QString asciiToHexStr (const char ascii)
 Converts a single ASCII character into hexadecimal representation. More...

QString asciiToHexStr (const char *ascii, int asciilen)
 Converts an ASCII string into a string representing the hexadecimal number. More...

void resolveEscapes (QString estr, char *cres, int arraymaxlen, int &length)
 Resolves the escape symbols in a string of ASCII characters. More...

QString asciiToReadableStr (const char *ascii, int asciilength)
 Converts a string of ASCII characters into a readable string. More...


Static Public Methods

QString intToBinStr (int c, int len)
 Converts an integer into a string representing the binary value of that integer. More...


Detailed Description

Class for various conversions.

This class is responsible for all sorts of conversions between int, QString, binary, hexadecimal, ASCII.


Member Function Documentation

bool Convert::X10ToASCII IOInfoBin io,
char * ascii,
int asciiarraylen,
int & length,
bool singlechar = TRUE
 

Converts a binary string into ASCII representation.

Parameters:
io   Object containing binary information
ascii   Resulting array of ascii characters
asciiarraylen   Length of ascii
length   Number of characters that have been converted
singlechar   If TRUE only a single character is converted
Returns:
TRUE if successful

QString Convert::X10ToBinStr IOInfoBin io
 

Converts a binary array into an string.

Parameters:
io   Object containing binary information
Returns:
converted string

bool Convert::X10ToDec IOInfoBin io,
int & dec
 

Converts a binary string into decimal representation.

Parameters:
io   Object containing binary information
dec   Resulting decimal representation
Returns:
TRUE if successful

QString Convert::X10ToHexStr IOInfoBin invio
 

Converts a binary array into a string containing the corresponding hexadecimal value.

Parameters:
len   length of binary array
bininv   binary data
Returns:
string with hexadecimal data

QString Convert::asciiToBinStr int maxlen,
const char * ascii,
int asciilen
 

Converts an ASCII string into a string representing the binary number.

Parameters:
maxlen   Maximum length of the binary string
ascii   Array holding the ASCII characters
asciilen   Length of the string of ASCII characters (can be smaller than the array size)
Returns:
The string representing the binary number

QString Convert::asciiToBinStr int maxlen,
const char ascii
 

Converts a single ASCII character into a string representing the binary number.

Parameters:
maxlen   Maximum length of the binary string
ascii   The ASCII character to convert
Returns:
The string representing the binary number

QString Convert::asciiToHexStr const char * ascii,
int asciilen
 

Converts an ASCII string into a string representing the hexadecimal number.

Parameters:
ascii   Array holding the ASCII characters
asciilen   Length of the string of ASCII characters (can be smaller than the array size)
Returns:
The string representing the hexadecimal number

QString Convert::asciiToHexStr const char ascii
 

Converts a single ASCII character into hexadecimal representation.

Parameters:
ascii   ASCII character to convert.
Returns:
String representing the hexadecimal number

QString Convert::asciiToReadableStr const char * asciiarray,
int asciilength
 

Converts a string of ASCII characters into a readable string.

This means, escape characters are introduces where necessary.

Parameters:
asciiarray   Array of ASCII characters
asciilength   Number of characters in the array
Returns:
Resulting string

IOInfoBin Convert::asciiToX10 int maxlen,
const char * ascii,
int asciilen
 

Converts a string of ASCII characters into binary representation.

Parameters:
maxlen   Maximum length of the binary string
ascii   Array of ASCII characters
asciilen   Number of ASCII characters stores in the array
Returns:
Object with the binary number

IOInfoBin Convert::asciiToX10 int maxlen,
const char ascii
 

Converts a single ASCII character into binary representation.

Parameters:
maxlen   Maximum length of the binary string
ascii   ASCII character to convert
Returns:
Object with the binary number

bool Convert::binStrToASCII const QString bin,
char * ascii,
int arraymaxlen,
int & length,
bool singlechar = TRUE,
int arrayoffset = 0
 

Converts a string representing a binary number into ASCII representation.

Parameters:
bin   String with the binary number
ascii   Array holding the resulting string of ASCII characters
arraymaxlen   Length of the array ascii
length   Number of converted characters
singlechar   If TRUE only the first character is converted.
Returns:
TRUE if successful

QString Convert::binStrToHexStr const QString bin
 

Converts a binary string into a hexadecimal string.

Parameters:
bin   string containing the binary value
Returns:
string containing the hexadecimal value

int Convert::binStrToInt QString s
 

Converts a string representing a binary number into an integer.

Parameters:
s   string to convert
Returns:
converted value

IOInfoBin Convert::binStrToX10 int num,
const QString cs
 

Converts a string representing a binary value into a binary array.

A binary array is an array of chars where each char represents one bit. The bit with the lowest index is the MSB. Value of 0 means 0, 1 means 1 and 2 means 'don't care' The end of the binary array is marked with a decimal '10'.

Parameters:
num   number of bits to convert (lenth of buffer-1)
cs   string to convert
buffer   binary array

bool Convert::hexStrToASCII const QString hex,
char * ascii,
int maxarraylen,
int & length,
bool singlechar = TRUE
 

Converts a string representing a hexadecimal number into ASCII representation.

Parameters:
bin   String with the hexadecimal number
ascii   Array holding the resulting string of ASCII characters
maxarraylen   Length of the array ascii
length   Number of converted characters
singlechar   If TRUE only the first character is converted.
Returns:
TRUE if successful

QString Convert::hexStrToBinStr int maxlen,
const QString hex
 

Converts a hexadecimal string into a binary string.

Parameters:
maxlen   length the binary string will have
hex   string containing a hexadecimal number
Returns:
string containing the binary number

bool Convert::hexStrToInt QString hex,
int & ires
 

Converts a string representing a hexadecimal number into an integer.

Parameters:
hex   String with the hexidecimal number
ires   Resulting integer value
Returns:
TRUE if successful

IOInfoBin Convert::hexStrToX10 int len,
const QString hex
 

Converts a string representing a hexadecimal number into a binary array.

Parameters:
len   number of bits to convert (length of binary array)
hex   string containing hexadecimal number
bin   buffer for resulting binary data

QString Convert::intToBinStr int c,
int len
[static]
 

Converts an integer into a string representing the binary value of that integer.

Parameters:
c   integer to convert
len   length of resulting string
Returns:
binary string

void Convert::resolveEscapes QString estr,
char * cres,
int arraymaxlen,
int & length
 

Resolves the escape symbols in a string of ASCII characters.

Example: \d is resolved into 0123456789 (digit)

Parameters:
estr   String of characters possibly with escape symbols
cres   Resulting array of ascii characters
arraymaxlen   Length of the array
length   Number characters stores in the array after resolution


The documentation for this class was generated from the following files:
Generated at Fri Apr 11 22:37:15 2003 for Qfsm by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001