CASM  1.1.0
A Clusters Approach to Statistical Mechanics
EnumIO

Detailed Description

Helpers for enum class IO.

Functions

template<typename ENUM >
std::string CASM::multiline_enum_help ()
 Print help message describing recognized strings for allowed enum values. More...
 
template<typename StringContainer >
std::string CASM::standard_singleline_help (StringContainer options, std::string _default="")
 Print short help message describing recognized strings for allowed enum values. More...
 
template<typename ENUM >
std::string CASM::standard_singleline_enum_help (std::string _default="", std::string other="")
 Print short help message describing recognized strings for allowed enum values. More...
 
template<typename ENUM >
std::string CASM::singleline_enum_help ()
 Print short help message describing recognized strings for allowed enum values. More...
 
template<typename ENUM >
void CASM::invalid_enum_string (std::string val)
 Throw invalid_argument error for unrecognized strings. More...
 
template<typename ENUM >
std::string CASM::to_string (ENUM val)
 Return string representation of enum class. More...
 
template<typename ENUM >
std::set< ENUM > CASM::matches (const std::string &val)
 Return all matching enum class members from string representation. More...
 
template<typename ENUM >
ENUM CASM::from_string (const std::string &val)
 Return enum class object from string representation. More...
 

Function Documentation

◆ from_string()

template<typename ENUM >
ENUM CASM::from_string ( const std::string &  val)

Return enum class object from string representation.

Definition at line 202 of file io_traits.hh.

◆ invalid_enum_string()

template<typename ENUM >
void CASM::invalid_enum_string ( std::string  val)

Throw invalid_argument error for unrecognized strings.

Prints to serr:

Invalid CoordType: mistakevalue
Options are:
CART or cart
FRAC or frac or DIRECT or direct
INTEGRAL or integral
const COORD_TYPE FRAC
Definition: enum.hh:8
const COORD_TYPE INTEGRAL
Definition: enum.hh:10
const COORD_TYPE CART
Definition: enum.hh:9

Definition at line 158 of file io_traits.hh.

◆ matches()

template<typename ENUM >
std::set<ENUM> CASM::matches ( const std::string &  val)

Return all matching enum class members from string representation.

Matches using substr of length val.size(), so "FRAC" matches for "F", "FR", "FRA", "FRAC", "FRAC.*".

Definition at line 184 of file io_traits.hh.

◆ multiline_enum_help()

template<typename ENUM >
std::string CASM::multiline_enum_help ( )

Print help message describing recognized strings for allowed enum values.

Of form:

Options are:
CART or cart
FRAC or frac or DIRECT or direct
INTEGRAL or integral

Definition at line 47 of file io_traits.hh.

◆ singleline_enum_help()

template<typename ENUM >
std::string CASM::singleline_enum_help ( )

Print short help message describing recognized strings for allowed enum values.

Of form:

Options are: {'FRAC' (default), 'CART', 'INTEGRAL'}

Definition at line 139 of file io_traits.hh.

◆ standard_singleline_enum_help()

template<typename ENUM >
std::string CASM::standard_singleline_enum_help ( std::string  _default = "",
std::string  other = "" 
)

Print short help message describing recognized strings for allowed enum values.

Of form:

Options are: {<other>, 'FRAC' (default), 'CART', 'INTEGRAL'}

or (if other.empty()):

Options are: {'FRAC' (default), 'CART', 'INTEGRAL'}

Definition at line 115 of file io_traits.hh.

◆ standard_singleline_help()

template<typename StringContainer >
std::string CASM::standard_singleline_help ( StringContainer  options,
std::string  _default = "" 
)

Print short help message describing recognized strings for allowed enum values.

Parameters
optionsList of options
_defaultIf not empty, the option to indicate as default

Of form:

Options are: {<other>, 'FRAC' (default), 'CART', 'INTEGRAL'}

or (if other.empty()):

Options are: {'FRAC' (default), 'CART', 'INTEGRAL'}

Definition at line 83 of file io_traits.hh.

◆ to_string()

template<typename ENUM >
std::string CASM::to_string ( ENUM  val)

Return string representation of enum class.

Definition at line 172 of file io_traits.hh.