Configuration.cxx
Go to the documentation of this file.
2 
3 using namespace WireCell;
4 using namespace std;
5 
6 
8  const std::string& dotpath)
9 {
10  std::vector<std::string> path;
11  boost::algorithm::split(path, dotpath, boost::algorithm::is_any_of("."));
12  for (auto name : path) {
13  cfg = cfg[name];
14  }
15  return cfg;
16 }
17 
18 // http://stackoverflow.com/a/23860017
21 {
22  if (a.isNull()) {
23  a = b;
24  return b;
25  }
26  if (!a.isObject() || !b.isObject()) {
27  return a;
28  }
29 
30  for (const auto& key : b.getMemberNames()) {
31  if (a[key].isObject()) {
32  update(a[key], b[key]);
33  }
34  else {
35  a[key] = b[key];
36  }
37  }
38  return a;
39 }
40 
41 /// Append array b onto end of a and return a.
43 {
44  Configuration ret(Json::arrayValue);
45  for (auto x : a) {
46  ret.append(x);
47  }
48  for (auto x : b) {
49  ret.append(x);
50  }
51  return ret;
52 }
static QCString name
Definition: declinfo.cpp:673
Configuration update(Configuration &a, Configuration &b)
Merge dictionary b into a, return a.
std::string string
Definition: nybbler.cc:12
STL namespace.
cfg
Definition: dbjson.py:29
Configuration branch(Configuration cfg, const std::string &dotpath)
Follow a dot.separated.path and return the branch there.
def key(type, name=None)
Definition: graph.py:13
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
Definition: Main.h:22
Configuration append(Configuration &a, Configuration &b)
Return an array which is composed of the array b appended to the array a.
Json::Value Configuration
Definition: Configuration.h:50
static bool * b
Definition: config.cpp:1043
list x
Definition: train.py:276
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35