SpECTRE
v2024.12.16
|
Class that handles parsing an input file. More...
#include <ParseOptions.hpp>
Public Member Functions | |
Parser (std::string help_text) | |
void | parse (std::string options) |
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, bool require_metadata=true) |
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 |
Get the help string. | |
void | pup (PUP::er &p) |
template<typename Tag , typename Metavariables > | |
Tag::type | get () const |
template<typename OverlayOptions > | |
void | overlay (std::string options) |
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) |
Overlay the options from a string or file on top of the currently parsed options. More... | |
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.
OptionList | the list of option structs to parse |
Group | the option group with a group hierarchy |
|
explicit |
help_text | an overall description of the options |
decltype(auto) Options::Parser< OptionList, Group >::apply | ( | F && | func | ) | const |
Call a function with the specified options as arguments.
TagList | a typelist of options to pass |
Returns: the result of the function call
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.
T::type Options::Parser< OptionList, Group >::get | ( | ) | const |
Get the value of the specified option.
T | the option to retrieve |
Returns: the value of the option
void Options::Parser< OptionList, Group >::overlay | ( | std::string | options | ) |
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.
void Options::Parser< OptionList, Group >::overlay_file | ( | const std::string & | file_name | ) |
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.
void Options::Parser< OptionList, Group >::parse | ( | std::string | options | ) |
Parse a string to obtain options and their values.
options | the string holding the YAML formatted options |
void Options::Parser< OptionList, Group >::parse_file | ( | const std::string & | file_name, |
bool | require_metadata = true |
||
) |
Parse a file containing options.
file_name | the path to the file to parse |
require_metadata | require the input file to have a metadata section |