|
MADNESS 0.10.1
|
very simple command line parser More...
#include <commandlineparser.h>
Public Member Functions | |
| commandlineparser () | |
| commandlineparser (int argc, char **argv) | |
| std::string | check_for_input_file (std::string line) |
| special option: the input file has no hyphens in front and is just a value | |
| bool | key_exists (std::string key) const |
| void | print_map () const |
| void | set_defaults () |
| set default values from the command line | |
| void | set_keyval (const std::string key, const std::string value) |
| void | set_keyval_keep_case (const std::string key, const std::string value) |
| std::string | value (const std::string key) const |
| std::string | value_raw (const std::string key) const |
Static Public Member Functions | |
| static std::string | base_name (std::string const &path, std::string const &delims="/") |
| static std::string | remove_blanks (const std::string arg) |
| remove all blanks | |
| static std::string | remove_extension (std::string const &filename) |
| static std::string | remove_first_equal (const std::string arg) |
| static std::string | remove_front_hyphens (const std::string arg) |
| static std::vector< std::string > | split (std::string s, const std::string delimiter) |
| split a string s into a vector of strings, using delimiter | |
| static std::string | tolower (std::string s) |
| make lower case | |
| static std::string | trim_blanks (const std::string arg) |
| remove blanks at the beginning and the end only | |
Public Attributes | |
| std::map< std::string, std::string > | keyval |
| std::map< std::string, std::string > | keyval_raw |
very simple command line parser
parser reads out key/value pairs from the command line of the form --key=val or --key. By default values are case-folded so that chemistry-style enum knobs (e.g. --xc=HF, --localize=BOYS) match the lowercased allowed_values of QCCalculationParametersBase-derived classes.
Two accessors are exposed for retrieving values:
value(key) — case-folded value (back-compat). Use for enum-like chemistry parameters.value_raw(key) — original-case value. Use for paths and free-form identifiers (archive filenames, JSON paths, …).The bare-positional input-file form (e.g. madness_app /Some/Path/in.in) is also case-preserving — both value("input") and value_raw("input") return the path with original case.
|
inline |
References set_defaults().
|
inline |
|
inlinestatic |
|
inline |
special option: the input file has no hyphens in front and is just a value
References split().
Referenced by commandlineparser().
|
inline |
References keyval, and tolower().
Referenced by madness::CalculationParameters::CalculationParameters(), main(), main(), madness::QCCalculationParametersBase::read_commandline_options(), madness::QCCalculationParametersBase::read_input_and_commandline_options(), madness::Molecule::GeometryParameters::set_derived_values(), madness::Molecule::GeometryParameters::set_global_convenience_options(), value(), and value_raw().
|
inline |
|
inlinestatic |
remove all blanks
References madness::arg().
|
inlinestatic |
References madness::filename, and p().
|
inlinestatic |
References madness::arg().
Referenced by commandlineparser().
|
inlinestatic |
References madness::arg().
Referenced by commandlineparser().
|
inline |
set default values from the command line
References keyval.
Referenced by commandlineparser(), and commandlineparser().
|
inline |
References keyval, keyval_raw, tolower(), trim_blanks(), and value().
Referenced by commandlineparser(), dnuclear_anchor_test(), main(), nuclear_anchor_test(), run_all_calculations(), madness::TDHF::test(), test_capitalization(), test_comment_lines(), test_derived(), test_empty_lines(), test_fock(), test_nemo(), test_not_allowed(), test_read_restartaodata(), test_read_restartdata(), test_serialize(), test_trailing_characters(), test_type_conversion1(), test_type_conversion2(), test_type_conversion3(), test_type_conversion4(), test_type_conversion5(), test_type_conversion6(), test_type_conversion7(), and test_type_conversion8().
|
inline |
References keyval, keyval_raw, tolower(), trim_blanks(), and value().
Referenced by commandlineparser().
|
inlinestatic |
split a string s into a vector of strings, using delimiter
| [in] | s | the string (pass by value!) |
Referenced by check_for_input_file(), main(), and madness::QCParameter::print_line().
|
inlinestatic |
make lower case
References c.
Referenced by key_exists(), madness::MacroTaskInfo::policy_to_string(), madness::MolecularOptimizer::projector_external_dof(), set_keyval(), set_keyval_keep_case(), madness::Exchange< T, NDIM >::string2algorithm(), value(), and value_raw().
|
inlinestatic |
remove blanks at the beginning and the end only
References madness::arg().
Referenced by set_keyval(), and set_keyval_keep_case().
|
inline |
References key_exists(), keyval, MADNESS_CHECK_THROW, and tolower().
Referenced by madness::CalculationParameters::CalculationParameters(), madness::Molecule::GeometryParameters::derive_source_type_from_name(), madness::Molecule::GeometryParameters::input_tag(), main(), main(), madness::QCCalculationParametersBase::read_commandline_options(), madness::QCCalculationParametersBase::read_input_and_commandline_options(), madness::Molecule::GeometryParameters::set_derived_values(), set_keyval(), set_keyval_keep_case(), and madness::TDHF::test().
|
inline |
Original-case value lookup — use for paths and free-form identifiers (archive filenames, JSON paths, etc.). For enum-like chemistry knobs matched against allowed_values, prefer value(key) instead.
References key_exists(), keyval, keyval_raw, MADNESS_CHECK_THROW, and tolower().
Referenced by main(), and madness::Molecule::GeometryParameters::set_global_convenience_options().
| std::map<std::string, std::string> madness::commandlineparser::keyval |
Referenced by key_exists(), print_map(), set_defaults(), set_keyval(), set_keyval_keep_case(), value(), and value_raw().
| std::map<std::string, std::string> madness::commandlineparser::keyval_raw |
Referenced by set_keyval(), set_keyval_keep_case(), and value_raw().