CommandLine.h
Go to the documentation of this file.
1 
20 #pragma once
21 
22 #include <WString.h>
23 #include <WVector.h>
24 
44 {
45 public:
49  struct Parameter {
53  const char* text{nullptr};
54 
55  operator bool() const
56  {
57  return text != nullptr;
58  }
59 
63  String getName() const;
64 
68  String getValue() const;
69  };
70 
74  class Parameters : public Vector<Parameter>
75  {
76  public:
81  Parameter find(const String& name) const;
82 
87  Parameter findIgnoreCase(const String& name) const;
88  };
89 
94  {
95  return parameters;
96  }
97 
98  /*
99  * Method called by startup code.
100  * All options have been processed so only parameters remain.
101  */
102  void parse(int paramCount, char* params[]);
103 
104 private:
105  Parameters parameters;
106 };
107 
108 extern CommandLine commandLine;
void parse(int paramCount, char *params[])
CommandLine commandLine
const char * text
The text exactly as presented on the command line.
Definition: CommandLine.h:53
Vector class template.
Definition: WVector.h:30
The String class.
Definition: WString.h:136
Manages a single parameter, may be optionally separated into name=value.
Definition: CommandLine.h:49
Provides access to the command lineAnything which doesn&#39;t start with - is interpreted as an applicati...
Definition: CommandLine.h:43
List of command-line parameters, in order.
Definition: CommandLine.h:74
const Parameters & getParameters()
Fetch a reference to the list of command-line parameters.
Definition: CommandLine.h:93
String getName() const
Get parameter name, if there is one.
String getValue() const
Get parameter value.