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