ADTF  3.18.2
ToNumericConverter

Safe convenience string-to-numeric conversion methods for generic programming. More...

Static Public Member Functions

static bool convert (const char *from, bool &to)
 Safely convert a string to a boolean value. More...
 
static bool convert (const char *from, std::int8_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::int16_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::int32_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::int64_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::uint8_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::uint16_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::uint32_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, std::uint64_t &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, float &to)
 Safely convert a string to a numeric value. More...
 
static bool convert (const char *from, double &to)
 Safely convert a string to a numeric value. More...
 

Detailed Description

Safe convenience string-to-numeric conversion methods for generic programming.

Definition at line 146 of file strings_convert_decl.h.

Member Function Documentation

◆ convert() [1/11]

static bool convert ( const char *  from,
bool &  to 
)
static

Safely convert a string to a boolean value.

Parameters
[in]fromString to convert. If either "true" or "false" (case insensitive), evaluates to the corresponding boolean value. If numeric, implicit conversion rules apply.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

Referenced by a_util::strings::toNumeric().

◆ convert() [2/11]

static bool convert ( const char *  from,
double &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [3/11]

static bool convert ( const char *  from,
float &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [4/11]

static bool convert ( const char *  from,
std::int16_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [5/11]

static bool convert ( const char *  from,
std::int32_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [6/11]

static bool convert ( const char *  from,
std::int64_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [7/11]

static bool convert ( const char *  from,
std::int8_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [8/11]

static bool convert ( const char *  from,
std::uint16_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [9/11]

static bool convert ( const char *  from,
std::uint32_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [10/11]

static bool convert ( const char *  from,
std::uint64_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.

◆ convert() [11/11]

static bool convert ( const char *  from,
std::uint8_t &  to 
)
static

Safely convert a string to a numeric value.

Parameters
[in]fromString to convert. If the potentially convertible numeric value is not in range of decltype(to) numeric limits, the conversion fails.
[out]toNumeric value converted from the string representation.
Return values
trueConversion was successful, to contains the converted value.
falseConversion failed, to is left untouched.