ETSI STF525 / Internal Testing test suite
This project provides an internal testing test suite and its associated Test Adapter/Codec
|
This class provide a set of methods for types conversions. More...
#include <converter.hh>
Public Types | |
enum | endian_t { big_endian, little_endian } |
Endianess style. More... | |
Public Member Functions | |
uint8_t | bcd_to_bin (const uint8_t p_value) |
Convert a Binary Coded Decimal value into a binary value. More... | |
uint8_t | bin_to_bcd (const uint8_t p_value) |
Convert a binary value into a Binary Coded Decimal value. More... | |
uint16_t | swap (const uint16_t p_value) |
Swap two bytes length value (e.g. 0xCAFE becomes 0xFECA) More... | |
int16_t | swap (const int16_t p_value) |
uint32_t | swap (const uint32_t p_value) |
Swap four bytes length value (used for littel endian / big endian) More... | |
int32_t | swap (const int32_t p_value) |
std::string | string_to_hexa (const std::string &p_value) |
Convert a string into an hexadecimal string. More... | |
std::string | bytes_to_hexa (const std::vector< uint8_t > &p_value) |
Convert a bytes array int32_t an hexadecimal string. More... | |
std::vector< uint8_t > | hexa_to_bytes (const std::string &p_value) |
Convert an hexadecimal string into a bytes array. More... | |
std::string | time_to_string (const time_t p_time) |
Convert a time in time_t format into a string formated according to RFC 822, 1036, 1123, 2822. More... | |
std::string | time_to_string (const struct tm &p_time) |
Convert a time in struct tm format into a string formated according to RFC 822, 1036, 1123, 2822. More... | |
std::vector< uint8_t > | short_to_bytes (const int16_t p_value, const endian_t p_endianess=big_endian) const |
Convert a 16-bits integer (int16_t) into a bytes array. More... | |
int16_t | bytes_to_short (const std::vector< uint8_t > &p_value, const endian_t p_endianess=big_endian) const |
Convert a bytes array into a 16-bits integer (int16_t) More... | |
std::vector< uint8_t > | int_to_bytes (const int32_t p_value, const endian_t p_endianess=big_endian) const |
Convert a 32-bits integer (int32_t) into a bytes array. More... | |
int32_t | bytes_to_int (const std::vector< uint8_t > &p_value, const endian_t p_endianess=big_endian) const |
Convert a bytes array into a 32-bits integer (int32_t) More... | |
std::vector< uint8_t > | long_to_bytes (const int64_t p_value, const endian_t p_endianess=big_endian) const |
Convert a 64-bits integer (int64_t) into a bytes array. More... | |
int64_t | bytes_to_long (const std::vector< uint8_t > &p_value, const endian_t p_endianess=big_endian) const |
Convert a bytes array into a 64-bits integer (int64_t) More... | |
std::vector< uint8_t > | float_to_bytes (const float p_value) const |
Convert a float value into a bytes array. More... | |
float | bytes_to_float (const std::vector< uint8_t > &p_value) const |
Convert a bytes array into a float. More... | |
std::vector< uint8_t > | string_to_bytes (const std::string &p_value) const |
Convert a string into a bytes array. More... | |
std::string | bytes_to_string (const std::vector< uint8_t > &p_value) const |
Convert a bytes array into a string. More... | |
int32_t | string_to_int (const std::string &p_value) const |
Convert a string into an integer. More... | |
std::string | int_to_string (const int32_t &p_value) const |
Convert an integer into a string. More... | |
std::string | trim (const std::string &p_value, const std::string &p_trim_chars=" \) |
Returns a copy of the string, with leading and trailing special characters omitted. More... | |
std::vector< std::string > | split_arguments_line (const std::string &p_value) |
Convert the provided string into a list of arguments. More... | |
Static Public Member Functions | |
static converter & | get_instance () |
Public accessor to the single object reference. More... | |
Private Member Functions | |
converter () | |
Default private ctor. More... | |
~converter () | |
Default private dtor. More... | |
Static Private Attributes | |
static converter * | instance = NULL |
Unique static object reference of this class. More... | |
This class provide a set of methods for types conversions.
enum converter::endian_t |
|
inlineprivate |
Default private ctor.
|
inlineprivate |
Default private dtor.
|
inline |
Convert a Binary Coded Decimal value into a binary value.
[in] | p_value | The BDC value |
|
inline |
Convert a binary value into a Binary Coded Decimal value.
[in] | p_value | The binary value |
|
inline |
Convert a bytes array into a float.
[in] | p_value | The bytes array |
std::string converter::bytes_to_hexa | ( | const std::vector< uint8_t > & | p_value | ) |
Convert a bytes array int32_t an hexadecimal string.
[in] | p_value | The bytes array value |
|
inline |
Convert a bytes array into a 32-bits integer (int32_t)
[in] | p_value | The bytes array |
[in] | p_endianess | Endianess style. Default: big_endian |
|
inline |
Convert a bytes array into a 64-bits integer (int64_t)
[in] | p_value | The bytes array |
[in] | p_endianess | Endianess style. Default: big_endian |
|
inline |
Convert a bytes array into a 16-bits integer (int16_t)
[in] | p_value | The bytes array |
[in] | p_endianess | Endianess style. Default: big_endian |
|
inline |
Convert a bytes array into a string.
[in] | p_value | The bytes array value |
|
inline |
Convert a float value into a bytes array.
[in] | p_value | The float value |
|
inlinestatic |
Public accessor to the single object reference.
std::vector< uint8_t > converter::hexa_to_bytes | ( | const std::string & | p_value | ) |
Convert an hexadecimal string into a bytes array.
[in] | p_value | The hexadecimal value |
|
inline |
Convert a 32-bits integer (int32_t) into a bytes array.
[in] | p_value | The 32-bits integer value |
[in] | p_endianess | Endianess style. Default: big_endian |
|
inline |
Convert an integer into a string.
[in] | p_value | The integer value |
|
inline |
Convert a 64-bits integer (int64_t) into a bytes array.
[in] | p_value | The 64-bits integer value |
[in] | p_endianess | Endianess style. Default: big_endian |
|
inline |
Convert a 16-bits integer (int16_t) into a bytes array.
[in] | p_value | The 16-bits integer value |
[in] | p_endianess | Endianess style. Default: big_endian |
std::vector< std::string > converter::split_arguments_line | ( | const std::string & | p_value | ) |
Convert the provided string into a list of arguments.
[in] | p_value | The string value |
|
inline |
Convert a string into a bytes array.
[in] | p_value | The string value |
std::string converter::string_to_hexa | ( | const std::string & | p_value | ) |
Convert a string into an hexadecimal string.
[in] | p_value | The string value |
|
inline |
Convert a string into an integer.
[in] | p_value | The string value |
uint16_t converter::swap | ( | const uint16_t | p_value | ) |
Swap two bytes length value (e.g. 0xCAFE becomes 0xFECA)
[in] | p_value | The value to swap |
|
inline |
uint32_t converter::swap | ( | const uint32_t | p_value | ) |
Swap four bytes length value (used for littel endian / big endian)
[in] | p_value | The value to swap |
|
inline |
std::string converter::time_to_string | ( | const time_t | p_time | ) |
Convert a time in time_t format into a string formated according to RFC 822, 1036, 1123, 2822.
[in] | p_time | The time to convert in time_t format |
std::string converter::time_to_string | ( | const struct tm & | p_time | ) |
Convert a time in struct tm format into a string formated according to RFC 822, 1036, 1123, 2822.
[in] | p_time | The time to convert in struct tm format |
std::string converter::trim | ( | const std::string & | p_value, |
const std::string & | p_trim_chars = " \t" |
||
) |
Returns a copy of the string, with leading and trailing special characters omitted.
[in] | p_value | The string value |
[in] | p_trim_chars | The special characters to be omitted. Default: ' ' and TAB |
|
staticprivate |
Unique static object reference of this class.