CBMC
|
Go to the source code of this file.
Functions | |
unsigned | safe_string2unsigned (const std::string &str, int base=10) |
std::size_t | safe_string2size_t (const std::string &str, int base=10) |
int | unsafe_string2int (const std::string &str, int base=10) |
unsigned | unsafe_string2unsigned (const std::string &str, int base=10) |
std::size_t | unsafe_string2size_t (const std::string &str, int base=10) |
long long int | unsafe_string2signedlonglong (const std::string &str, int base=10) |
long long unsigned int | unsafe_string2unsignedlonglong (const std::string &str, int base=10) |
std::optional< int > | string2optional_int (const std::string &, int base=10) |
Convert string to integer as per stoi, but return nullopt when stoi would throw. More... | |
std::optional< unsigned > | string2optional_unsigned (const std::string &, int base=10) |
Convert string to unsigned similar to the stoul or stoull functions, return nullopt when the conversion fails. More... | |
std::optional< std::size_t > | string2optional_size_t (const std::string &, int base=10) |
Convert string to size_t similar to the stoul or stoull functions, return nullopt when the conversion fails. More... | |
template<typename T > | |
auto | string2optional_base (const std::string &str, int base) -> typename std::enable_if< std::is_signed< T >::value, long long >::type |
convert string to signed long long if T is signed More... | |
template<typename do_conversiont > | |
auto | wrap_string_conversion (do_conversiont do_conversion) -> std::optional< decltype(do_conversion())> |
attempt a given conversion, return nullopt if the conversion fails with out_of_range or invalid_argument More... | |
template<typename T > | |
std::optional< T > | string2optional (const std::string &str, int base=10) |
convert a string to an integer, given the base of the representation works with signed and unsigned integer types smaller than (unsigned) long long does not accept negative inputs when the result type is unsigned More... | |
std::size_t safe_string2size_t | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 23 of file string2int.cpp.
unsigned safe_string2unsigned | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 16 of file string2int.cpp.
std::optional<T> string2optional | ( | const std::string & | str, |
int | base = 10 |
||
) |
convert a string to an integer, given the base of the representation works with signed and unsigned integer types smaller than (unsigned) long long does not accept negative inputs when the result type is unsigned
Definition at line 111 of file string2int.h.
auto string2optional_base | ( | const std::string & | str, |
int | base | ||
) | -> typename std::enable_if<std::is_signed<T>::value, long long>::type |
convert string to signed long long if T is signed
convert string to unsigned long long if T is unsigned
Definition at line 58 of file string2int.h.
std::optional<int> string2optional_int | ( | const std::string & | str, |
int | base = 10 |
||
) |
Convert string to integer as per stoi, but return nullopt when stoi would throw.
Definition at line 59 of file string2int.cpp.
std::optional<std::size_t> string2optional_size_t | ( | const std::string & | str, |
int | base = 10 |
||
) |
Convert string to size_t similar to the stoul or stoull functions, return nullopt when the conversion fails.
Note: Unlike stoul or stoull negative inputs are disallowed
Definition at line 71 of file string2int.cpp.
std::optional<unsigned> string2optional_unsigned | ( | const std::string & | str, |
int | base = 10 |
||
) |
Convert string to unsigned similar to the stoul or stoull functions, return nullopt when the conversion fails.
Note: Unlike stoul or stoull negative inputs are disallowed
Definition at line 65 of file string2int.cpp.
int unsafe_string2int | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 30 of file string2int.cpp.
long long int unsafe_string2signedlonglong | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 45 of file string2int.cpp.
std::size_t unsafe_string2size_t | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 40 of file string2int.cpp.
unsigned unsafe_string2unsigned | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 35 of file string2int.cpp.
long long unsigned int unsafe_string2unsignedlonglong | ( | const std::string & | str, |
int | base = 10 |
||
) |
Definition at line 52 of file string2int.cpp.
auto wrap_string_conversion | ( | do_conversiont | do_conversion | ) | -> std::optional<decltype(do_conversion())> |
attempt a given conversion, return nullopt if the conversion fails with out_of_range or invalid_argument
Definition at line 89 of file string2int.h.