#include "rtabmap/utilite/UConversion.h"
#include "rtabmap/utilite/UStl.h"
#include <sstream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
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 | uBytes2Str (const std::vector< unsigned char > &bytes) |
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, int precision, bool fixed) |
std::string | uNumber2Str (double number, int precision, bool fixed) |
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) |
bool | uStr2Bool (const std::string &str) |
std::vector< unsigned char > | uStr2Bytes (const std::string &str) |
double | uStr2Double (const std::string &str) |
float | uStr2Float (const std::string &str) |
int | uStr2Int (const std::string &str) |
std::string | uToLowerCase (const std::string &str) |
std::string | uToUpperCase (const std::string &str) |
Variables | |
static const char | HEX2ASCII [256][2] |
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 :
c | the ascii character |
Definition at line 288 of file UConversion.cpp.
std::string uBool2Str | ( | bool | boolean | ) |
Convert a bool to a string. The format used is "true" and "false".
boolean | the boolean to convert in a string |
Definition at line 156 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 :
bytes | the bytes array |
bytesLen | the length of the bytes array |
Definition at line 203 of file UConversion.cpp.
std::string 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').
bytes | the array of bytes |
Definition at line 188 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 365 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 322 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 :
c | the hexadecimal value |
rightPart | If we want the character corresponding to the right of left part (4 bits) of the byte value. |
Definition at line 276 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 :
hex | the hexadecimal string |
Definition at line 223 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 :
hex | the hexadecimal string |
bytesLen | the hexadecimal string length |
Definition at line 228 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 :
hex | the hexadecimal string |
Definition at line 250 of file UConversion.cpp.
std::string uNumber2Str | ( | unsigned int | number | ) |
Convert a number (unsigned int) to a string.
number | the number to convert in a string |
Definition at line 91 of file UConversion.cpp.
std::string uNumber2Str | ( | int | number | ) |
Convert a number (int) to a string.
number | the number to convert in a string |
Definition at line 98 of file UConversion.cpp.
std::string uNumber2Str | ( | float | number, |
int | precision = 6 , |
||
bool | fixed = false |
||
) |
Convert a number (float) to a string.
number | the number to convert in a string |
Definition at line 105 of file UConversion.cpp.
std::string uNumber2Str | ( | double | number, |
int | precision = 6 , |
||
bool | fixed = false |
||
) |
Convert a number (double) to a string.
number | the number to convert in a string |
Definition at line 115 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 :
str | the string |
before | the character to be replaced by the new one |
after | the new character replacing the old one |
Definition at line 33 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 :
str | the string |
before | the character to be replaced by the new one |
after | the new string replacing the old character |
Definition at line 46 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.
str | the string to convert in a boolean |
Definition at line 170 of file UConversion.cpp.
bool uStr2Bool | ( | const std::string & | str | ) |
Definition at line 175 of file UConversion.cpp.
std::vector<unsigned char> uStr2Bytes | ( | const std::string & | str | ) |
Convert a string to an array of bytes including the null character ('\0').
str | the string |
Definition at line 180 of file UConversion.cpp.
double uStr2Double | ( | const std::string & | str | ) |
Convert a string to a double independent of the locale (comma/dot).
the | string |
Definition at line 147 of file UConversion.cpp.
float uStr2Float | ( | const std::string & | str | ) |
Convert a string to a float independent of the locale (comma/dot).
the | string |
Definition at line 138 of file UConversion.cpp.
int uStr2Int | ( | const std::string & | str | ) |
Convert a string to an integer.
the | string |
Definition at line 125 of file UConversion.cpp.
std::string uToLowerCase | ( | const std::string & | str | ) |
Transform characters from a string to lower case. Example :
str | the string |
Definition at line 77 of file UConversion.cpp.
std::string uToUpperCase | ( | const std::string & | str | ) |
Transform characters from a string to upper case. Example :
str | the string |
Definition at line 63 of file UConversion.cpp.
|
static |
Definition at line 256 of file UConversion.cpp.