-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmdtypes.hpp
102 lines (83 loc) · 2.55 KB
/
cmdtypes.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//@ {"targets":[{"name":"cmdtypes.hpp","type":"include"}]}
#ifndef ANJA_CMDTYPES_HPP
#define ANJA_CMDTYPES_HPP
#include "alice/alice.hpp"
namespace Alice
{
template<>
struct MakeType<Stringkey("filename")>:public MakeType<Stringkey("string")>
{
static constexpr const char* descriptionShortGet() noexcept
{return "A valid filename";}
};
template<>
struct MakeType<Stringkey("filename in")>:public MakeType<Stringkey("filename")>
{
static constexpr const char* descriptionShortGet() noexcept
{return "A name of an existing file";}
static constexpr const char* descriptionLongGet() noexcept
{
return "If there is no file with the given name, an error occurs.";
}
};
template<>
struct MakeType<Stringkey("filename out")>:public MakeType<Stringkey("filename")>
{
static constexpr const char* descriptionShortGet() noexcept
{return "A valid filename";}
static constexpr const char* descriptionLongGet() noexcept
{
return "If a file with the same name already exists, it will be "
"overwritten.";
}
};
enum class Theme:int{DARK,LIGHT};
template<>
struct MakeType<Stringkey("theme")>
{
typedef Theme Type;
static constexpr const char* descriptionShortGet() noexcept
{return "`dark` | `light`";}
static constexpr const char* descriptionLongGet() noexcept
{return "";}
};
template<class ErrorHandler>
struct MakeValue<Theme,ErrorHandler>
{
static Theme make_value(const std::string& str);
};
template<class ErrorHandler>
Theme MakeValue<Theme,ErrorHandler>::make_value(const std::string& str)
{
if(str=="dark")
{return Theme::DARK;}
if(str=="light")
{return Theme::LIGHT;}
throw Anja::Error("`",str.c_str(),"` is not a valid theme. Possible themes are `dark` and `light`.");
}
enum class WindowMode:int{FULLSCREEN,WINDOWED};
template<>
struct MakeType<Stringkey("window mode")>
{
typedef WindowMode Type;
static constexpr const char* descriptionShortGet() noexcept
{return "`fullscreen` | `windowed`";}
static constexpr const char* descriptionLongGet() noexcept
{return "";}
};
template<class ErrorHandler>
struct MakeValue<WindowMode,ErrorHandler>
{
static WindowMode make_value(const std::string& str);
};
template<class ErrorHandler>
WindowMode MakeValue<WindowMode,ErrorHandler>::make_value(const std::string& str)
{
if(str=="fullscreen")
{return WindowMode::FULLSCREEN;}
if(str=="windowed")
{return WindowMode::WINDOWED;}
throw Anja::Error("`",str.c_str(),"` is not a valid window mode. Possible modes are `fullscreen` and `windowed`.");
}
}
#endif