Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarparse Class Reference

\file colvarparse.h Parsing functions for collective variables \brief Base class containing parsing functions; all objects which need to parse input inherit from this. More...

#include <colvarparse.h>

Inheritance diagram for colvarparse:

colvarparams colvar colvar::cvc colvar_grid colvar_grid< cvm::real > colvar_grid< size_t > colvarbias colvarbias_restraint_moving colvarmodule::atom_group List of all members.

Public Types

enum  Parse_Mode {
  parse_null = 0, parse_echo = (1<<1), parse_echo_default = (1<<2), parse_deprecation_warning = (1<<3),
  parse_silent = 0, parse_required = (1<<16), parse_override = (1<<17), parse_restart = (1<<18),
  parse_normal = (1<<1) | (1<<2) | (1<<17), parse_deprecated = (1<<1) | (1<<3) | (1<<17)
}
 How a keyword is parsed in a string. More...


Public Methods

 colvarparse ()
 Default constructor. More...

 colvarparse (const std::string &conf)
 Constructor that stores the object's config string. More...

void clear ()
 Set the object ready to parse a new configuration string. More...

void set_string (std::string const &conf)
 Set a new config string for this object. More...

virtual ~colvarparse ()
 Default destructor. More...

std::string const & get_config () const
 Get the configuration string (includes comments). More...

int check_keywords (std::string &conf, char const *key)
 \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. More...

void clear_keyword_registry ()
 \brief Use this after parsing a config string (note that check_keywords() calls it already). More...

bool get_keyval (std::string const &conf, char const *key, int &value, int const &def_value=(int) 0, Parse_Mode const parse_mode=parse_normal)
 \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). More...

bool get_keyval (std::string const &conf, char const *key, size_t &value, size_t const &def_value=(size_t) 0, Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, long &value, long const &def_value=0, Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, cvm::step_number &value, cvm::step_number const &def_value=0, Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::string &value, std::string const &def_value=std::string(""), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, cvm::real &value, cvm::real const &def_value=(cvm::real) 0.0, Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, cvm::rvector &value, cvm::rvector const &def_value=cvm::rvector(), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, cvm::quaternion &value, cvm::quaternion const &def_value=cvm::quaternion(), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, colvarvalue &value, colvarvalue const &def_value=colvarvalue(colvarvalue::type_notset), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, bool &value, bool const &def_value=false, Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< int > &values, std::vector< int > const &def_values=std::vector< int >(0,(int) 0), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< size_t > &values, std::vector< size_t > const &def_values=std::vector< size_t >(0,(size_t) 0), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< long > &values, std::vector< long > const &def_values=std::vector< long >(0,(long) 0), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< std::string > &values, std::vector< std::string > const &def_values=std::vector< std::string >(0, std::string("")), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< cvm::real > &values, std::vector< cvm::real > const &def_values=std::vector< cvm::real >(0,(cvm::real) 0.0), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< cvm::rvector > &values, std::vector< cvm::rvector > const &def_values=std::vector< cvm::rvector >(0, cvm::rvector()), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< cvm::quaternion > &values, std::vector< cvm::quaternion > const &def_values=std::vector< cvm::quaternion >(0, cvm::quaternion()), Parse_Mode const parse_mode=parse_normal)
bool get_keyval (std::string const &conf, char const *key, std::vector< colvarvalue > &values, std::vector< colvarvalue > const &def_values=std::vector< colvarvalue >(0, colvarvalue(colvarvalue::type_notset)), Parse_Mode const parse_mode=parse_normal)
bool key_lookup (std::string const &conf, char const *key, std::string *data=NULL, size_t *save_pos=NULL)
 \brief Low-level function for parsing configuration strings; automatically adds the requested keyword to the list of valid ones.
Parameters:
conf  the content of the configuration file or one of its blocks
key  the keyword to search within "conf"
data  (optional) holds the string provided after "key", if any
save_pos  (optional) stores the position of the keyword within "conf", useful when doing multiple calls.
More...


std::istream & read_config_line (std::istream &is, std::string &line)
 \brief Reads a configuration line, adds it to config_string, and returns the stream
Parameters:
is  Input stream
line  String that will hold the configuration line, with comments stripped.
More...


template<> int _get_keyval_scalar_value_ (std::string const &key_str, std::string const &data, bool &value, bool const &)
template<> int _get_keyval_scalar_novalue_ (std::string const &key_str, bool &value, Parse_Mode const &parse_mode)

Static Public Methods

std::string to_lower_cppstr (std::string const &in)
 \brief Return a lowercased copy of the string. More...

std::istream & getline_nocomments (std::istream &is, std::string &s)
 \brief Works as std::getline() but also removes everything between a comment character and the following newline. More...

int check_braces (std::string const &conf, size_t const start_pos)
 \brief Check if the content of a config string has matching braces
Parameters:
conf  The configuration string
start_pos  Start the count from this position.
More...


int check_ascii (std::string const &conf)
 \brief Check that a config string contains non-ASCII characters
Parameters:
conf  The configuration string.
More...


void split_string (const std::string &data, const std::string &delim, std::vector< std::string > &dest)
 \brief Split a string with a specified delimiter into a vector
Parameters:
data  The string to be splitted
delim  A delimiter
dest  A destination vector to store the splitted results.
More...



Static Public Attributes

const char *const white_space = " \t"
 Accepted white space delimiters, used in key_lookup(). More...


Protected Types

enum  key_set_mode { key_not_set = 0, key_set_user = 1, key_set_default = 2 }
 How a keyword has been set. More...


Protected Methods

bool get_key_string_value (std::string const &conf, char const *key, std::string &data)
 Get the string value of a keyword, and save it for later parsing. More...

bool get_key_string_multi_value (std::string const &conf, char const *key, std::vector< std::string > &data)
 Get multiple strings from repeated instances of a same keyword. More...

template<typename TYPE> bool _get_keyval_scalar_ (std::string const &conf, char const *key, TYPE &value, TYPE const &def_value, Parse_Mode const &parse_mode)
 Template for single-value keyword parsers. More...

template<typename TYPE> bool _get_keyval_vector_ (std::string const &conf, char const *key, std::vector< TYPE > &values, std::vector< TYPE > const &def_values, Parse_Mode const &parse_mode)
 Template for multiple-value keyword parsers. More...

template<typename TYPE> int _get_keyval_scalar_value_ (std::string const &key_str, std::string const &data, TYPE &value, TYPE const &def_value)
 Extract the value of a variable from a string. More...

template<typename TYPE> int _get_keyval_scalar_novalue_ (std::string const &key_str, TYPE &value, Parse_Mode const &parse_mode)
 Handle the case where the user provides a keyword without value. More...

template<typename TYPE> void mark_key_set_user (std::string const &key_str, TYPE const &value, Parse_Mode const &parse_mode)
 Record that the keyword has just been user-defined. More...

template<typename TYPE> void mark_key_set_default (std::string const &key_str, TYPE const &def_value, Parse_Mode const &parse_mode)
 Record that the keyword has just been set to its default value. More...

void error_key_required (std::string const &key_str, Parse_Mode const &parse_mode)
 Raise error condition due to the keyword being required! More...

bool key_already_set (std::string const &key_str)
 True if the keyword has been set already. More...

void add_keyword (char const *key)
 \brief Add a new valid keyword to the list. More...

void strip_values (std::string &conf)
 \brief Remove all the values from the config string. More...


Protected Attributes

std::string const keyword_delimiters_left
 Characters allowed immediately to the left of a kewyord. More...

std::string const keyword_delimiters_right
 Characters allowed immediately to the right of a kewyord. More...

std::list< std::stringallowed_keywords
 \brief List of legal keywords for this object: this is updated by each call to colvarparse::get_keyval() or colvarparse::key_lookup(). More...

std::map< std::string, key_set_modekey_set_modes
 Track which keywords have been already set, and how. More...

std::list< size_t > data_begin_pos
 \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. More...

std::list< size_t > data_end_pos
 \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. More...

std::string config_string
 \brief Configuration string of the object (includes comments). More...


Detailed Description

\file colvarparse.h Parsing functions for collective variables \brief Base class containing parsing functions; all objects which need to parse input inherit from this.

Definition at line 26 of file colvarparse.h.


Member Enumeration Documentation

enum colvarparse::key_set_mode [protected]
 

How a keyword has been set.

Enumeration values:
key_not_set 
key_set_user 
key_set_default 

Definition at line 348 of file colvarparse.h.

enum colvarparse::Parse_Mode
 

How a keyword is parsed in a string.

Enumeration values:
parse_null  Zero for all flags.
parse_echo  Print the value of a keyword if it is given.
parse_echo_default  Print the default value of a keyword, if it is NOT given.
parse_deprecation_warning  Print a deprecation warning if the keyword is given.
parse_silent  Do not print the keyword.
parse_required  Raise error if the keyword is not provided.
parse_override  Successive calls to get_keyval() will override the previous values when the keyword is not given any more.
parse_restart  The call is being executed from a read_restart() function.
parse_normal  Alias for old default behavior (should be phased out).
parse_deprecated  Settings for a deprecated keyword.

Definition at line 52 of file colvarparse.h.

Referenced by colvardeps::get_keyval_feature, operator|, and colvar_grid< size_t >::parse_params.


Constructor & Destructor Documentation

colvarparse::colvarparse  
 

Default constructor.

Definition at line 35 of file colvarparse.C.

References keyword_delimiters_right, n, and string.

colvarparse::colvarparse const std::string   conf
 

Constructor that stores the object's config string.

colvarparse::~colvarparse   [virtual]
 

Default destructor.

Definition at line 67 of file colvarparse.C.


Member Function Documentation

template<typename TYPE>
bool colvarparse::_get_keyval_scalar_ std::string const &    conf,
char const *    key,
TYPE &    value,
TYPE const &    def_value,
Parse_Mode const &    parse_mode
[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.

template<>
int colvarparse::_get_keyval_scalar_novalue_ std::string const &    key_str,
bool &    value,
Parse_Mode const &    parse_mode
 

Definition at line 230 of file colvarparse.C.

References set_bool.

template<typename TYPE>
int colvarparse::_get_keyval_scalar_novalue_ std::string const &    key_str,
TYPE &    value,
Parse_Mode const &    parse_mode
[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.

template<>
int colvarparse::_get_keyval_scalar_value_ std::string const &    key_str,
std::string const &    data,
bool &    value,
bool const &   
 

Definition at line 199 of file colvarparse.C.

References COLVARS_INPUT_ERROR, data, colvarmodule::error, set_bool, and string.

template<typename TYPE>
int colvarparse::_get_keyval_scalar_value_ std::string const &    key_str,
std::string const &    data,
TYPE &    value,
TYPE const &    def_value
[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.

template<typename TYPE>
bool colvarparse::_get_keyval_vector_ std::string const &    conf,
char const *    key,
std::vector< TYPE > &    values,
std::vector< TYPE > const &    def_values,
Parse_Mode const &    parse_mode
[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.

void colvarparse::add_keyword char const *    key [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.

int colvarparse::check_ascii std::string const &    conf [static]
 

\brief Check that a config string contains non-ASCII characters

Parameters:
conf  The configuration string.

Definition at line 939 of file colvarparse.C.

References conf, colvarmodule::getline, and colvarmodule::log.

Referenced by colvarmodule::parse_config.

int colvarparse::check_braces std::string const &    conf,
size_t const    start_pos
[static]
 

\brief Check if the content of a config string has matching braces

Parameters:
conf  The configuration string
start_pos  Start the count from this position.

Definition at line 925 of file colvarparse.C.

References COLVARS_INPUT_ERROR, and conf.

Referenced by key_lookup, and colvarmodule::parse_config.

int colvarparse::check_keywords std::string   conf,
char const *    key
 

\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.

void colvarparse::clear  
 

Set the object ready to parse a new configuration string.

Reimplemented in colvarbias.

Referenced by colvarbias_meta::read_state_data, and colvarmodule::reset.

void colvarparse::clear_keyword_registry  
 

\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.

void colvarparse::error_key_required std::string const &    key_str,
Parse_Mode const &    parse_mode
[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_.

std::string const& colvarparse::get_config   const [inline]
 

Get the configuration string (includes comments).

Definition at line 46 of file colvarparse.h.

References config_string.

Referenced by colvarmodule::get_config.

bool colvarparse::get_key_string_multi_value std::string const &    conf,
char const *    key,
std::vector< std::string > &    data
[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.

bool colvarparse::get_key_string_value std::string const &    conf,
char const *    key,
std::string   data
[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_.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< colvarvalue > &    values,
std::vector< colvarvalue > const &    def_values = std::vector< colvarvalue >(0, colvarvalue(colvarvalue::type_notset)),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 524 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< cvm::quaternion > &    values,
std::vector< cvm::quaternion > const &    def_values = std::vector< cvm::quaternion >(0, cvm::quaternion()),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 515 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< cvm::rvector > &    values,
std::vector< cvm::rvector > const &    def_values = std::vector< cvm::rvector >(0, cvm::rvector()),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 506 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< cvm::real > &    values,
std::vector< cvm::real > const &    def_values = std::vector< cvm::real >(0,(cvm::real) 0.0),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 497 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< std::string > &    values,
std::vector< std::string > const &    def_values = std::vector< std::string >(0, std::string("")),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 488 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< long > &    values,
std::vector< long > const &    def_values = std::vector< long >(0,(long) 0),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 479 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< size_t > &    values,
std::vector< size_t > const &    def_values = std::vector< size_t >(0,(size_t) 0),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 470 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::vector< int > &    values,
std::vector< int > const &    def_values = std::vector< int >(0,(int) 0),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 461 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
bool &    value,
bool const &    def_value = false,
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 449 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
colvarvalue   value,
colvarvalue const &    def_value = colvarvalue(colvarvalue::type_notset),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 440 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
cvm::quaternion &    value,
cvm::quaternion const &    def_value = cvm::quaternion(),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 431 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
cvm::rvector &    value,
cvm::rvector const &    def_value = cvm::rvector(),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 422 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
cvm::real   value,
cvm::real const &    def_value = (cvm::real) 0.0,
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 413 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
std::string   value,
std::string const &    def_value = std::string(""),
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 404 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
cvm::step_number   value,
cvm::step_number const &    def_value = 0,
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 395 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
long &    value,
long const &    def_value = 0,
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 386 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
size_t &    value,
size_t const &    def_value = (size_t) 0,
Parse_Mode const    parse_mode = parse_normal
 

Definition at line 377 of file colvarparse.C.

References conf.

bool colvarparse::get_keyval std::string const &    conf,
char const *    key,
int &    value,
int const &    def_value = (int) 0,
Parse_Mode const    parse_mode = parse_normal
 

\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.

std::istream & colvarparse::getline_nocomments std::istream &    is,
std::string   s
[static]
 

\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.

bool colvarparse::key_already_set std::string const &    key_str [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.

bool colvarparse::key_lookup std::string const &    conf,
char const *    key,
std::string   data = NULL,
size_t *    save_pos = NULL
 

\brief Low-level function for parsing configuration strings; automatically adds the requested keyword to the list of valid ones.

Parameters:
conf  the content of the configuration file or one of its blocks
key  the keyword to search within "conf"
data  (optional) holds the string provided after "key", if any
save_pos  (optional) stores the position of the keyword within "conf", useful when doing multiple calls.

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.

template<typename TYPE>
void colvarparse::mark_key_set_default std::string const &    key_str,
TYPE const &    def_value,
Parse_Mode const &    parse_mode
[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.

template<typename TYPE>
void colvarparse::mark_key_set_user std::string const &    key_str,
TYPE const &    value,
Parse_Mode const &    parse_mode
[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.

std::istream & colvarparse::read_config_line std::istream &    is,
std::string   line
 

\brief Reads a configuration line, adds it to config_string, and returns the stream

Parameters:
is  Input stream
line  String that will hold the configuration line, with comments stripped.

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.

void colvarparse::set_string std::string const &    conf
 

Set a new config string for this object.

Definition at line 58 of file colvarparse.C.

Referenced by colvarbias::init, and colvar::init.

void colvarparse::split_string const std::string   data,
const std::string   delim,
std::vector< std::string > &    dest
[static]
 

\brief Split a string with a specified delimiter into a vector

Parameters:
data  The string to be splitted
delim  A delimiter
dest  A destination vector to store the splitted results.

Definition at line 958 of file colvarparse.C.

References data.

void colvarparse::strip_values std::string   conf [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.

std::string colvarparse::to_lower_cppstr std::string const &    in [inline, static]
 

\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.


Member Data Documentation

std::list<std::string> colvarparse::allowed_keywords [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.

std::string colvarparse::config_string [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.

std::list<size_t> colvarparse::data_begin_pos [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.

std::list<size_t> colvarparse::data_end_pos [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.

std::map<std::string, key_set_mode> colvarparse::key_set_modes [protected]
 

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.

std::string const colvarparse::keyword_delimiters_left [protected]
 

Characters allowed immediately to the left of a kewyord.

Definition at line 337 of file colvarparse.h.

Referenced by key_lookup.

std::string const colvarparse::keyword_delimiters_right [protected]
 

Characters allowed immediately to the right of a kewyord.

Definition at line 340 of file colvarparse.h.

Referenced by key_lookup.

char const *const colvarparse::white_space = " \t" [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.


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 02:46:53 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002