#include <colvarparse.h>
Inheritance diagram for colvarparse:
Definition at line 26 of file colvarparse.h.
[protected]
How a keyword is parsed in a string.
Definition at line 52 of file colvarparse.h.
Referenced by colvardeps::get_keyval_feature, operator|, and colvar_grid< size_t >::parse_params.
Default constructor.
Definition at line 35 of file colvarparse.C.
References keyword_delimiters_right, n, and string.
Constructor that stores the object's config string.
[virtual]
[protected]
Template for single-value keyword parsers.
Definition at line 241 of file colvarparse.C.
References conf, data, colvarmodule::debug, error_key_required, get_key_string_value, key_already_set, colvarmodule::log, parse_override, and parse_required.
[protected]
Handle the case where the user provides a keyword without value.
Definition at line 221 of file colvarparse.C.
References COLVARS_INPUT_ERROR, and colvarmodule::error.
Definition at line 199 of file colvarparse.C.
References COLVARS_INPUT_ERROR, data, colvarmodule::error, set_bool, and string.
[protected]
Extract the value of a variable from a string.
Definition at line 169 of file colvarparse.C.
References COLVARS_INPUT_ERROR, data, and colvarmodule::error.
[protected]
Template for multiple-value keyword parsers.
Definition at line 287 of file colvarparse.C.
References COLVARS_BUG_ERROR, COLVARS_INPUT_ERROR, conf, data, colvarmodule::error, error_key_required, get_key_string_value, key_already_set, parse_override, and parse_required.
[protected]
\brief Add a new valid keyword to the list.
Definition at line 534 of file colvarparse.C.
References allowed_keywords, key_not_set, key_set_modes, and to_lower_cppstr.
Referenced by key_lookup.
[static]
\brief Check that a config string contains non-ASCII characters
Definition at line 939 of file colvarparse.C.
References conf, colvarmodule::getline, and colvarmodule::log.
Referenced by colvarmodule::parse_config.
\brief Check if the content of a config string has matching braces
Definition at line 925 of file colvarparse.C.
References COLVARS_INPUT_ERROR, and conf.
Referenced by key_lookup, and colvarmodule::parse_config.
\brief Check that all the keywords within "conf" are in the list of allowed keywords; this will invoke strip_values() first and then loop over all words.
Definition at line 592 of file colvarparse.C.
References allowed_keywords, clear_keyword_registry, COLVARS_INPUT_ERROR, conf, colvarmodule::debug, colvarmodule::error, colvarmodule::getline, colvarmodule::log, strip_values, to_lower_cppstr, and white_space.
Referenced by colvarbias_histogram::init, and colvarmodule::parse_config.
Set the object ready to parse a new configuration string.
Reimplemented in colvarbias.
Referenced by colvarbias_meta::read_state_data, and colvarmodule::reset.
\brief Use this after parsing a config string (note that check_keywords() calls it already).
Definition at line 583 of file colvarparse.C.
References allowed_keywords, data_begin_pos, data_end_pos, and key_set_modes.
Referenced by check_keywords, and colvarmodule::read_restart.
[protected]
Raise error condition due to the keyword being required!
Definition at line 152 of file colvarparse.C.
References COLVARS_INPUT_ERROR, colvarmodule::error, key_already_set, and parse_restart.
Referenced by _get_keyval_scalar_, and _get_keyval_vector_.
[inline]
Get the configuration string (includes comments).
Definition at line 46 of file colvarparse.h.
References config_string.
Referenced by colvarmodule::get_config.
[protected]
Get multiple strings from repeated instances of a same keyword.
Definition at line 99 of file colvarparse.C.
References conf, data, and key_lookup.
[protected]
Get the string value of a keyword, and save it for later parsing.
Definition at line 74 of file colvarparse.C.
References COLVARS_INPUT_ERROR.
Referenced by _get_keyval_scalar_, and _get_keyval_vector_.
\fn get_keyval bool const get_keyval (std::string const &conf, char const *key, _type_ &value, _type_ const &def_value, Parse_Mode const parse_mode) \brief Helper function to parse keywords in the configuration and get their values In normal circumstances, you should use either version the get_keyval function. Both of them look for the C string "key" in the C++ string "conf", and assign the corresponding value (if available) to the variable "value" (first version), or assign as many values as found to the vector "values" (second version). If "key" is found but no value is associated to it, the default value is provided (either one copy or as many copies as the current length of the vector "values" specifies). A message will print, unless parse_mode is equal to parse_silent. The return value of both forms of get_keyval is true if "key" is found (with or without value), and false when "key" is absent in the string "conf". If there is more than one instance of the keyword, a warning will be raised; instead, to loop over multiple instances key_lookup() should be invoked directly. If you introduce a new data type, add two new instances of this functions, or insert this type in the colvarvalue wrapper class (colvarvalue.h).
Definition at line 368 of file colvarparse.C.
References conf.
Referenced by colvar::alpha_angles::alpha_angles, colvarbias_restraint_k::change_configuration, colvarbias_restraint_centers::change_configuration, colvar::coordnum::coordnum, colvar::distance_inv::distance_inv, colvar::distance_z::distance_z, colvardeps::get_keyval_feature, colvar::map_total::init, colvar::spin_angle::init, colvar::tilt::init, colvar::orientation::init, colvar::cvc::init, colvarbias_restraint_histogram::init, colvarbias_restraint_harmonic_walls::init, colvarbias_restraint_k_moving::init, colvarbias_restraint_centers_moving::init, colvarbias_restraint_moving::init, colvarbias_restraint_k::init, colvarbias_restraint_centers::init, colvarbias_meta::init, colvarbias_reweightaMD::init, colvarbias_histogram::init, colvarbias_alb::init, colvarbias_abf::init, colvarbias::init, colvar::init, colvarbias_meta::init_ebmeta_params, colvar::init_extended_Lagrangian, colvar::init_grid_parameters, colvar::init_output_flags, colvarbias_meta::init_replicas_params, colvarbias_meta::init_well_tempered_params, colvar::parse_analysis, colvarmodule::parse_global_params, colvar_grid< size_t >::parse_params, colvarmodule::read_restart, colvar::read_state, colvarbias_restraint_k_moving::set_state_params, colvarbias_restraint_centers_moving::set_state_params, colvarbias_restraint_moving::set_state_params, colvarbias_meta::set_state_params, colvarbias_alb::set_state_params, and colvarbias::set_state_params.
\brief Works as std::getline() but also removes everything between a comment character and the following newline.
Definition at line 652 of file colvarparse.C.
References colvarmodule::getline.
Referenced by colvarbias_restraint_histogram::init, operator>>, colvarmodule::read_traj, and colvarbias_meta::update_replicas_registry.
[protected]
True if the keyword has been set already.
Definition at line 548 of file colvarparse.C.
References key_set_modes, and to_lower_cppstr.
Referenced by _get_keyval_scalar_, _get_keyval_vector_, error_key_required, and colvar::init_grid_parameters.
\brief Low-level function for parsing configuration strings; automatically adds the requested keyword to the list of valid ones.
Definition at line 664 of file colvarparse.C.
References add_keyword, check_braces, COLVARS_INPUT_ERROR, conf, data, data_begin_pos, data_end_pos, colvarmodule::debug, colvarmodule::error, keyword_delimiters_left, keyword_delimiters_right, colvarmodule::log, NULL, to_lower_cppstr, and white_space.
Referenced by colvar::alpha_angles::alpha_angles, colvar::distance_z::distance_z, get_key_string_multi_value, colvarbias_histogram::init, colvar::init_custom_function, colvarmodule::parse_colvars, colvarmodule::parse_global_params, and colvar::cvc::parse_group.
[protected]
Record that the keyword has just been set to its default value.
Definition at line 140 of file colvarparse.C.
References key_set_default, key_set_modes, colvarmodule::log, parse_echo_default, and to_lower_cppstr.
[protected]
Record that the keyword has just been user-defined.
Definition at line 123 of file colvarparse.C.
References key_set_modes, key_set_user, colvarmodule::log, parse_deprecation_warning, parse_echo, and to_lower_cppstr.
\brief Reads a configuration line, adds it to config_string, and returns the stream
Definition at line 639 of file colvarparse.C.
References config_string, and colvarmodule::getline.
Referenced by colvarmodule::read_config_file, and colvarmodule::read_config_string.
Set a new config string for this object.
Definition at line 58 of file colvarparse.C.
Referenced by colvarbias::init, and colvar::init.
[static]
\brief Split a string with a specified delimiter into a vector
Definition at line 958 of file colvarparse.C.
References data.
[protected]
\brief Remove all the values from the config string.
Definition at line 560 of file colvarparse.C.
References conf, data_begin_pos, and data_end_pos.
Referenced by check_keywords.
\brief Return a lowercased copy of the string.
Definition at line 261 of file colvarparse.h.
Referenced by add_keyword, check_keywords, colvarbias::colvarbias, key_already_set, key_lookup, mark_key_set_default, mark_key_set_user, colvar::parse_analysis, colvarmodule::parse_global_params, pdb_field_str2enum, colvarmodule::read_restart, and colvarbias::read_state_data_key.
[protected]
\brief List of legal keywords for this object: this is updated by each call to colvarparse::get_keyval() or colvarparse::key_lookup().
Definition at line 345 of file colvarparse.h.
Referenced by add_keyword, check_keywords, and clear_keyword_registry.
[protected]
\brief Configuration string of the object (includes comments).
Definition at line 374 of file colvarparse.h.
Referenced by get_config, and read_config_line.
[protected]
\brief List of delimiters for the values of each keyword in the configuration string; all keywords will be stripped of their values before the keyword check is performed.
Definition at line 360 of file colvarparse.h.
Referenced by clear_keyword_registry, key_lookup, and strip_values.
[protected]
\brief List of delimiters for the values of each keyword in the configuration string; all keywords will be stripped of their values before the keyword check is performed.
Definition at line 365 of file colvarparse.h.
Referenced by clear_keyword_registry, key_lookup, and strip_values.
Track which keywords have been already set, and how.
Definition at line 355 of file colvarparse.h.
Referenced by add_keyword, clear_keyword_registry, key_already_set, mark_key_set_default, and mark_key_set_user.
[protected]
Characters allowed immediately to the left of a kewyord.
Definition at line 337 of file colvarparse.h.
Referenced by key_lookup.
[protected]
Characters allowed immediately to the right of a kewyord.
Definition at line 340 of file colvarparse.h.
Referenced by key_lookup.
[static]
Accepted white space delimiters, used in key_lookup().
Definition at line 20 of file colvarparse.C.
Referenced by check_keywords, key_lookup, colvarmodule::read_config_file, colvarmodule::read_config_string, and colvarmodule::read_traj.