BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
ArgsParser.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 namespace BeeeOn {
7 
8 class ArgsParser {
9 public:
10  ArgsParser(
11  const std::string &whitespace = " \t",
12  const char quote = '\"',
13  const char escape = '\\');
14 
15  const std::vector<std::string> &parse(const std::string &input);
16 
17  std::vector<std::string>::const_iterator begin() const
18  {
19  return m_args.begin();
20  }
21 
22  std::vector<std::string>::const_iterator end() const
23  {
24  return m_args.end();
25  }
26 
27  std::size_t count() const;
28  const std::string &at(const std::size_t index) const;
29  const std::string &operator[](const std::size_t index) const
30  {
31  return at(index);
32  }
33 
34 protected:
35  std::vector<std::string> &parse(
36  const std::string &input,
37  std::vector<std::string> &args);
38 
39 private:
40  std::string m_whitespace;
41  char m_quote;
42  char m_escape;
43  std::vector<std::string> m_args;
44 };
45 
46 }
Definition: ArgsParser.h:8