CppTools
Loading...
Searching...
No Matches
InputParser.hpp
Go to the documentation of this file.
1
9#ifndef CPP_TOOLS_INPUT_PARSER_HPP
10#define CPP_TOOLS_INPUT_PARSER_HPP
11
12#include <string>
13#include <vector>
14
15#include "ErrorHandler.hpp"
16
18namespace CppTools
19{
24 {
25 public:
31 void AddField(const std::string& entry);
37 int CheckEntry(const std::string& argument);
38 {
39 if (argument[0] == '-')
40 {
41 // position of the argument
42 int startPos = 1;
43 if (argument[1] == '-') startPos++;
44
45 const std::string entry = argument.substr(startPos);
46 for (int i = 0; i < static_cast<int>(parserFields.size()); i++)
47 {
48 if (entry == parserFields[i]) return i;
49 }
50 }
51 return -1;
52 }
54 virtual ~InputParser();
55
56 private:
58 std::vector<std::string> parserFields;
59 }
60}
61#endif /* CPP_TOOLS_INPUT_PARSER_HPP */
Contains useful set of functions to print errors, warning, check existence of files,...
void AddField(const std::string &entry)
Adds entry to the list of fields.
virtual ~InputParser()
Default desctuctor.
int CheckEntry(const std::string &argument)
Checks if the argument can be associated with any of the added fields.
InputParser()
Default constructor.