LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
encode_extended_value.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // encode overload for extended_value
4 //
5 // ======================================================================
6 
7 #include "cetlib/includer.h"
10 #include "fhiclcpp/exception.h"
13 
14 using namespace fhicl;
15 
20 
21 using ps_atom_t = ParameterSet::ps_atom_t; // same as atom_t!
23 
24 boost::any
26 {
27  switch (xval.tag) {
28  case NIL:
29  case BOOL:
30  case NUMBER:
31  case STRING:
32  return atom_t(xval);
33 
34  case COMPLEX: {
35  complex_t const& cmplx = complex_t(xval);
36  return '(' + cmplx.first + ',' + cmplx.second + ')';
37  }
38 
39  case SEQUENCE: {
40  ps_sequence_t result;
41  sequence_t const& seq = sequence_t(xval);
42  for (sequence_t::const_iterator it = seq.begin(), e = seq.end(); it != e;
43  ++it)
44  result.push_back(boost::any(encode(*it)));
45  return result;
46  }
47 
48  case TABLE: {
50  table_t const& tbl = table_t(xval);
51  ParameterSet result;
52  for (const_iterator it = tbl.begin(), e = tbl.end(); it != e; ++it) {
53  if (!it->second.in_prolog)
54  result.put(it->first, it->second);
55  }
56  return ParameterSetRegistry::put(result);
57  }
58 
59  case TABLEID: {
60  atom_t const& tableID = atom_t(xval);
61  return ParameterSetID(tableID);
62  }
63 
64  case UNKNOWN:
65  default: {
66  throw fhicl::exception(type_mismatch, "unknown extended value");
67  }
68  }
69 } // encode()
intermediate_table::complex_t complex_t
iterator begin()
Definition: stdmap_shims.h:155
static ParameterSetID const & put(ParameterSet const &ps)
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
intermediate_table::table_t table_t
extended_value::table_t table_t
extended_value::atom_t atom_t
extended_value::complex_t complex_t
intermediate_table::sequence_t sequence_t
iterator end()
Definition: stdmap_shims.h:177
extended_value::sequence_t sequence_t
intermediate_table::const_iterator const_iterator
parameter set interface
fhicl::detail::ps_atom_t ps_atom_t
Definition: ParameterSet.h:36
fhicl::detail::ps_sequence_t ps_sequence_t
Definition: ParameterSet.h:37
ParameterSet::ps_atom_t ps_atom_t
fhicl::extended_value::sequence_t sequence_t
intermediate_table::atom_t atom_t
ParameterSet::ps_sequence_t ps_sequence_t
Float_t e
Definition: plot.C:34
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< boost::any > ps_sequence_t
Definition: coding.h:46