-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.hpp
71 lines (55 loc) · 1.64 KB
/
option.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//@ {
//@ "targets":[{"name":"option.hpp","type":"include"}]
//@ ,"dependencies_extra":[{"ref":"option.o","rel":"implementation"}]
//@ }
#ifndef ALICE_OPTION_HPP
#define ALICE_OPTION_HPP
#include <cstddef>
#include <cstdio>
namespace Alice
{
class Option
{
public:
enum class Multiplicity:size_t
{ZERO_OR_ONE,ZERO_OR_MORE,ONE,ONE_OR_MORE};
constexpr Option():r_group(""),r_name("")
,r_description(""),r_type_name("")
,m_mult(Multiplicity::ZERO_OR_MORE){}
constexpr Option(const char* group
,const char* name,const char* description
,const char* type_name
,Multiplicity mult):r_group(group),r_name(name)
,r_description(description),r_type_name(type_name),m_mult(mult)
{}
void help(bool group_header=0,FILE* dest=stdout) const noexcept;
constexpr const char* groupGet() const noexcept
{return r_group;}
bool emptyAllowed() const noexcept
{
return m_mult==Multiplicity::ZERO_OR_ONE
|| m_mult==Multiplicity::ZERO_OR_MORE;
}
bool manyAllowed() const noexcept
{
return m_mult==Multiplicity::ZERO_OR_MORE
|| m_mult==Multiplicity::ONE_OR_MORE;
}
constexpr Multiplicity multiplicityGet() const noexcept
{return m_mult;}
constexpr const char* nameGet() const noexcept
{return r_name;}
constexpr const char* typeGet() const noexcept
{return r_type_name;}
constexpr const char* descriptionGet() const noexcept
{return r_description;}
protected:
void groupHeaderPrint(FILE* dest) const noexcept;
const char* r_group;
const char* r_name;
const char* r_description;
const char* r_type_name;
Multiplicity m_mult;
};
}
#endif