args-parser 6.3.3
Loading...
Searching...
No Matches
arg_iface.hpp
Go to the documentation of this file.
1
31#ifndef ARGS__ARG_IFACE_HPP__INCLUDED
32#define ARGS__ARG_IFACE_HPP__INCLUDED
33
34// Args include.
35#include "utils.hpp"
36#include "types.hpp"
37#include "enums.hpp"
38
39
40namespace Args {
41
42class Context;
43class CmdLine;
44
45
46//
47// ArgIface
48//
49
51class ArgIface {
52
53 friend class CmdLine;
54 friend class GroupIface;
55 friend class Command;
56
57public:
59 : m_cmdLine( nullptr )
60 {
61 }
62
63 virtual ~ArgIface()
64 {
65 }
66
68 virtual ArgType type() const = 0;
69
76 virtual String name() const = 0;
77
79 virtual bool isWithValue() const = 0;
80
82 virtual bool isRequired() const = 0;
83
85 virtual bool isDefined() const = 0;
86
88 virtual const String & flag() const = 0;
89
91 virtual const String & argumentName() const = 0;
92
94 virtual const String & valueSpecifier() const = 0;
95
97 virtual const String & description() const = 0;
98
100 virtual const String & longDescription() const = 0;
101
103 CmdLine * cmdLine() const
104 {
105 return m_cmdLine;
106 }
107
109 virtual bool isMisspelledName(
111 const String & name,
113 StringList & possibleNames ) const = 0;
114
116 virtual void clear() = 0;
117
118protected:
132 const String & name ) = 0;
133
139 virtual void process(
141 Context & context ) = 0;
142
151 StringList & flags,
153 StringList & names ) const = 0;
154
156 virtual void checkCorrectnessAfterParsing() const = 0;
157
159 virtual void setCmdLine( CmdLine * cmdLine )
160 {
161 m_cmdLine = cmdLine;
162 }
163
164private:
166
167
168 CmdLine * m_cmdLine;
169}; // class ArgIface
170
171} /* namespace Args */
172
173#endif // ARGS__ARG_IFACE_HPP__INCLUDED
Interface for arguments.
Definition arg_iface.hpp:51
virtual ArgIface * findArgument(const String &name)=0
virtual const String & valueSpecifier() const =0
virtual bool isRequired() const =0
virtual void process(Context &context)=0
Process argument's staff, for example take values from context.
virtual ~ArgIface()
Definition arg_iface.hpp:63
virtual String name() const =0
virtual const String & longDescription() const =0
virtual ArgType type() const =0
virtual const String & argumentName() const =0
virtual bool isWithValue() const =0
virtual void setCmdLine(CmdLine *cmdLine)
Set command line parser.
virtual void checkCorrectnessAfterParsing() const =0
Check correctness of the argument after parsing.
virtual const String & flag() const =0
CmdLine * cmdLine() const
virtual const String & description() const =0
virtual void clear()=0
Clear state of the argument.
virtual bool isDefined() const =0
virtual bool isMisspelledName(const String &name, StringList &possibleNames) const =0
virtual void checkCorrectnessBeforeParsing(StringList &flags, StringList &names) const =0
Check correctness of the argument before parsing.
CmdLine is class that holds all rguments and parse command line arguments in the correspondence with ...
Definition cmd_line.hpp:123
Command in the command line interface.
Definition command.hpp:53
Context is a list of words in the command line that user presented with interface for interacting wit...
Definition context.hpp:60
Interface for the groups.
Definition api.hpp:42
std::string String
String type.
Definition types.hpp:324
std::vector< String > StringList
List of strings.
Definition types.hpp:346
ArgType
Type of the argument.
Definition enums.hpp:56
#define DISABLE_COPY(Class)
Macro for disabling copy.
Definition utils.hpp:50