claw
1.9.0
Toggle main menu visibility
Loading...
Searching...
No Matches
arguments.hpp
Go to the documentation of this file.
1
/*
2
CLAW - a C++ Library Absolutely Wonderful
3
4
CLAW is a free library without any particular aim but being useful to
5
anyone.
6
7
Copyright (C) 2005-2011 Julien Jorge
8
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2.1 of the License, or (at your option) any later version.
13
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
18
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23
contact: julien.jorge@stuff-o-matic.com
24
*/
30
#ifndef __CLAW_ARGUMENTS_HPP__
31
#define __CLAW_ARGUMENTS_HPP__
32
33
#include <
claw/ordered_set.hpp
>
34
35
#include <map>
36
#include <string>
37
38
namespace
claw
39
{
51
class
arguments
52
{
53
private
:
54
typedef
std::map<std::string, std::list<std::string> >
55
valued_arguments_map;
56
57
public
:
58
arguments
();
59
explicit
arguments
(
const
std::string& prog_name);
60
arguments
(
int
& argc,
char
**& argv);
61
arguments
(
int
& argc,
char
**& argv,
62
const
claw::math::ordered_set<std::string>
& allowed);
63
64
void
parse
(
int
& argc,
char
**& argv);
65
void
parse
(
int
& argc,
char
**& argv,
66
const
claw::math::ordered_set<std::string>
& allowed);
67
68
bool
has_value
(
const
std::string& arg_name)
const
;
69
bool
only_integer_values
(
const
std::string& arg_name)
const
;
70
bool
only_real_values
(
const
std::string& arg_name)
const
;
71
72
const
std::string&
get_program_name
()
const
;
73
74
bool
get_bool
(
const
std::string& arg_name)
const
;
75
int
get_integer
(
const
std::string& arg_name)
const
;
76
double
get_real
(
const
std::string& arg_name)
const
;
77
const
std::string&
get_string
(
const
std::string& arg_name)
const
;
78
79
std::list<int>
get_all_of_integer
(
const
std::string& arg_name)
const
;
80
std::list<double>
get_all_of_real
(
const
std::string& arg_name)
const
;
81
std::list<std::string>
82
get_all_of_string
(
const
std::string& arg_name)
const
;
83
84
void
add_argument
(
const
std::string& arg);
85
86
private
:
87
void
parse
(
int
& argc,
char
**& argv,
bool
always_allowed,
88
const
claw::math::ordered_set<std::string>
& allowed);
89
bool
split_argument(
const
std::string& arg, std::string& name,
90
std::string& value)
const
;
91
92
void
remove_null_arguments(
int
& argc,
char
**& argv)
const
;
93
94
void
process_boolean(
char
*& arg,
bool
always_allowed,
95
const
claw::math::ordered_set<std::string>
& allowed);
96
97
private
:
99
std::string m_program_name;
100
102
claw::math::ordered_set<std::string>
m_flags;
103
105
valued_arguments_map m_pairs;
106
107
};
// class arguments
108
}
109
110
#endif
// __CLAW_ARGUMENTS_HPP__
claw::arguments::add_argument
void add_argument(const std::string &arg)
Add an argument in our list.
Definition
arguments.cpp:304
claw::arguments::parse
void parse(int &argc, char **&argv)
Parse arguments.
Definition
arguments.cpp:89
claw::arguments::get_real
double get_real(const std::string &arg_name) const
Get the real value of an argument.
Definition
arguments.cpp:199
claw::arguments::has_value
bool has_value(const std::string &arg_name) const
Tell if a value is associated to an argument.
Definition
arguments.cpp:113
claw::arguments::get_program_name
const std::string & get_program_name() const
Get the name of the program.
Definition
arguments.cpp:163
claw::arguments::arguments
arguments()
Constructor.
Definition
arguments.cpp:41
claw::arguments::only_integer_values
bool only_integer_values(const std::string &arg_name) const
Tell if only integer values are associated to an argument.
Definition
arguments.cpp:122
claw::arguments::get_all_of_string
std::list< std::string > get_all_of_string(const std::string &arg_name) const
Get all string values of an argument.
Definition
arguments.cpp:284
claw::arguments::get_bool
bool get_bool(const std::string &arg_name) const
Get the boolean state of an argument.
Definition
arguments.cpp:172
claw::arguments::get_string
const std::string & get_string(const std::string &arg_name) const
Get the string value of an argument.
Definition
arguments.cpp:217
claw::arguments::get_all_of_integer
std::list< int > get_all_of_integer(const std::string &arg_name) const
Get all integer values of an argument.
Definition
arguments.cpp:230
claw::arguments::get_all_of_real
std::list< double > get_all_of_real(const std::string &arg_name) const
Get all real values of an argument.
Definition
arguments.cpp:257
claw::arguments::get_integer
int get_integer(const std::string &arg_name) const
Get the integer value of an argument.
Definition
arguments.cpp:182
claw::arguments::only_real_values
bool only_real_values(const std::string &arg_name) const
Tell if only real values are associated to an argument.
Definition
arguments.cpp:143
claw::math::ordered_set
A class to manage sets of ordered items.
Definition
ordered_set.hpp:45
claw
This is the main namespace.
Definition
application.hpp:50
ordered_set.hpp
A class to manage sets of ordered items.
lib
application
include
claw
application
arguments.hpp
Generated by
1.17.0