LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
DatabaseSupport.cc
Go to the documentation of this file.
3 
4 void
5 fhicl::decompose_fhicl(std::string const& filename,
6  std::vector<std::string>& records,
7  std::vector<std::string>& hashes)
8 {
9  // Parse file into a ParameterSet.
11  cet::filepath_maker fpm;
12  make_ParameterSet(filename, fpm, top);
13  decompose_parameterset(top, records, hashes);
14 }
15 
16 void
18  std::vector<std::string>& records,
19  std::vector<std::string>& hashes)
20 {
21  assert(records.size() == hashes.size());
22 
23  // First handle the top-level ParameterSet
24  records.push_back(top.to_compact_string());
25  hashes.push_back(top.id().to_string());
26 
27  // Recurse through all parameters, dealing with ParameterSets and
28  // vectors thereof.
29  std::vector<std::string> keys = top.get_names();
30  for (auto const& key : keys) {
31  if (top.is_key_to_table(key))
32  decompose_parameterset(top.get<ParameterSet>(key), records, hashes);
33  else if (top.is_key_to_sequence(key)) {
34  try {
35  auto nestlings = top.get<std::vector<ParameterSet>>(key);
36  for (auto const& ps : nestlings)
37  decompose_parameterset(ps, records, hashes);
38  }
39  catch (fhicl::exception const&) {
40  // The vector didn't contain ParameterSets, keep going; no
41  // corrective action is needed.
42  }
43  }
44  }
45 }
46 
47 void
48 fhicl::parse_file_and_fill_db(std::string const& filename, sqlite3* out)
49 {
51  cet::filepath_maker fpm;
52  make_ParameterSet(filename, fpm, top);
55 }
std::string to_string() const
static ParameterSetID const & put(ParameterSet const &ps)
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
void parse_file_and_fill_db(std::string const &filename, sqlite3 *db)
void decompose_parameterset(fhicl::ParameterSet const &top, std::vector< std::string > &records, std::vector< std::string > &hashes)
bool is_key_to_sequence(std::string const &key) const
Definition: ParameterSet.h:155
bool is_key_to_table(std::string const &key) const
Definition: ParameterSet.h:149
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string to_compact_string() const
Definition: ParameterSet.h:143
ParameterSetID id() const
std::vector< std::string > get_names() const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
static void exportTo(sqlite3 *db)
void decompose_fhicl(std::string const &filename, std::vector< std::string > &records, std::vector< std::string > &hashes)