Go to the source code of this file.
Definition at line 10 of file test_configuration.cxx.
17 "my_struct": { "x": 1, "y": 2, "z": 3 }, 18 "my_array" : [ "one", "two", "three" ], 19 "my_array_dict" : [ {"a":1, "b":2}, {"a":10, "b":20}], 20 "data1" : { "data2": { "a":1, "b":2, "c":3 } } 23 string extra_json = R
"( 26 "data1" : { "data2": { "d":4 } }, 27 "data3": { "data4" : 4 } 35 Assert(get(cfg,
"my_int",0) == 1);
36 Assert(
get(cfg,
"my_float",0.0) == 6.9);
38 Assert(
string(
"hello") == convert<std::string>(cfg[
"my_string"]));
40 cerr <<
"my_string=" <<
get(
cfg,
"my_string",
string(
""))<<
endl;
41 Assert(
get(cfg,
"my_string",
string(
"")) ==
string(
"hello"));
44 put(cfg,
"a.b.c", 42);
46 int n42get =
get(
cfg,
"a.b.c", 0);
48 int n42ind = cfg[
"a"][
"b"][
"c"].asInt();
51 Assert(get<int>(cfg,
"my_struct.x") == 1);
53 auto nums = get< vector<string> >(
cfg,
"my_array");
54 for (
auto anum : nums) {
64 cerr <<
"other:\n" << other <<
endl;
65 cerr <<
"last:\n" << last <<
endl;
66 Assert(last[
"a"][
"b"][
"c"] == 42);
67 Assert(last[
"data3"][
"data4"] == 4);
Configuration update(Configuration &a, Configuration &b)
Merge dictionary b into a, return a.
void put(Configuration &cfg, const std::string &dotpath, const T &val)
Put value in configuration at the dotted path.
Configuration branch(Configuration cfg, const std::string &dotpath)
Follow a dot.separated.path and return the branch there.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Json::Value Configuration
int convert< int >(const Configuration &cfg, const int &def)
QTextStream & endl(QTextStream &s)