CBMC
Loading...
Searching...
No Matches
Functions
string2int.cpp File Reference
#include "string2int.h"
#include <cstdlib>
#include <stdexcept>
#include "invariant.h"
+ Include dependency graph for string2int.cpp:

Go to the source code of this file.

Functions

unsigned  safe_string2unsigned (std::string_view str, int base)
 
std::size_t  safe_string2size_t (std::string_view str, int base)
 
int  unsafe_string2int (const std::string &str, int base)
 
unsigned  unsafe_string2unsigned (const std::string &str, int base)
 
std::size_t  unsafe_string2size_t (const std::string &str, int base)
 
 
 
std::optional< intstring2optional_int (std::string_view str, int base)
  Convert string to integer as per stoi, but return nullopt when stoi would throw.
 
std::optional< unsignedstring2optional_unsigned (std::string_view str, int base)
  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 str, int base)
  Convert string to size_t similar to the stoul or stoull functions, return nullopt when the conversion fails.
 

Function Documentation

◆  safe_string2size_t()

std::size_t safe_string2size_t ( std::string_view  str,
int  base 
)

Definition at line 23 of file string2int.cpp.

◆  safe_string2unsigned()

unsigned safe_string2unsigned ( std::string_view  str,
int  base 
)

Definition at line 16 of file string2int.cpp.

◆  string2optional_int()

std::optional< int > string2optional_int ( std::string_view  str,
int  base 
)

Convert string to integer as per stoi, but return nullopt when stoi would throw.

Definition at line 59 of file string2int.cpp.

◆  string2optional_size_t()

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.

◆  string2optional_unsigned()

std::optional< unsigned > string2optional_unsigned ( std::string_view  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 64 of file string2int.cpp.

◆  unsafe_string2int()

int unsafe_string2int ( const std::string &  str,
int  base 
)

Definition at line 30 of file string2int.cpp.

◆  unsafe_string2signedlonglong()

signed long long int unsafe_string2signedlonglong ( const std::string &  str,
int  base 
)

Definition at line 45 of file string2int.cpp.

◆  unsafe_string2size_t()

std::size_t unsafe_string2size_t ( const std::string &  str,
int  base 
)

Definition at line 40 of file string2int.cpp.

◆  unsafe_string2unsigned()

unsigned unsafe_string2unsigned ( const std::string &  str,
int  base 
)

Definition at line 35 of file string2int.cpp.

◆  unsafe_string2unsignedlonglong()

unsigned long long int unsafe_string2unsignedlonglong ( const std::string &  str,
int  base 
)

Definition at line 52 of file string2int.cpp.

AltStyle によって変換されたページ (->オリジナル) /