blob: f407395fac53567d2b132c9e2f2b59c1450df81e (
plain)
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
|
/*
core/cvar.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_CORE_CVAR_H__
#define __INCLUDED_CORE_CVAR_H__
#include <sstream>
namespace core {
/** new cvars have to be added through the cvar::set functions
* and not created directly.
*/
class Cvar_t {
public:
Cvar_t(const char *cvarname, unsigned int cvarflags = 0);
Cvar_t(const std::string &cvarname, unsigned int cvarflags = 0);
inline const std::string &name() const { return cvar_name; }
inline const std::string &value() const {return cvar_value; }
Cvar_t &operator=(const char *cvarvalue);
Cvar_t &operator=(const std::string &cvarvalue);
Cvar_t &operator=(int cvarvalue);
private:
std::string cvar_name;
std::string cvar_value;
unsigned int cvar_flags;
};
typedef Cvar_t *Cvar;
/// the cvar registry
namespace cvar
{
/// create a new cvar containing a string value
Cvar set(const char *cvarname, const char *value);
/// create a new cvar containing an integer value
Cvar set(const char *cvarname, int value);
/// delete a cvar
void unset(const char *cvarname);
// delete a cvar
void unset(const std::string &cvarname);
/// search for a named cvar, returns 0 if not found
Cvar find(const std::string &cvarname);
/// search for a named cvar, returns 0 if not found
Cvar find(const char *cvarname);
} // namespace cvar
} // namespace core
#endif // __INCLUDED_CORE_CVAR_H__
|