command.h
Go to the documentation of this file.
1 
7 #ifndef COMMAND_H
8 #define COMMAND_H
9 
10 #include <string>
11 #include <unordered_set>
12 #include <unordered_map>
13 
14 #include <utility>
15 #include <vector>
18 #include <boost/algorithm/string.hpp>
19 #include <boost/range/algorithm/remove_if.hpp>
20 #include <boost/algorithm/string/trim.hpp>
21 
32 {
33  std::string name;
34  bool cmdHasParams;
35  std::vector<std::pair<std::string, std::string>>
38  std::string cmd;
42  std::string response;
44 };
45 
56 {
57  std::string optName;
58  bool optHasParams;
59  std::vector<std::pair<std::string, std::string>>
62  std::string opt;
65  std::string
72 };
73 
90 class Command
91 {
101  typedef void (Command::*insertInstruction)(const int&,
103  std::string& out);
104 
105 public:
109  Command();
122  Command(const CommandParams& cmdParams, const std::shared_ptr<Syntax> syntax,
123  const std::unordered_map<std::string,
124  std::shared_ptr<CommandOptions>>& options);
133  void generateCommand(const Parameter::ParameterMap& inputParams,
134  std::string& out);
148  void generateCommand(const Parameter::ParameterMap& inputParams,
149  const std::vector<std::string>& options,
150  std::string& out);
162  const bool verifyResponse(const Parameter::ParameterMap& inputParams,
163  const std::string& responseOrig,
164  Parameter::ParameterMap& outputParams);
181  const bool verifyResponse(const Parameter::ParameterMap& inputParams,
182  const std::vector<std::string>& options,
183  const std::string& responseOrig,
184  Parameter::ParameterMap& outputParams);
189  const std::string& getName() const;
190 
191 private:
192  std::string name;
196  std::shared_ptr<Syntax> syntax;
197  std::unordered_map<std::string, std::shared_ptr<CommandOptions>> options;
200  std::unordered_map<std::string, std::string> parameterTypes;
203  std::unordered_set<std::string>
205  std::vector<std::string>
208  std::vector<std::string> cmdParameter;
211  std::vector<std::pair<int, insertInstruction>>
217  std::string simpleResponse;
218  // string contains a keyWord if bool=false, else string contains paramName
219  std::vector<std::pair<std::string, bool>>
232  void insertCmdKeyword(const int& index, const Parameter::ParameterMap& input,
233  std::string& out);
242  void insertCmdParameter(const int& index,
243  const Parameter::ParameterMap& input,
244  std::string& out);
245 };
246 
247 #endif // COMMAND_H
std::vector< std::string > cmdKeyWords
Definition: command.h:206
std::vector< std::string > cmdParameter
Definition: command.h:208
std::string name
Definition: command.h:33
bool cmdHasParams
Definition: command.h:34
std::unordered_set< std::string > cmdParameterSet
Definition: command.h:204
std::string cmd
Definition: command.h:38
bool respHasParams
Definition: command.h:195
The Parameter::ParameterMap class provides a map functionality for Parameter::Parameter objects conta...
Definition: parameter.h:163
bool cmdHasResponse
Definition: command.h:40
bool respHasParams
Definition: command.h:41
bool cmdHasParams
Definition: command.h:193
bool optReturnsParams
Definition: command.h:64
std::string name
Definition: command.h:192
The CommandOptions class serves as a data struct to inform Command objects about all modifiers that c...
Definition: command.h:55
std::string opt
Definition: command.h:62
std::string simpleResponse
Definition: command.h:217
std::unordered_map< std::string, std::string > parameterTypes
Definition: command.h:200
std::unordered_map< std::string, std::shared_ptr< CommandOptions > > options
Definition: command.h:197
std::vector< std::pair< int, insertInstruction > > commandTemplate
Definition: command.h:212
bool optHasParams
Definition: command.h:58
std::vector< std::pair< std::string, bool > > responseTemplate
Definition: command.h:220
std::shared_ptr< Syntax > syntax
Definition: command.h:196
std::vector< std::pair< std::string, std::string > > params
Definition: command.h:36
bool addsRespToGrps
Definition: command.h:69
std::string response
Definition: command.h:42
The CommandParams class serves as a data struct to configure Command objects.
Definition: command.h:31
std::vector< std::pair< std::string, std::string > > params
Definition: command.h:60
The Command class builds the syntactic template for a specific command defined in a CommandParams str...
Definition: command.h:90
std::string response
Definition: command.h:66
std::string optName
Definition: command.h:57
Header file for the Syntax struct.
Header file for the Parameter::Parameter, Parameter::GenericParameter and Parameter::ParameterMap cla...
bool cmdHasResponse
Definition: command.h:194


pses_ucbridge
Author(s): Sebastian Ehmes
autogenerated on Sat Oct 28 2017 19:16:13