Collection of static methods for conversion from and to string.
More...
#include <convert.hpp>
|
| template<typename Source> |
| static std::enable_if<!std::is_convertible< Source, std::string >::value, std::string >::type | toString (const Source &t) noexcept |
| | Converts every type which is either a pod (plain old data) type or is convertible to a string (this means that the operator std::string() is defined).
|
| template<typename Source> |
| static std::enable_if< std::is_convertible< Source, std::string >::value, std::string >::type | toString (const Source &t) noexcept |
| | Converts every type which is either a pod (plain old data) type or is convertible to a string (this means that the operator std::string() is defined).
|
| template<typename TargetType> |
| static bb::Optional< TargetType > | from_string (const char *v) noexcept |
| | convert the input based on the 'TargetType', allowing only numeric types as valid destination types
|
Collection of static methods for conversion from and to string.
int i;
unsigned int a;
static bb::Optional< TargetType > from_string(const char *v) noexcept
convert the input based on the 'TargetType', allowing only numeric types as valid destination types
static std::enable_if<!std::is_convertible< Source, std::string >::value, std::string >::type toString(const Source &t) noexcept
Converts every type which is either a pod (plain old data) type or is convertible to a string (this m...
- Todo
- iox-#260 Refactor 'convert' so that one can use 'into' to directly to convert numbers to strings: 'ClassExpectingAString(iox2::bb::into<iox2::bb::StaticString<100>>(42)'
Definition at line 47 of file convert.hpp.
◆ NumberType
| Enumerator |
|---|
| INTEGER | |
| UNSIGNED_INTEGER | |
| FLOAT | |
Definition at line 49 of file convert.hpp.
◆ from_string() [1/2]
template<typename TargetType>
| bb::Optional< TargetType > iox2::legacy::convert::from_string |
( |
const char * | v | ) |
|
|
staticnoexcept |
convert the input based on the 'TargetType', allowing only numeric types as valid destination types
- Note
- for the 'TargetType' equal to 'std::string,' please include 'iox/std_string_support.hpp'
- Template Parameters
-
| TargetType | the desired target type for converting text |
- Parameters
-
| v | the input string in c type |
- Returns
- an iox2::bb::Optional<TargetType> where, if the return value is iox2::bb::NULLOPT, it indicates a failed conversion process
◆ from_string() [2/2]
template<>
| bb::Optional< std::string > iox2::legacy::convert::from_string |
( |
const char * | v | ) |
|
|
inlinenoexcept |
◆ toString() [1/2]
template<typename Source>
| std::enable_if< std::is_convertible< Source, std::string >::value, std::string >::type iox2::legacy::convert::toString |
( |
const Source & | t | ) |
|
|
staticnoexcept |
Converts every type which is either a pod (plain old data) type or is convertible 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 |
| [in] | t | value which should be converted to a string |
- Returns
- string representation of t
◆ toString() [2/2]
template<typename Source>
| std::enable_if<!std::is_convertible< Source, std::string >::value, std::string >::type iox2::legacy::convert::toString |
( |
const Source & | t | ) |
|
|
staticnoexcept |
Converts every type which is either a pod (plain old data) type or is convertible 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 |
| [in] | t | value which should be converted to a string |
- Returns
- string representation of t
◆ DOUBLE_SIGNALING_NAN_MASK
| uint64_t iox2::legacy::convert::DOUBLE_SIGNALING_NAN_MASK { static_cast<uint64_t>(1) << static_cast<uint64_t>(51) } |
|
staticconstexpr |
◆ FLOAT_SIGNALING_NAN_MASK
| uint32_t iox2::legacy::convert::FLOAT_SIGNALING_NAN_MASK { static_cast<uint32_t>(1) << static_cast<uint32_t>(22) } |
|
staticconstexpr |
◆ STRTOL_BASE
| int32_t iox2::legacy::convert::STRTOL_BASE { 10 } |
|
staticconstexpr |
◆ STRTOLL_BASE
| int32_t iox2::legacy::convert::STRTOLL_BASE { 10 } |
|
staticconstexpr |
◆ STRTOUL_BASE
| int32_t iox2::legacy::convert::STRTOUL_BASE { 10 } |
|
staticconstexpr |
◆ STRTOULL_BASE
| int32_t iox2::legacy::convert::STRTOULL_BASE { 10 } |
|
staticconstexpr |
The documentation for this class was generated from the following files: