|
| | Parser (std::string help_text) noexcept |
| |
| void | parse (std::string options) noexcept |
| | Parse a string to obtain options and their values. More...
|
| |
|
void | parse (const Option &options) |
| | Parse an Option to obtain options and their values.
|
| |
| void | parse_file (const std::string &file_name) noexcept |
| | Parse a file containing options. More...
|
| |
| template<typename T , typename Metavariables = NoSuchType> |
| T::type | get () const |
| | Get the value of the specified option. More...
|
| |
| template<typename TagList , typename Metavariables = NoSuchType, typename F > |
| decltype(auto) | apply (F &&func) const |
| | Call a function with the specified options as arguments. More...
|
| |
| template<typename Metavariables = NoSuchType, typename F > |
| decltype(auto) | apply_all (F &&func) const |
| | Call a function with the typelist of parsed options (i.e., the supplied option list with the chosen branches of any Alternatives inlined) and the option values as arguments. More...
|
| |
|
template<typename TagsAndSubgroups = tags_and_subgroups_list> |
| std::string | help () const noexcept |
| | Get the help string.
|
| |
|
void | pup (PUP::er &p) noexcept |
| |
|
template<typename Tag , typename Metavariables > |
| Tag::type | get () const |
| |
|
| template<typename OverlayOptions > |
| void | overlay (std::string options) noexcept |
| | Overlay the options from a string or file on top of the currently parsed options. More...
|
| |
| template<typename OverlayOptions > |
| void | overlay_file (const std::string &file_name) noexcept |
| | Overlay the options from a string or file on top of the currently parsed options. More...
|
| |
template<typename OptionList, typename Group = NoSuchType>
class Options::Parser< OptionList, Group >
Class that handles parsing an input file.
Options must be given YAML data to parse before output can be extracted. This can be done either from a file (parse_file method), from a string (parse method), or, in the case of recursive parsing, from an Option (parse method). The options can then be extracted using the get method.
Example
struct Bounded {
using type = int;
"Option with bounds and a suggested value"};
static type suggested_value() noexcept { return 3; }
};
std::string help() const noexcept
Get the help string.
Definition: ParseOptions.hpp:643
const char *const String
The string used in option structs.
Definition: Options.hpp:32
opts.parse("Bounded: 3");
CHECK(opts.get<Bounded>() == 3);
Class that handles parsing an input file.
Definition: ParseOptions.hpp:177
- See also
- the Option Parsing tutorial
- Template Parameters
-
| OptionList | the list of option structs to parse |
| Group | the option group with a group hierarchy |
template<typename OptionList , typename Group = NoSuchType>
template<typename TagList , typename Metavariables = NoSuchType, typename F >
| decltype(auto) Options::Parser< OptionList, Group >::apply |
( |
F && |
func | ) |
const |
Call a function with the specified options as arguments.
- Template Parameters
-
| TagList | a typelist of options to pass |
Returns: the result of the function call
template<typename OptionList , typename Group = NoSuchType>
template<typename Metavariables = NoSuchType, typename F >
| decltype(auto) Options::Parser< OptionList, Group >::apply_all |
( |
F && |
func | ) |
const |
Call a function with the typelist of parsed options (i.e., the supplied option list with the chosen branches of any Alternatives inlined) and the option values as arguments.
Returns: the result of the function call. This must have the same type for all valid sets of parsed arguments.
template<typename OptionList , typename Group = NoSuchType>
template<typename T , typename Metavariables = NoSuchType>
Get the value of the specified option.
- Template Parameters
-
Returns: the value of the option
template<typename OptionList , typename Group >
template<typename OverlayOptions >
Overlay the options from a string or file on top of the currently parsed options.
Any tag included in the list passed as the template parameter can be overridden by a new parsed value. Newly parsed options replace the previous values. Any tags not appearing in the new input are left unchanged.
template<typename OptionList , typename Group >
template<typename OverlayOptions >
Overlay the options from a string or file on top of the currently parsed options.
Any tag included in the list passed as the template parameter can be overridden by a new parsed value. Newly parsed options replace the previous values. Any tags not appearing in the new input are left unchanged.