tclap  1.4.0
CmdLineInterface.h
Go to the documentation of this file.
1 // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2 
3 /******************************************************************************
4  *
5  * file: CmdLineInterface.h
6  *
7  * Copyright (c) 2003, Michael E. Smoot .
8  * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
9  * Copyright (c) 2017, Google LLC
10  * All rights reserved.
11  *
12  * See the file COPYING in the top directory of this distribution for
13  * more information.
14  *
15  * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  *****************************************************************************/
24 
25 #ifndef TCLAP_CMD_LINE_INTERFACE_H
26 #define TCLAP_CMD_LINE_INTERFACE_H
27 
28 #include <tclap/ArgContainer.h>
29 
30 #include <algorithm>
31 #include <iostream>
32 #include <list>
33 #include <string>
34 #include <vector>
35 
36 namespace TCLAP {
37 
38 class Arg;
39 class ArgGroup;
40 class CmdLineOutput;
41 
47 public:
51  virtual ~CmdLineInterface() {}
52 
58  virtual ArgContainer &add(Arg &a) = 0;
59 
65  virtual ArgContainer &add(Arg *a) = 0;
66 
67  // TODO: Rename this to something smarter or refactor this logic so
68  // it's not needed.
69  // Internal - do not use
70  virtual void addToArgList(Arg *a) = 0;
71 
82  virtual ArgContainer &add(ArgGroup &args) = 0;
83 
87  virtual void xorAdd(Arg &a, Arg &b) = 0;
88 
92  virtual void xorAdd(const std::vector<Arg *> &xors) = 0;
93 
99  virtual void parse(int argc, const char *const *argv) = 0;
100 
106  void parse(std::vector<std::string> &args);
107 
111  virtual void setOutput(CmdLineOutput *co) = 0;
112 
116  virtual std::string getVersion() const = 0;
117 
121  virtual std::string getProgramName() const = 0;
122 
126  virtual std::list<ArgGroup *> getArgGroups() = 0;
127  virtual std::list<Arg *> getArgList() const = 0; // TODO: get rid of this
128 
132  virtual char getDelimiter() const = 0;
133 
137  virtual std::string getMessage() const = 0;
138 
143  virtual bool hasHelpAndVersion() const = 0;
144 
149  virtual void reset() = 0;
150 
155  virtual void beginIgnoring() = 0;
156 
161  virtual bool ignoreRest() = 0;
162 };
163 
164 } // namespace TCLAP
165 
166 #endif // TCLAP_CMD_LINE_INTERFACE_H
virtual void xorAdd(Arg &a, Arg &b)=0
virtual void beginIgnoring()=0
Begin ignoring arguments since the "--" argument was specified.
A virtual base class that defines the essential data for all arguments.
Definition: Arg.h:53
virtual ~CmdLineInterface()
Destructor.
virtual void reset()=0
Resets the instance as if it had just been constructed so that the instance can be reused...
virtual ArgContainer & add(Arg &a)=0
Adds an argument.
virtual std::string getMessage() const =0
Returns the message string.
virtual void addToArgList(Arg *a)=0
Interface that allows adding an Arg to a "container".
Definition: ArgContainer.h:39
virtual void setOutput(CmdLineOutput *co)=0
virtual void parse(int argc, const char *const *argv)=0
Parses the command line.
The base class that manages the command line definition and passes along the parsing to the appropria...
virtual std::list< ArgGroup * > getArgGroups()=0
Returns the list of ArgGroups.
virtual bool ignoreRest()=0
Whether to ignore the rest.
virtual bool hasHelpAndVersion() const =0
Indicates whether or not the help and version switches were created automatically.
virtual std::list< Arg * > getArgList() const =0
virtual std::string getProgramName() const =0
Returns the program name string.
virtual char getDelimiter() const =0
Returns the delimiter string.
Definition: Arg.h:46
ArgGroup is the base class for implementing groups of arguments that are mutually exclusive (it repla...
Definition: ArgGroup.h:41
virtual std::string getVersion() const =0
Returns the version string.
The interface that any output object must implement.
Definition: CmdLineOutput.h:45