AppOpts Pile   version 0.0.1
The pile provides the application with easy loading
one_opt.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_APPOPTS_ONEOPT_H_INCLUDE
11 #define GUARD_APPOPTS_ONEOPT_H_INCLUDE
12 
13 #include <appopts/appopts-config.h>
14 
15 #include <QMap>
16 #include <QList>
17 #include <QString>
18 #include <QSet>
19 #include <QStringList>
20 
21 class UserMsg;
22 class PerSt;
23 
25 class APPOPTS_EXPORT OneOpt {
26 
27 public:
28 
29  QString name_;
30  QString group_;
31  QString description_;
32  QStringList default_;
33  bool required_;
34 
36  static OneOpt
37  create (
38  const QString name,
39  const QString stgs_group = "general",
40  const QString description = QString(),
41  const QStringList default_val = QStringList());
42 
43 
45  explicit OneOpt() :
46  name_(),
47  group_(),
48  description_(),
49  default_(),
50  required_(false)
51  {}
52 
55  OneOpt (const OneOpt & other) :
56  name_(other.name_),
57  group_(other.group_),
58  description_(other.description_),
59  default_(other.default_),
60  required_(other.required_)
61  {}
62 
65  OneOpt& operator=( const OneOpt& other ) {
66  name_ = other.name_;
67  group_ = other.group_;
68  description_ = other.description_;
69  default_ = other.default_;
70  required_ = other.required_;
71  return *this;
72  }
73 
76  inline const QString &
77  name () const {
78  return name_;
79  }
80 
83  inline void
84  setName (const QString & value) {
85  name_ = value;
86  }
87 
89  inline QString fullName () const {
90  if (group_.isEmpty()) {
91  return name_;
92  } else {
93  return QString ("%1/%2")
94  .arg(group_)
95  .arg(name_);
96  }
97  }
98 
99 
102  inline const QString &
103  group () const {
104  return group_;
105  }
106 
109  inline void
110  setGroup (const QString & value) {
111  group_ = value;
112  }
113 
116  inline const QString &
117  description () const {
118  return description_;
119  }
120 
123  inline void
124  setDescription (const QString & value) {
125  description_ = value;
126  }
127 
130  inline const QStringList &
131  defaultValue () const {
132  return default_;
133  }
134 
137  inline void
138  setDefault (const QStringList & value) {
139  default_ = value;
140  }
141 
144  inline bool
145  required () const {
146  return required_;
147  }
148 
151  inline void
152  setRequired (bool value) {
153  required_ = value;
154  }
155 
156 protected:
157 
158 
159 private:
160 
161 
162 };
163 
164 inline bool operator== (
165  const OneOpt& lhs, const OneOpt& rhs){
166  return lhs.name() == rhs.name(); }
167 
168 inline bool operator!= (
169  const OneOpt& lhs, const OneOpt& rhs){
170  return lhs.name() != rhs.name(); }
171 
172 inline uint qHash(OneOpt key) { return qHash(key.name())*qHash(key.group()); }
173 
174 #endif // GUARD_APPOPTS_ONEOPT_H_INCLUDE
void setDefault(const QStringList &value)
Definition: one_opt.h:138
OneOpt & operator=(const OneOpt &other)
Definition: one_opt.h:65
const QString & description() const
Definition: one_opt.h:117
Definition for an option.
Definition: one_opt.h:25
bool required() const
Definition: one_opt.h:145
const QString & name() const
Definition: one_opt.h:77
const QString & group() const
Definition: one_opt.h:103
void setGroup(const QString &value)
Definition: one_opt.h:110
void setRequired(bool value)
Definition: one_opt.h:152
void setDescription(const QString &value)
Definition: one_opt.h:124
const QStringList & defaultValue() const
Definition: one_opt.h:131
void setName(const QString &value)
Definition: one_opt.h:84
OneOpt()
Default constructor.
Definition: one_opt.h:45
OneOpt(const OneOpt &other)
Definition: one_opt.h:55
QString fullName() const
Full name (includes the group)
Definition: one_opt.h:89