20 {
21
24
25
27 {"Int32 Key", 42},
28 {"Bool Key", true},
29 {"Subdir", {
30 {"Int32 key", 123 },
31 {"Double Key", 1.2},
32 {"Subsub", {
33 {"Float key", 1.2f},
34 {"String Key", "Hello"},
35 }}
36 }},
37 {"Int Array", {1, 2, 3}},
38 {"Double Array", {1.2, 2.3, 3.4}},
39 {"String Array", {"Hello1", "Hello2", "Hello3"}},
40 {"Large Array", std::array<int, 10>{} },
41 {"Large String", std::string(63, '\0') },
42 {"String Array 10", std::array<std::string, 10>{}},
43
44 {"Large String Array 10", std::array<std::string, 10>{std::string(63, '\0')}}
45 };
46
47
48
49
51
52
54 std::cout <<
o2 << std::endl;
55
56
58 int i =
o[
"Int32 Key"];
61 o[
"Int32 Key"] *= 1.3;
62 std::cout <<
"Should be 57: " <<
o[
"Int32 Key"] << std::endl;
63
64
65 o[
"Bool Key"] =
false;
66 o[
"Bool Key"] = !
o[
"Bool Key"];
67
68
69 o[
"Subdir"][
"Subsub"][
"String Key"] =
"Hello";
70 std::string s =
o[
"Subdir"][
"Subsub"][
"String Key"];
71 s += " world!";
72 o[
"Subdir"][
"Subsub"][
"String Key"] = s;
73
74
75 std::vector<int> v =
o[
"Int Array"];
76 std::fill(v.begin(), v.end(), 10);
78 o[
"Int Array"][1] = 2;
79 i =
o[
"Int Array"][1];
80 o[
"Int Array"].resize(5);
82
83
84 std::vector<std::string>
sv;
85 sv =
o[
"String Array"];
87 o[
"String Array"] =
sv;
88 o[
"String Array"][2] =
"Another String";
89
90
91 int sum = 0;
92 for (
int e :
o[
"Int Array"])
94 std::cout << "Sum should be 27: " << sum << std::endl;
95
96
99
100
101 std::cout <<
oi << std::endl;
102 oi.set_auto_refresh_read(
false);
103 std::cout <<
oi << std::endl;
105 std::cout <<
oi << std::endl;
106
107
111 ot[
"Double Key"] = 1.23;
112 ot[
"String Key"] =
"Hello";
113 ot[
"Int Array"] = std::array<int, 10>{};
114 ot[
"Subdir"][
"Int32 Key"] = 42;
115 ot[
"String Array"] = std::vector<std::string>{
"S1",
"S2",
"S3"};
116
117
118 i =
ot[
"Int32 Key"](123);
119 i =
ot[
"New Int32 Key"](123);
120 std::string
s1 =
ot[
"New String Key"](
"Hi");
121 std::cout <<
ot << std::endl;
122
124 std::cout <<
o.print() << std::endl;
125
126
129
130
131 std::cout <<
o.print() << std::endl;
132
133
134 std::cout <<
o.dump() << std::endl;
135
136
138
139
142 std::cout <<
"Value of key \"" +
o.get_full_path() +
"\" changed to " <<
o << std::endl;
143 });
144
145 do {
148 break;
150
152 return 1;
153}
static void set_debug(bool flag)
void connect(const std::string &path, const std::string &name, bool write_defaults, bool delete_keys_not_in_defaults=false)
INT cm_yield(INT millisec)
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
INT cm_disconnect_experiment(void)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)