ADTF
Loading...
Searching...
No Matches
a_util::strings::ToNumericConverter Struct Reference

#include <strings_convert_decl.h>

Static Public Member Functions

static bool convert (const char *from, bool &to)
 
static bool convert (const char *from, std::int8_t &to)
 
static bool convert (const char *from, std::int16_t &to)
 
static bool convert (const char *from, std::int32_t &to)
 
static bool convert (const char *from, std::int64_t &to)
 
static bool convert (const char *from, std::uint8_t &to)
 
static bool convert (const char *from, std::uint16_t &to)
 
static bool convert (const char *from, std::uint32_t &to)
 
static bool convert (const char *from, std::uint64_t &to)
 
static bool convert (const char *from, float &to)
 
static bool convert (const char *from, double &to)
 

Detailed Description

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

Member Function Documentation

◆ convert() [1/11]

static bool a_util::strings::ToNumericConverter::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.

◆ convert() [2/11]

static bool a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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 a_util::strings::ToNumericConverter::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.

The documentation for this struct was generated from the following file: