-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathc_console.h
More file actions
72 lines (53 loc) · 1.77 KB
/
c_console.h
File metadata and controls
72 lines (53 loc) · 1.77 KB
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
#ifndef C_CONSOLE_HDR
#define C_CONSOLE_HDR
#include "u_string.h"
#include "u_optional.h"
#include "u_map.h"
#include "c_variable.h"
#include "c_complete.h"
namespace c {
struct Console {
typedef u::map<u::string, Reference> Map;
enum {
kVarSuccess = 1,
kVarRangeError,
kVarTypeError,
kVarNotFoundError,
kVarReadOnlyError,
kVarMalformedError
};
// get a reference to a console variable
static const Reference &reference(const char *name);
// get the variable value: variable must exist
template <typename T>
static Variable<T> &value(const char *name);
// get the variable value as a string (or u::none if not exist.)
static u::optional<u::string> value(const char *name);
// set the variable value directly
template <typename T>
static int set(const char *name, const T &value);
// set the variable value by string
static int change(const char *name, const char *value);
static int change(const u::string &name, const u::string &value);
// initialize the console subsystem now
static void initialize();
// shut down the console subsystem
static void shutdown();
// get console variable suggestions for a prefix
static u::vector<u::string> suggestions(const u::string &prefix);
private:
friend struct Config;
friend struct Reference;
static Reference *m_references;
static Reference *split(Reference *ref);
static Reference *merge(Reference *lhs, Reference *rhs);
static Reference *sort(Reference *begin);
static Map &map();
static unsigned char m_mapData[sizeof(Map)];
static Map *m_map;
static Complete &complete();
static unsigned char m_completeData[sizeof(Complete)];
static Complete *m_complete;
};
}
#endif