20 {
21
24
25
27
28
30 {"Int32 Key", 42},
31 {"Bool Key", true},
32 {"Subdir", {
33 {"Int32 key", 123 },
34 {"Double Key", 1.2},
35 {"Subsub", {
36 {"Float key", 1.2f},
37 {"String Key", "Hello"},
38 }}
39 }},
40 {"Int Array", {1, 2, 3}},
41 {"Double Array", {1.2, 2.3, 3.4}},
42 {"String Array", {"Hello1", "Hello2", "Hello3"}},
43 {"Large Array", std::array<int, 10>{} },
44 {"Large String", std::string(63, '\0') },
45 {"String Array 10", std::array<std::string, 10>{}},
46
47 {"Large String Array 10", std::array<std::string, 10>{std::string(63, '\0')}}
48 };
49
50
51
52
54
55
57 std::cout <<
o2 << std::endl;
58
59
61 int i =
o[
"Int32 Key"];
64 o[
"Int32 Key"] *= 1.3;
65 std::cout <<
"Should be 57: " <<
o[
"Int32 Key"] << std::endl;
66
67
68 o[
"Int64 Key"] = -1LL;
70 std::cout << std::hex <<
"0x" <<
i64 << std::dec << std::endl;
71
72 o[
"UInt64 Key"] = 0x1234567812345678u;
74 std::cout << std::hex <<
"0x" <<
ui64 << std::dec << std::endl;
75
76
77 o[
"Bool Key"] =
false;
78 o[
"Bool Key"] = !
o[
"Bool Key"];
79
80
81 o[
"Subdir"][
"Subsub"][
"String Key"] =
"Hello";
82 std::string s =
o[
"Subdir"][
"Subsub"][
"String Key"];
83 s += " world!";
84 o[
"Subdir"][
"Subsub"][
"String Key"] = s;
85 s = s +
o[
"Subdir"][
"Subsub"][
"String Key"].s();
86
87
88 std::string
substr(
"Int32 Key");
90
91
92 std::vector<int> v =
o[
"Int Array"];
93 std::fill(v.begin(), v.end(), 10);
95 o[
"Int Array"][1] = 2;
96 i =
o[
"Int Array"][1];
97 o[
"Int Array"].resize(5);
99 std::cout <<
"Arrays size is " <<
o[
"Int Array"].size() << std::endl;
100
101
102 o[
"Int Array"][10] = 10;
103
104
105 std::vector<std::string>
sv;
106 sv =
o[
"String Array"];
107 sv[1] =
"New String";
108 o[
"String Array"] =
sv;
109 o[
"String Array"][2] =
"Another String";
110 o[
"String Array"][3] = std::string(
"One more");
111 s =
o[
"String Array"][1].s();
112
113
114 o[
"String Array 2"][0].set_string_size(
"Hello", 64);
115 o[
"String Array 2"][1] =
"Second string";
116 o[
"String Array 2"][2] =
"Third string";
117
118
119 o[
"Bool Array"] = std::array<bool, 3>{
true,
false,
true};
120 o[
"Bool Array from Vector"] = std::vector<bool>{
true,
false,
true};
121
122
123 int sum = 0;
124 for (
int e :
o[
"Int Array"])
126 std::cout << "Sum should be 37: " << sum << std::endl;
127
128
131
132
133 std::cout <<
oi << std::endl;
134 oi.set_auto_refresh_read(
false);
135 std::cout <<
oi << std::endl;
137 std::cout <<
oi << std::endl;
138
139
140 oi.set_auto_refresh_write(
false);
143
144
148 ot[
"Double Key"] = 1.23;
149 ot[
"String Key"] =
"Hello";
150 ot[
"Int Array"] = std::array<int, 10>{};
151 ot[
"Subdir"][
"Int32 Key"] = 42;
152 ot[
"String Array"] = std::vector<std::string>{
"S1",
"S2",
"S3"};
153 ot[
"Other String Array"][0] =
"OSA0";
154 ot[
"Other String Array"][1] =
"OSA1";
155
156
157 i =
ot[
"Int32 Key"](123);
158 i =
ot[
"New Int32 Key"](123);
159
160 std::cout <<
ot << std::endl;
161
163 std::cout <<
o.print() << std::endl;
164
165
169
170
171 std::cout <<
o.print() << std::endl;
172
173
174 std::cout <<
o.dump() << std::endl;
175
176
177
179 {"Int32 Key", 456},
180 {"New Bool Key", true},
181 {"String Array", {"Hello1", "Hello2", "Hello3"}},
182 {"Bool Key", true},
183 {"Subdir", {
184 {"Int32 key", 135 },
185 {"New Sub Bool Key", false},
186 {"Double Key", 1.5}
187 }}
188 };
190
191
192 std::cout << "After changing structure with o3:" << std::endl;
193 std::cout <<
o3.print() << std::endl;
194
195
197
198
200
201
204 std::cout <<
"Value of key \"" +
o.get_full_path() +
"\" changed to " <<
o << std::endl;
205 });
206
207 do {
210 break;
212
214 return 1;
215}
static void set_debug(bool flag)
void connect_and_fix_structure(std::string path)
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)