FreeNOS
Argument.cpp
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#include "Argument.h"
19
20Argument::Argument(const char *name)
21 : m_id(0)
22 , m_name(name, true)
23 , m_count(0)
24{
25}
26
28 : m_id(0)
29 , m_name(name)
30 , m_count(0)
31{
32}
33
35{
36 return m_id;
37}
38
40{
41 return m_count;
42}
43
45{
46 return m_name;
47}
48
50{
51 return m_description;
52}
53
55{
56 return m_value;
57}
58
60{
61 m_id = id;
62}
63
64void Argument::setName(const char *name)
65{
66 m_name = name;
67}
68
69void Argument::setDescription(const char *description)
70{
71 m_description = description;
72}
73
74void Argument::setValue(const char *value)
75{
76 m_value = value;
77}
78
80{
81 m_count = count;
82}
83
84bool Argument::operator == (const Argument & arg) const
85{
86 return arg.m_id == m_id;
87}
88
89bool Argument::operator != (const Argument & arg) const
90{
91 return arg.m_id != m_id;
92}
Represents program command line argument.
Definition Argument.h:36
const String & getValue() const
Retrieve argument option value (if any)
Definition Argument.cpp:54
const String & getDescription() const
Retrieve single line argument description.
Definition Argument.cpp:49
void setCount(Size count)
Set argument maximum count.
Definition Argument.cpp:79
void setIdentifier(char id)
Set argument identifier.
Definition Argument.cpp:59
const String & getName() const
Retrieve argument name.
Definition Argument.cpp:44
void setName(const char *name)
Set argument name.
Definition Argument.cpp:64
bool operator!=(const Argument &arg) const
Non-equality operator.
Definition Argument.cpp:89
bool operator==(const Argument &arg) const
Equality operator.
Definition Argument.cpp:84
String m_value
Optional argument value.
Definition Argument.h:153
String m_name
Argument name.
Definition Argument.h:147
void setDescription(const char *description)
Set argument single line description.
Definition Argument.cpp:69
char getIdentifier() const
Get single character identifier.
Definition Argument.cpp:34
Size m_count
Maximum argument count.
Definition Argument.h:156
Size getCount() const
Retrieve maximum argument count (if set)
Definition Argument.cpp:39
Argument(const char *name)
Class constructor.
Definition Argument.cpp:20
String m_description
Argument description in a single line.
Definition Argument.h:150
char m_id
Argument identifier.
Definition Argument.h:144
void setValue(const char *value)
Set argument option value.
Definition Argument.cpp:74
Abstraction of strings.
Definition String.h:42
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128