Functions | Variables
UConversion.cpp File Reference
#include "utilite/UConversion.h"
#include <sstream>
#include <string.h>
#include <stdio.h>
Include dependency graph for UConversion.cpp:

Go to the source code of this file.

Functions

unsigned char uAscii2Hex (const unsigned char &c)
std::string uBool2Str (bool boolean)
std::string uBytes2Hex (const char *bytes, unsigned int bytesLen)
std::string uFormat (const char *fmt,...)
std::string uFormatv (const char *fmt, va_list args)
unsigned char uHex2Ascii (const unsigned char &c, bool rightPart)
std::vector< char > uHex2Bytes (const std::string &hex)
std::vector< char > uHex2Bytes (const char *hex, int hexLen)
std::string uHex2Str (const std::string &hex)
std::string uNumber2Str (unsigned int number)
std::string uNumber2Str (int number)
std::string uNumber2Str (float number)
std::string uNumber2Str (double number)
std::string uReplaceChar (const std::string &str, char before, char after)
std::string uReplaceChar (const std::string &str, char before, const std::string &after)
bool uStr2Bool (const char *str)
std::string uToLowerCase (const std::string &str)
std::string uToUpperCase (const std::string &str)

Variables

static const char HEX2ASCII [256][2]

Function Documentation

unsigned char uAscii2Hex ( const unsigned char &  c)

Convert an ascii character to an hexadecimal value (right 4 bits). Characters can be in upper or lower case. Example :

 unsigned char hex = uAscii2Hex('F');
 // The results is hex = 0x0F;
See also:
hex2ascii
Parameters:
cthe ascii character
Returns:
the hexadecimal value

Definition at line 221 of file UConversion.cpp.

std::string uBool2Str ( bool  boolean)

Convert a bool to a string. The format used is "true" and "false".

Parameters:
booleanthe boolean to convert in a string
Returns:
the string

Definition at line 117 of file UConversion.cpp.

std::string uBytes2Hex ( const char *  bytes,
unsigned int  bytesLen 
)

Convert a bytes array to an hexadecimal string. The resulting string is twice the size of the bytes array. The hexadecimal Characters are in upper case. Example :

 char bytes[] = {0x3F};
 std::string hex = uBytes2Hex(bytes, 1);
 // The string constains "3F".
Parameters:
bytesthe bytes array
bytesLenthe length of the bytes array
Returns:
the hexadecimal string

Definition at line 136 of file UConversion.cpp.

std::string uFormat ( const char *  fmt,
  ... 
)

Format a string like printf, and return it as a std::string

Definition at line 294 of file UConversion.cpp.

std::string uFormatv ( const char *  fmt,
va_list  ap 
)

Format a string like printf, and return it as a std::string

Definition at line 255 of file UConversion.cpp.

unsigned char uHex2Ascii ( const unsigned char &  c,
bool  rightPart 
)

Convert hexadecimal (left or right part) value to an ascii character. Example :

 unsigned char F = uHex2Ascii(0xFA, false);
 unsigned char A = uHex2Ascii(0xFA, true);
See also:
ascii2hex
Parameters:
cthe hexadecimal value
rightPartIf we want the character corresponding to the right of left part (4 bits) of the byte value.
Returns:
the ascii character (in upper case)

Definition at line 209 of file UConversion.cpp.

std::vector<char> uHex2Bytes ( const std::string &  hex)

Convert an hexadecimal string to a bytes array. The string must be pair length. The hexadecimal Characters can be in upper or lower case. Example :

 std::string hex = "1f3B";
 std::vector<char> bytes = uHex2Bytes(hex);
 // The array contains {0x1F, 0x3B}.
Parameters:
hexthe hexadecimal string
Returns:
the bytes array

Definition at line 156 of file UConversion.cpp.

std::vector<char> uHex2Bytes ( const char *  hex,
int  hexLen 
)

Convert an hexadecimal string to a bytes array. The string must be pair length. The hexadecimal Characters can be in upper or lower case. Example :

 std::vector<char> bytes = uHex2Bytes("1f3B", 4);
 // The array contains {0x1F, 0x3B}.
Parameters:
hexthe hexadecimal string
bytesLenthe hexadecimal string length
Returns:
the bytes array

Definition at line 161 of file UConversion.cpp.

std::string uHex2Str ( const std::string &  hex)

Convert an hexadecimal string to an ascii string. A convenient way when using only strings. The hexadecimal str MUST not contains any null values 0x00 ("00"). Think to use of hex2bytes() to handle 0x00 values. Characters can be in upper or lower case. Example :

 std::string str = uHex2Str("48656C6C4F21");
 // The string contains "Hello!".
See also:
hex2bytes
Parameters:
hexthe hexadecimal string
Returns:
the ascii string

Definition at line 183 of file UConversion.cpp.

std::string uNumber2Str ( unsigned int  number)

Convert a number (unsigned int) to a string.

Parameters:
numberthe number to convert in a string
Returns:
the string

Definition at line 89 of file UConversion.cpp.

std::string uNumber2Str ( int  number)

Convert a number (int) to a string.

Parameters:
numberthe number to convert in a string
Returns:
the string

Definition at line 96 of file UConversion.cpp.

std::string uNumber2Str ( float  number)

Convert a number (float) to a string.

Parameters:
numberthe number to convert in a string
Returns:
the string

Definition at line 103 of file UConversion.cpp.

std::string uNumber2Str ( double  number)

Convert a number (double) to a string.

Parameters:
numberthe number to convert in a string
Returns:
the string

Definition at line 110 of file UConversion.cpp.

std::string uReplaceChar ( const std::string &  str,
char  before,
char  after 
)

Replace old characters in a string to new ones. Example :

 std::string str = "Hello";
 uReplaceChar(str, 'l', 'p');
 // The results is str = "Heppo";
Parameters:
strthe string
beforethe character to be replaced by the new one
afterthe new character replacing the old one
Returns:
the modified string

Definition at line 31 of file UConversion.cpp.

std::string uReplaceChar ( const std::string &  str,
char  before,
const std::string &  after 
)

Replace old characters in a string with the specified string. Example :

 std::string str = "Hello";
 uReplaceChar(str, 'o', "oween");
 // The results is str = "Helloween";
Parameters:
strthe string
beforethe character to be replaced by the new one
afterthe new string replacing the old character
Returns:
the modified string

Definition at line 44 of file UConversion.cpp.

bool uStr2Bool ( const char *  str)

Convert a string to a boolean. The format used is : "false", "FALSE" or "0" give false. All others give true.

Parameters:
strthe string to convert in a boolean
Returns:
the boolean

Definition at line 131 of file UConversion.cpp.

std::string uToLowerCase ( const std::string &  str)

Transform characters from a string to lower case. Example :

 std::string str = "HELLO!";
 str = uToLowerCase(str, false);
 //str is now equal to "hello!"
Parameters:
strthe string
Returns:
the modified string

Definition at line 75 of file UConversion.cpp.

std::string uToUpperCase ( const std::string &  str)

Transform characters from a string to upper case. Example :

 std::string str = "hello!";
 str = uToUpperCase(str);
 //str is now equal to "HELLO!"
Parameters:
strthe string
Returns:
the modified string

Definition at line 61 of file UConversion.cpp.


Variable Documentation

const char HEX2ASCII[256][2] [static]
Initial value:
{
        {'0','0'},{'0','1'},{'0','2'},{'0','3'},{'0','4'},{'0','5'},{'0','6'},{'0','7'},{'0','8'},{'0','9'},{'0','A'},{'0','B'},{'0','C'},{'0','D'},{'0','E'},{'0','F'},
        {'1','0'},{'1','1'},{'1','2'},{'1','3'},{'1','4'},{'1','5'},{'1','6'},{'1','7'},{'1','8'},{'1','9'},{'1','A'},{'1','B'},{'1','C'},{'1','D'},{'1','E'},{'1','F'},
        {'2','0'},{'2','1'},{'2','2'},{'2','3'},{'2','4'},{'2','5'},{'2','6'},{'2','7'},{'2','8'},{'2','9'},{'2','A'},{'2','B'},{'2','C'},{'2','D'},{'2','E'},{'2','F'},
        {'3','0'},{'3','1'},{'3','2'},{'3','3'},{'3','4'},{'3','5'},{'3','6'},{'3','7'},{'3','8'},{'3','9'},{'3','A'},{'3','B'},{'3','C'},{'3','D'},{'3','E'},{'3','F'},
        {'4','0'},{'4','1'},{'4','2'},{'4','3'},{'4','4'},{'4','5'},{'4','6'},{'4','7'},{'4','8'},{'4','9'},{'4','A'},{'4','B'},{'4','C'},{'4','D'},{'4','E'},{'4','F'},
        {'5','0'},{'5','1'},{'5','2'},{'5','3'},{'5','4'},{'5','5'},{'5','6'},{'5','7'},{'5','8'},{'5','9'},{'5','A'},{'5','B'},{'5','C'},{'5','D'},{'5','E'},{'5','F'},
        {'6','0'},{'6','1'},{'6','2'},{'6','3'},{'6','4'},{'6','5'},{'6','6'},{'6','7'},{'6','8'},{'6','9'},{'6','A'},{'6','B'},{'6','C'},{'6','D'},{'6','E'},{'6','F'},
        {'7','0'},{'7','1'},{'7','2'},{'7','3'},{'7','4'},{'7','5'},{'7','6'},{'7','7'},{'7','8'},{'7','9'},{'7','A'},{'7','B'},{'7','C'},{'7','D'},{'7','E'},{'7','F'},
        {'8','0'},{'8','1'},{'8','2'},{'8','3'},{'8','4'},{'8','5'},{'8','6'},{'8','7'},{'8','8'},{'8','9'},{'8','A'},{'8','B'},{'8','C'},{'8','D'},{'8','E'},{'8','F'},
        {'9','0'},{'9','1'},{'9','2'},{'9','3'},{'9','4'},{'9','5'},{'9','6'},{'9','7'},{'9','8'},{'9','9'},{'9','A'},{'9','B'},{'9','C'},{'9','D'},{'9','E'},{'9','F'},
        {'A','0'},{'A','1'},{'A','2'},{'A','3'},{'A','4'},{'A','5'},{'A','6'},{'A','7'},{'A','8'},{'A','9'},{'A','A'},{'A','B'},{'A','C'},{'A','D'},{'A','E'},{'A','F'},
        {'B','0'},{'B','1'},{'B','2'},{'B','3'},{'B','4'},{'B','5'},{'B','6'},{'B','7'},{'B','8'},{'B','9'},{'B','A'},{'B','B'},{'B','C'},{'B','D'},{'B','E'},{'B','F'},
        {'C','0'},{'C','1'},{'C','2'},{'C','3'},{'C','4'},{'C','5'},{'C','6'},{'C','7'},{'C','8'},{'C','9'},{'C','A'},{'C','B'},{'C','C'},{'C','D'},{'C','E'},{'C','F'},
        {'D','0'},{'D','1'},{'D','2'},{'D','3'},{'D','4'},{'D','5'},{'D','6'},{'D','7'},{'D','8'},{'D','9'},{'D','A'},{'D','B'},{'D','C'},{'D','D'},{'D','E'},{'D','F'},
        {'E','0'},{'E','1'},{'E','2'},{'E','3'},{'E','4'},{'E','5'},{'E','6'},{'E','7'},{'E','8'},{'E','9'},{'E','A'},{'E','B'},{'E','C'},{'E','D'},{'E','E'},{'E','F'},
        {'F','0'},{'F','1'},{'F','2'},{'F','3'},{'F','4'},{'F','5'},{'F','6'},{'F','7'},{'F','8'},{'F','9'},{'F','A'},{'F','B'},{'F','C'},{'F','D'},{'F','E'},{'F','F'}
}

Definition at line 189 of file UConversion.cpp.



find_object_2d
Author(s): Mathieu Labbe
autogenerated on Thu Aug 27 2015 13:00:33