1 #ifndef __DIADES__UTILS__CMDINTERFACE__HH 2 #define __DIADES__UTILS__CMDINTERFACE__HH 19 #include <unordered_map> 20 #include <boost/program_options.hpp> 28 using std::stringstream;
40 namespace CmdInterface
52 const string _fileBase =
"[a-zA-Z_][a-zA-Z_0-9]*\\.";
53 std::unordered_map<std::string, std::regex>
_suffixes;
71 match(
const std::string & fileName,
72 const std::string & suffix)
const;
84 size_t printUsage(
const string & programName, boost::program_options::options_description & desc);
156 bool fileSuffixOk(
const string & modelFile,
const string & suffix);
169 template<
typename Option>
174 vector<string>::size_type index = 0;
175 while(!found && (index < options.size()))
177 found = options[index] == parameter;
208 stream <<
"The parameter " << argv[index - 1] <<
" is not correct.";
213 stream << argv[index];
214 if(!(stream >> param))
217 stream <<
"The parameter " << argv[index] <<
" has an incorrect format.";
242 const vector<string> &
options,
244 int & index, set< T > & records)
246 cout <<
"index = " << index <<
" argc = " << argc << endl;
250 getParameter<string>(argc, argv, index, newValue);
252 cout <<
"param = " << newValue << endl;
253 bool isAnOption =
false;
254 vector<string>::size_type i = 0;
255 while((i < options.size()) && (!isAnOption))
257 isAnOption = options[i] == newValue;
262 cout << newValue <<
" is not an option so is part of the list following an option" << endl;
266 getParameter<T>(argc, argv, index, param);
267 records.insert(param);
268 cout <<
"insert the filename " << param << endl;
size_t printUsage(const string &programName, Poptions::options_description &desc)
InputIterator getFileExtension(const std::basic_string< CharType, CharTraits > &fileName, InputIterator begin, InputIterator end)
std::unordered_map< std::string, std::regex > _suffixes
const size_t ERROR_UNHANDLED_EXCEPTION
size_t printCommandLineError(const string &msg)
vector< string > options(numberOfOptions)
const size_t ERROR_IN_COMMAND_LINE
FileSuffixes(const std::vector< std::string > &suffixes)
bool match(const std::string &fileName, const std::string &suffix) const
bool getOption(const string ¶meter, const vector< string > &options, Option &result)
string getSuffix(const string &name)
const size_t WARNING_IN_COMMAND_LINE
bool fileSuffixOk(const string &modelFile, const string &suffix)
Namespace of the Diades project.
void getParameter(int argc, char **argv, int &index, T ¶m)
size_t printCommandLineWarning(const string &msg)
FileSuffixes suffixes({"aut","ddaut"})
void getParameterList(int argc, char **argv, const vector< string > &options, const vector< string > &fileExtensions, int &index, set< T > &records)
vector< string > fileExtensions(numberOfFileExtensions)