Functions
UConversion.h File Reference

Some conversion functions. More...

#include "rtabmap/utilite/UtiLiteExp.h"
#include <string>
#include <vector>
#include <stdarg.h>
Include dependency graph for UConversion.h:

Go to the source code of this file.

Functions

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

Detailed Description

Some conversion functions.

This contains functions to do some convenient conversion like uNumber2str(), uBytes2Hex() or uHex2Bytes().

Definition in file UConversion.h.

Function Documentation

unsigned char UTILITE_EXP 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 :

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

Definition at line 273 of file UConversion.cpp.

std::string UTILITE_EXP 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 141 of file UConversion.cpp.

std::string UTILITE_EXP 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 :

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

Definition at line 188 of file UConversion.cpp.

std::string UTILITE_EXP uBytes2Str ( const std::vector< unsigned char > &  bytes)

Convert an array of bytes to string, the array of bytes must end with the null character ('\0').

Parameters
bytesthe array of bytes
Returns
the string

Definition at line 173 of file UConversion.cpp.

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

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

Definition at line 350 of file UConversion.cpp.

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

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

Definition at line 307 of file UConversion.cpp.

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

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

1 unsigned char F = uHex2Ascii(0xFA, false);
2 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 261 of file UConversion.cpp.

std::vector<char> UTILITE_EXP 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 :

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

Definition at line 208 of file UConversion.cpp.

std::vector<char> UTILITE_EXP 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 :

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

Definition at line 213 of file UConversion.cpp.

std::string UTILITE_EXP 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 :

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

Definition at line 235 of file UConversion.cpp.

std::string UTILITE_EXP 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 90 of file UConversion.cpp.

std::string UTILITE_EXP uNumber2Str ( int  number)

Convert a number (int) to a string.

Parameters
numberthe number to convert in a string
Returns
the string

Definition at line 97 of file UConversion.cpp.

std::string UTILITE_EXP uNumber2Str ( float  number)

Convert a number (float) to a string.

Parameters
numberthe number to convert in a string
Returns
the string

Definition at line 104 of file UConversion.cpp.

std::string UTILITE_EXP uNumber2Str ( double  number)

Convert a number (double) to a string.

Parameters
numberthe number to convert in a string
Returns
the string

Definition at line 111 of file UConversion.cpp.

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

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

1 std::string str = "Hello";
2 uReplaceChar(str, 'l', 'p');
3 // 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 32 of file UConversion.cpp.

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

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

1 std::string str = "Hello";
2 uReplaceChar(str, 'o', "oween");
3 // 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 45 of file UConversion.cpp.

bool UTILITE_EXP 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 155 of file UConversion.cpp.

bool UTILITE_EXP uStr2Bool ( const std::string &  str)

Definition at line 160 of file UConversion.cpp.

std::vector<unsigned char> UTILITE_EXP uStr2Bytes ( const std::string &  str)

Convert a string to an array of bytes including the null character ('\0').

Parameters
strthe string
Returns
the array of bytes

Definition at line 165 of file UConversion.cpp.

double UTILITE_EXP uStr2Double ( const std::string &  str)

Convert a string to a double independent of the locale (comma/dot).

Parameters
thestring
Returns
the number

Definition at line 132 of file UConversion.cpp.

float UTILITE_EXP uStr2Float ( const std::string &  str)

Convert a string to a float independent of the locale (comma/dot).

Parameters
thestring
Returns
the number

Definition at line 123 of file UConversion.cpp.

int UTILITE_EXP uStr2Int ( const std::string &  str)

Convert a string to an integer.

Parameters
thestring
Returns
the number

Definition at line 118 of file UConversion.cpp.

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

Transform characters from a string to lower case. Example :

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

Definition at line 76 of file UConversion.cpp.

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

Transform characters from a string to upper case. Example :

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

Definition at line 62 of file UConversion.cpp.



rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:37:07