clockUtils  1.1
Parser.h
Go to the documentation of this file.
1 /*
2  * clockUtils
3  * Copyright (2015) Michael Baer, Daniel Bonrath, All rights reserved.
4  *
5  * This file is part of clockUtils; clockUtils is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __CLOCKUTILS_ARGPARSER_PARSER_H__
26 #define __CLOCKUTILS_ARGPARSER_PARSER_H__
27 
29 
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 namespace clockUtils {
35  enum class ClockError;
36 namespace argParser {
37 
38  class BasicVariable;
39 
44  friend class BasicVariable;
45 
46  public:
52  static ClockError parseArguments(const char ** argv, int argc);
53 
59  static ClockError parseArguments(char ** argv, int argc) {
60  return parseArguments(const_cast<const char **>(argv), argc);
61  }
62 
66  static std::string getLastParserError();
67 
71  static void registerArgumentsVector(std::vector<std::string> * args) {
72  arguments = args;
73  }
74 
78  static void setErrorOnFlag(bool b) {
79  errorOnFlag = b;
80  }
81 
85  static bool wasHelpSet() {
86  return help;
87  }
88 
92  static std::string getHelpText();
93 
97  static void addHelpTextLine(const std::pair<std::string, std::string> & line) {
98  helpTexts.insert(line);
99  }
100 
101  private:
105  static std::vector<BasicVariable *> variableList;
106 
110  static std::string error;
111 
115  static std::vector<std::string> * arguments;
116 
120  static bool errorOnFlag;
121 
125  static bool help;
126 
130  static std::map<std::string, std::string> helpTexts;
131  };
132 
133 } /* namespace argParser */
134 } /* namespace clockUtils */
135 
136 #endif /* __CLOCKUTILS_ARGPARSER_PARSER_H__ */
137 
static void registerArgumentsVector(std::vector< std::string > *args)
registers a vector for arguments at end of input
Definition: Parser.h:71
base class for Variable handling
Definition: BasicVariable.h:42
static bool wasHelpSet()
returns true if –help was found in argument line
Definition: Parser.h:85
static void addHelpTextLine(const std::pair< std::string, std::string > &line)
add a line for help text
Definition: Parser.h:97
static void setErrorOnFlag(bool b)
sets bool determining whether an error shall occure if an extra flag is given that wasn&#39;t registered ...
Definition: Parser.h:78
#define CLOCK_ARGPARSER_API
class handling all known variables being able to be parsed and offering parse functionality ...
Definition: Parser.h:43
static ClockError parseArguments(char **argv, int argc)
parses argument line
Definition: Parser.h:59
ClockError
Definition: errors.h:30