|
CBMC
|
#include "narrow.h"#include <charconv>#include <optional>#include <string>#include <string_view>#include <type_traits>
Include dependency graph for string2int.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| unsigned | safe_string2unsigned (std::string_view, int base=10) |
| std::size_t | safe_string2size_t (std::string_view, int base=10) |
| int | unsafe_string2int (const std::string &, int base=10) |
| unsigned | unsafe_string2unsigned (const std::string &, int base=10) |
| std::size_t | unsafe_string2size_t (const std::string &, int base=10) |
| long long int | unsafe_string2signedlonglong (const std::string &, int base=10) |
| long long unsigned int | unsafe_string2unsignedlonglong (const std::string &, int base=10) |
| std::optional< int > | string2optional_int (std::string_view, int base=10) |
| Convert string to integer as per stoi, but return nullopt when stoi would throw. | |
| std::optional< unsigned > | string2optional_unsigned (std::string_view, int base=10) |
| Convert string to unsigned similar to the stoul or stoull functions, return nullopt when the conversion fails. | |
| std::optional< std::size_t > | string2optional_size_t (std::string_view, int base=10) |
| Convert string to size_t similar to the stoul or stoull functions, return nullopt when the conversion fails. | |
| template<typename T > | |
| std::optional< T > | string2optional (std::string_view str, int base=10) |
| Convert a string to an integer, given the base of the representation, works with signed and unsigned integer types, rejects negative inputs when the result type is unsigned, rejects the empty string, rejects leading spaces, rejects any trailing non-numerical suffix. | |
| std::size_t safe_string2size_t | ( | std::string_view | str, |
| int | base = 10 |
||
| ) |
Definition at line 23 of file string2int.cpp.
Definition at line 16 of file string2int.cpp.
Convert a string to an integer, given the base of the representation, works with signed and unsigned integer types, rejects negative inputs when the result type is unsigned, rejects the empty string, rejects leading spaces, rejects any trailing non-numerical suffix.
A prefix such as 0, 0x, 0X to change base is not supported.
Definition at line 66 of file string2int.h.
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 | ( | std::string_view | 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 70 of file string2int.cpp.
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 64 of file string2int.cpp.
Definition at line 30 of file string2int.cpp.
Definition at line 45 of file string2int.cpp.
Definition at line 40 of file string2int.cpp.
Definition at line 35 of file string2int.cpp.