22 #ifndef __PLUMED_core_CLTool_h
23 #define __PLUMED_core_CLTool_h
28 #include "tools/Tools.h"
29 #include "tools/Keywords.h"
40 std::vector<std::string>
line;
66 bool readInputFile(
int argc,
char**argv, FILE* in, FILE*out );
71 void setInputData(
const std::map<std::string,std::string>&inputData){
80 bool parse(
const std::string&key,T&t);
82 void parseFlag(
const std::string&key,
bool&t);
84 void error(
const std::string& msg);
86 bool parseVector(
const std::string&key,std::vector<T>&t);
94 bool readInput(
int argc,
char**argv, FILE* in, FILE*out );
98 virtual std::string
description()
const{
return "(no description available)";}
105 plumed_massert(
keywords.
exists(key),
"keyword " + key +
" has not been registered");
107 if(
inputData.count(key)==0)
error(
"missing data for keyword " + key);
109 if(!check)
error(
"data input for keyword " + key +
" has wrong type");
112 if(
inputData.count(key)==0 )
return false;
121 plumed_massert(
keywords.
exists(key),
"keyword " + key +
" has not been registered");
123 unsigned size=t.size();
124 bool skipcheck=
false;
125 if(size==0) skipcheck=
true;
129 plumed_massert(
inputData[key]!=
"false",
"compulsory keyword "+std::string(key)+
"has no data");
132 if(words.size()==0)
return false;
134 for(
unsigned i=0;i<words.size();++i){
140 if( !skipcheck && t.size()!=size ) {
141 plumed_merror(
"vector read in for keyword "+key+
" has wrong size" );
148 plumed_merror(
"ERROR in keyword "+key+
" has weird default value" );
150 for(
unsigned i=0;i<t.size();++i) t[i]=val;
153 plumed_merror(
"keyword " + key +
" is compulsory for this action");
Class containing wrappers to MPI.
bool getDefaultValue(std::string key, std::string &def) const
Get the value of the default for the keyword named key.
This class holds the keywords and their documentation.
bool style(const std::string &k, const std::string &t) const
Check if the keyword with name k has style t.
bool exists(const std::string &k) const
Check if there is a keyword with name k.