-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgzw_options.cpp
99 lines (84 loc) · 2.51 KB
/
gzw_options.cpp
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
#include "gzw_options.h"
#include <Options.h>
#include <string.h>
#include <stdlib.h>
//
// Static public member functions.
//
options_t options_create(const char* configPath, const char* userPath, const char* commandLine)
{
OpenZWave::Options *opts = OpenZWave::Options::Create(configPath, userPath, commandLine);
return (options_t)opts;
}
bool options_destroy()
{
return OpenZWave::Options::Destroy();
}
options_t options_get()
{
OpenZWave::Options *opts = OpenZWave::Options::Get();
return (options_t)opts;
}
//
// Public member functions.
//
bool options_lock(options_t o)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
return opts->Lock();
}
bool options_addOptionBool(options_t o, const char* name, bool value)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
return opts->AddOptionBool(inStr, value);
}
bool options_addOptionInt(options_t o, const char* name, int32_t value)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
return opts->AddOptionInt(inStr, value);
}
bool options_addOptionLogLevel(options_t o, const char* name, loglevel_t level)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
return opts->AddOptionInt(inStr, loglevel_toLogLevel(level));
}
bool options_addOptionString(options_t o, const char* name, const char* value, bool append)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
std::string _value(value);
return opts->AddOptionString(inStr, _value, append);
}
bool options_getOptionAsBool(options_t o, const char* name, bool* o_value)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
return opts->GetOptionAsBool(inStr, o_value);
}
bool options_getOptionAsInt(options_t o, const char* name, int32_t* o_value)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
return opts->GetOptionAsInt(inStr, o_value);
}
bool options_getOptionAsString(options_t o, const char* name, char **o_value)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
std::string inStr(name);
std::string str;
bool result = opts->GetOptionAsString(inStr, &str);
if (*o_value) {
free(*o_value);
}
*o_value = strdup(str.c_str());
return result;
}
//TODO OptionType options_getOptionType(string const &inStr);
bool options_areLocked(options_t o)
{
OpenZWave::Options *opts = (OpenZWave::Options*)o;
return opts->AreLocked();
}