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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* preferences.cc
* Copyright 2014 John Lindgren
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions, and the following disclaimer in the documentation
* provided with the distribution.
*
* This software is provided "as is" and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising from
* the use of this software.
*/
#include "preferences.h"
#include "runtime.h"
#include <assert.h>
EXPORT bool WidgetConfig::get_bool () const
{
assert (type == Bool);
if (value)
return * (bool *) value;
else if (name)
return aud_get_bool (section, name);
else
return false;
}
EXPORT void WidgetConfig::set_bool (bool val) const
{
assert (type == Bool);
if (value)
* (bool *) value = val;
else if (name)
aud_set_bool (section, name, val);
if (callback)
callback ();
}
EXPORT int WidgetConfig::get_int () const
{
assert (type == Int);
if (value)
return * (int *) value;
else if (name)
return aud_get_int (section, name);
else
return 0;
}
EXPORT void WidgetConfig::set_int (int val) const
{
assert (type == Int);
if (value)
* (int *) value = val;
else if (name)
aud_set_int (section, name, val);
if (callback)
callback ();
}
EXPORT double WidgetConfig::get_float () const
{
assert (type == Float);
if (value)
return * (double *) value;
else if (name)
return aud_get_double (section, name);
else
return 0;
}
EXPORT void WidgetConfig::set_float (double val) const
{
assert (type == Float);
if (value)
* (double *) value = val;
else if (name)
aud_set_double (section, name, val);
if (callback)
callback ();
}
EXPORT String WidgetConfig::get_string () const
{
assert (type == String);
if (value)
return * (::String *) value;
else if (name)
return aud_get_str (section, name);
else
return ::String ();
}
EXPORT void WidgetConfig::set_string (const char * val) const
{
assert (type == String);
if (value)
* (::String *) value = ::String (val);
else if (name)
aud_set_str (section, name, val);
if (callback)
callback ();
}
|