AOSharedServiceLibrary
cli.h
1 /*
2 MIT License Block
3 
4 Copyright (c) 2016 Alex Barry
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 */
24 
25 #include <string>
26 #include <iterator>
27 #include <vector>
28 
29 #include "aossl/core/include/kv_store.h"
30 #include "aossl/core/include/buffers.h"
31 
32 #ifndef AOSSL_COMMANDLINE_INCLUDE_CLI_H_
33 #define AOSSL_COMMANDLINE_INCLUDE_CLI_H_
34 
35 namespace AOSSL {
36 
38  std::string name;
39  void process_arg(const std::string& arg);
40 
41  public:
42  // Create a new Command Line Interpreter
43 
44  // Here we create a new interpreter by passing in the two
45  // arguments from the main method, int argc & char* argv[].
46  // This parses arguments passed in the form:
47  // arg_key=arg_val
48  CommandLineInterpreter(int argc, char* argv[]) : KeyValueStore() {
49  name = argv[0];
50  for (int i = 1; i < argc; i++) {
51  std::string full_line(argv[i]);
52  process_arg(full_line);
53  }
54  }
55  // Create a new Command Line Interpreter
56 
57  // Here we create a new interpreter by passing in the two
58  // arguments from the main method, int argc & char* argv[].
59  // This parses arguments passed in the form:
60  // arg_key=arg_val
61  explicit CommandLineInterpreter(const std::vector<std::string>& args) : \
62  KeyValueStore() {
63  name = args[0];
64  for (std::string elt : args) {
65  process_arg(elt);
66  }
67  }
68 
70 
71  std::string get_name() {return name;}
72  void load_config() {}
73 };
74 
75 } // namespace AOSSL
76 
77 #endif // AOSSL_COMMANDLINE_INCLUDE_CLI_H_
Key Value Store.
Definition: kv_store.h:42
void load_config()
Re-load configuration.
Definition: cli.h:72
Definition: cli.h:37
Definition: cli.h:35