FreeNOS
ArgumentContainer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBAPP_ARGUMENTCONTAINER_H
19 #define __LIBAPP_ARGUMENTCONTAINER_H
20 
21 #include <Types.h>
22 #include <Macros.h>
23 #include <String.h>
24 #include <HashTable.h>
25 #include <HashIterator.h>
26 #include <Vector.h>
27 #include "Argument.h"
28 
41 {
42  public:
43 
47  enum Result
48  {
52  };
53 
54  public:
55 
60 
64  virtual ~ArgumentContainer();
65 
73  const char * get(const char *name) const;
74 
80  const Vector<Argument *> & getPositionals() const;
81 
88 
97 
105  Result addFlag(Argument *arg);
106 
107  private:
108 
111 
114 };
115 
121 #endif /* __LIBAPP_ARGUMENTCONTAINER_H */
ArgumentContainer::get
const char * get(const char *name) const
Get argument by name.
Definition: ArgumentContainer.cpp:49
HashTable< String, Argument * >
Macros.h
Vector.h
Types.h
HashTable.h
HashIterator.h
ArgumentContainer::m_positionals
Vector< Argument * > m_positionals
Contains all positional arguments.
Definition: ArgumentContainer.h:113
ArgumentContainer::Success
@ Success
Definition: ArgumentContainer.h:49
ArgumentContainer
Generic command-line argument parser.
Definition: ArgumentContainer.h:40
ArgumentContainer::m_flags
HashTable< String, Argument * > m_flags
Contains all flag arguments.
Definition: ArgumentContainer.h:110
Argument
Represents program command line argument.
Definition: Argument.h:35
ArgumentContainer::addPositional
Result addPositional(Argument *arg)
Add positional argument.
Definition: ArgumentContainer.cpp:67
ArgumentContainer::Result
Result
Result codes.
Definition: ArgumentContainer.h:47
ArgumentContainer::NotFound
@ NotFound
Definition: ArgumentContainer.h:51
ArgumentContainer::ArgumentContainer
ArgumentContainer()
Constructor.
Definition: ArgumentContainer.cpp:20
ArgumentContainer::getFlags
const HashTable< String, Argument * > & getFlags() const
Get flag arguments.
Definition: ArgumentContainer.cpp:44
ArgumentContainer::InvalidArgument
@ InvalidArgument
Definition: ArgumentContainer.h:50
ArgumentContainer::~ArgumentContainer
virtual ~ArgumentContainer()
Destructor.
Definition: ArgumentContainer.cpp:24
Argument.h
String.h
ArgumentContainer::addFlag
Result addFlag(Argument *arg)
Add flag argument.
Definition: ArgumentContainer.cpp:73
Vector< Argument * >
ArgumentContainer::getPositionals
const Vector< Argument * > & getPositionals() const
Get positional arguments.
Definition: ArgumentContainer.cpp:39