iox::cxx::convert🔗
Collection of static methods for conversion from and to string. More...
#include <convert.hpp>
Public Types🔗
Name | |
---|---|
enum | NumberType |
Public Functions🔗
Name | |
---|---|
template \<typename Source > std::enable_if<!std::is_convertible< Source, std::string >::value, std::string >::type |
toString(const Source & t) Converts every type which is either a pod (plain old data) type or is convertable to a string (this means that the operator std::string() is defined) |
template \<typename Source > std::enable_if< std::is_convertible< Source, std::string >::value, std::string >::type |
toString(const Source & t) Converts every type which is either a pod (plain old data) type or is convertable to a string (this means that the operator std::string() is defined) |
template \<typename Destination > bool |
fromString(const char * v, Destination & dest) Sets dest from a given string. If the conversion fails false is returned and the value of dest is undefined. |
bool | stringIsNumber(const char * v, const NumberType type) checks if a given string v is a number |
bool | fromString(const char * v, char & dest) |
bool | fromString(const char * v, string< 100 > & dest) |
bool | fromString(const char * v, float & dest) |
bool | fromString(const char * v, double & dest) |
bool | fromString(const char * v, long double & dest) |
bool | fromString(const char * v, uint64_t & dest) |
bool | fromString(const char * v, uint32_t & dest) |
bool | fromString(const char * v, uint16_t & dest) |
bool | fromString(const char * v, uint8_t & dest) |
bool | fromString(const char * v, int64_t & dest) |
bool | fromString(const char * v, int32_t & dest) |
bool | fromString(const char * v, int16_t & dest) |
bool | fromString(const char * v, int8_t & dest) |
bool | fromString(const char * v, bool & dest) |
Public Attributes🔗
Name | |
---|---|
constexpr int32_t | STRTOULL_BASE |
Detailed Description🔗
class iox::cxx::convert;
Collection of static methods for conversion from and to string.
std::string number = cxx::convert::toString(123);
std::string someClass = cxx::convert::toString(someToStringConvertableObject);
int i;
unsigned int a;
if ( cxx::convert::fromString("123", i) ) {} // will succeed
if ( cxx::convert::fromString("-123", a) ) {} // will fail since -123 is not unsigned
Public Types Documentation🔗
enum NumberType🔗
Enumerator | Value | Description |
---|---|---|
INTEGER | ||
UNSIGNED_INTEGER | ||
FLOAT |
Public Functions Documentation🔗
function toString🔗
template <typename Source >
static inline std::enable_if<!std::is_convertible< Source, std::string >::value, std::string >::type toString(
const Source & t
)
Converts every type which is either a pod (plain old data) type or is convertable to a string (this means that the operator std::string() is defined)
Parameters:
- Source type of the value which should be converted to a string
- t value which should be converted to a string
Return: string representation of t
function toString🔗
template <typename Source >
static std::enable_if< std::is_convertible< Source, std::string >::value, std::string >::type toString(
const Source & t
)
Converts every type which is either a pod (plain old data) type or is convertable to a string (this means that the operator std::string() is defined)
Parameters:
- Source type of the value which should be converted to a string
- t value which should be converted to a string
Return: string representation of t
function fromString🔗
template <typename Destination >
static bool fromString(
const char * v,
Destination & dest
)
Sets dest from a given string. If the conversion fails false is returned and the value of dest is undefined.
Parameters:
- v string which contains the value of dest
- dest destination to which the value should be written
Return: false = if the conversion fails otherwise true
function stringIsNumber🔗
static inline bool stringIsNumber(
const char * v,
const NumberType type
)
checks if a given string v is a number
Parameters:
- v string which contains the number
- type is the expected contained type in v
Return: true if the given string is a number, otherwise false
function fromString🔗
static inline bool fromString(
const char * v,
char & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
string< 100 > & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
float & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
double & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
long double & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
uint64_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
uint32_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
uint16_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
uint8_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
int64_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
int32_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
int16_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
int8_t & dest
)
function fromString🔗
static inline bool fromString(
const char * v,
bool & dest
)
Public Attributes Documentation🔗
variable STRTOULL_BASE🔗
static constexpr int32_t STRTOULL_BASE = 10;
Updated on 31 May 2022 at 15:29:15 CEST