LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
encode_extended_value.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // encode overload for extended_value
4 //
5 // ======================================================================
6 
9 #include "fhiclcpp/exception.h"
12 
13 using namespace fhicl;
14 
19 
20 using ps_atom_t = ParameterSet::ps_atom_t; // same as atom_t!
22 
23 std::any
25 {
26  switch (xval.tag) {
27  case NIL:
28  case BOOL:
29  case NUMBER:
30  case STRING:
31  return atom_t(xval);
32 
33  case COMPLEX: {
34  auto const [real, imag] = complex_t(xval);
35  return '(' + real + ',' + imag + ')';
36  }
37 
38  case SEQUENCE: {
39  ps_sequence_t result;
40  for (auto const& e : sequence_t(xval)) {
41  result.push_back(encode(e));
42  }
43  return result;
44  }
45 
46  case TABLE: {
47  ParameterSet result;
48  for (auto const& [key, value] : table_t(xval)) {
49  if (!value.in_prolog)
50  result.put(key, value);
51  }
52  return ParameterSetRegistry::put(result);
53  }
54 
55  case TABLEID: {
56  atom_t const& tableID = atom_t(xval);
57  return ParameterSetID(tableID);
58  }
59 
60  case UNKNOWN:
61  default: {
62  throw fhicl::exception(type_mismatch, "unknown extended value");
63  }
64  }
65 } // encode()
intermediate_table::complex_t complex_t
static ParameterSetID const & put(ParameterSet const &ps)
ps_atom_t encode(std::string const &)
Definition: coding.cc:83
intermediate_table::table_t table_t
::fhicl::detail::ps_atom_t encode(Interval< Args... > const &iv)
Encodes a quantity interval into a FHiCL parameter set atom.
std::vector< std::any > ps_sequence_t
Definition: coding.h:45
intermediate_table::sequence_t sequence_t
extended_value::complex_t complex_t
parameter set interface
extended_value::sequence_t sequence_t
fhicl::detail::ps_atom_t ps_atom_t
Definition: ParameterSet.h:38
fhicl::detail::ps_sequence_t ps_sequence_t
Definition: ParameterSet.h:39
double value
Definition: spectrum.C:18
extended_value::table_t table_t
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:35
extended_value::atom_t atom_t
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33