LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
fhicl::detail Namespace Reference

Namespaces

 atom
 
 no_defaults
 
 sequence
 
 table
 
 yes_defaults
 

Classes

struct  AllowedConfiguration
 
struct  AllowedConfiguration< T, cet::enable_if_type_exists_t< typename T::Parameters > >
 
class  AtomBase
 
class  DelegateBase
 
class  HashParameterSetID
 
class  Indentation
 
class  it_value_get
 
class  it_value_get< std::complex< U >, typename tt::disable_if< std::is_reference< std::complex< U > >::value|| std::is_pointer< std::complex< U > >::value >::type >
 
class  it_value_get< T, typename tt::disable_if< std::is_reference< T >::value|| std::is_pointer< T >::value >::type >
 
class  it_value_get< intermediate_table::sequence_t & >
 
class  it_value_get< intermediate_table::sequence_t >
 
class  it_value_get< intermediate_table::sequence_t const & >
 
class  it_value_get< intermediate_table::table_t & >
 
class  it_value_get< intermediate_table::table_t >
 
class  it_value_get< intermediate_table::table_t const & >
 
class  KeyAssembler
 
class  Keys
 
class  MaybeDisplayParent
 
class  ParameterBase
 
class  ParameterMetadata
 
class  ParameterWalker
 
struct  per_entry
 
struct  per_entry< 0, TUPLE >
 
class  Prettifier
 
class  PrettifierAnnotated
 
class  PrettifierPrefixAnnotated
 
class  PrintAllowedConfiguration
 
class  RegisterIfTableMember
 
class  SearchAllowedConfiguration
 
class  SequenceBase
 
class  SequenceKey
 
class  TableBase
 
class  TableMemberRegistry
 
class  ValidateThenSet
 
class  validationException
 

Typedefs

typedef std::string ps_atom_t
 
typedef std::vector< boost::any > ps_sequence_t
 
typedef long double ldbl
 
using key_t = std::string
 
using name_t = std::string
 
using cit_size_t = std::vector< std::size_t >::const_iterator
 
using base_ptr = cet::exempt_ptr< ParameterBase >
 

Enumerations

enum  binding_modifier : unsigned char { binding_modifier::NONE, binding_modifier::PROTECT_IGNORE, binding_modifier::PROTECT_ERROR }
 
enum  print_mode { print_mode::raw, print_mode::annotated, print_mode::prefix_annotated }
 

Functions

bool is_sequence (boost::any const &val)
 
bool is_table (boost::any const &val)
 
bool is_nil (boost::any const &val)
 
ps_atom_t encode (std::string const &)
 
ps_atom_t encode (char const *)
 
ps_atom_t encode (void *)
 
ps_atom_t encode (bool)
 
ParameterSetID encode (ParameterSet const &)
 
ps_atom_t encode (std::uintmax_t)
 
template<class T >
tt::enable_if< tt::is_uint< T >::value, ps_atom_t >::type encode (T const &)
 
ps_atom_t encode (std::intmax_t)
 
template<class T >
tt::enable_if< tt::is_int< T >::value, ps_atom_t >::type encode (T const &)
 
ps_atom_t encode (ldbl)
 
template<class T >
tt::enable_if< tt::is_floating_point< T >::value, ps_atom_t >::type encode (T const &)
 
template<class T >
ps_atom_t encode (std::complex< T > const &)
 
template<class T >
ps_sequence_t encode (std::vector< T > const &)
 
template<class T >
tt::disable_if< tt::is_numeric< T >::value, std::string >::type encode (T const &)
 
void decode (boost::any const &, std::string &)
 
void decode (boost::any const &, void *&)
 
void decode (boost::any const &, bool &)
 
void decode (boost::any const &, ParameterSet &)
 
void decode (boost::any const &, std::uintmax_t &)
 
template<class T >
tt::enable_if< tt::is_uint< T >::value, void >::type decode (boost::any const &, T &)
 
void decode (boost::any const &, std::intmax_t &)
 
template<class T >
tt::enable_if< tt::is_int< T >::value, void >::type decode (boost::any const &, T &)
 
void decode (boost::any const &, ldbl &)
 
template<class T >
tt::enable_if< tt::is_floating_point< T >::value, void >::type decode (boost::any const &, T &)
 
void decode (boost::any const &, std::complex< ldbl > &)
 
template<class T >
void decode (boost::any const &, std::complex< T > &)
 
template<class T >
void decode (boost::any const &, std::vector< T > &)
 
template<typename U >
void decode_tuple (boost::any const &, U &tuple)
 
template<typename T , std::size_t SIZE>
void decode (boost::any const &a, std::array< T, SIZE > &result)
 
template<typename KEY , typename VALUE >
void decode (boost::any const &a, std::pair< KEY, VALUE > &result)
 
template<typename... ARGS>
void decode (boost::any const &a, std::tuple< ARGS... > &result)
 
template<class T >
tt::disable_if< tt::is_numeric< T >::value, void >::type decode (boost::any const &, T &)
 
boost::any encode (extended_value const &xval)
 
Keys get_names (std::string const &key)
 
SequenceKey get_sequence_indices (std::string const &key)
 
bool find_an_any (cit_size_t it, cit_size_t const cend, boost::any &a)
 
std::string nl (std::size_t i=1)
 
std::string printed_suffix (std::string const &key, std::size_t const sz)
 
std::string print_prefix_annotated_info (std::string const &curr_info)
 
std::string print_annotated_info (std::string const &curr_info, std::string const &cached_info)
 
bool is_sequence_element (std::string const &key)
 
bool is_table_member (std::string const &key)
 
template<typename L >
void try_insert (L l, std::string const &key)
 
std::string translate (error)
 
void throwOnSQLiteFailure (sqlite3 *db, char *msg=nullptr)
 
std::function< bool()> AlwaysUse ()
 
void check_nargs_for_bounded_sequences (std::string const &key, std::size_t expected, std::size_t provided)
 
std::string optional_parameter_message (bool const with_comment=true)
 
std::string strip_first_containing_name (std::string const &key)
 
std::string strip_all_containing_names (std::string const &key)
 
template<typename T >
std::set< std::string > ensure_callable ()
 
std::set< std::string > & concatenate_keys (std::set< std::string > &keys)
 
template<typename H , typename... T>
std::set< std::string > & concatenate_keys (std::set< std::string > &keys, H const &h, T const &...t)
 

Typedef Documentation

using fhicl::detail::base_ptr = typedef cet::exempt_ptr<ParameterBase>

Definition at line 17 of file MaybeDisplayParent.h.

using fhicl::detail::cit_size_t = typedef std::vector<std::size_t>::const_iterator

Definition at line 108 of file ParameterSetImplHelpers.h.

using fhicl::detail::key_t = typedef std::string

Definition at line 71 of file KeyAssembler.h.

typedef long double fhicl::detail::ldbl

Definition at line 47 of file coding.h.

using fhicl::detail::name_t = typedef std::string

Definition at line 72 of file KeyAssembler.h.

typedef std::string fhicl::detail::ps_atom_t

Definition at line 45 of file coding.h.

typedef std::vector<boost::any> fhicl::detail::ps_sequence_t

Definition at line 46 of file coding.h.

Enumeration Type Documentation

enum fhicl::detail::binding_modifier : unsigned char
strong
Enumerator
NONE 
PROTECT_IGNORE 
PROTECT_ERROR 

Definition at line 5 of file binding_modifier.h.

5  : unsigned char {
6  NONE,
9 #if 0 /* Preparation for issue #7231. */
10  INITIAL,
11  REPLACE,
12  REPLACE_COMPAT,
13  ADD_OR_REPLACE_COMPAT
14 #endif
15  };
Enumerator
raw 
annotated 
prefix_annotated 

Definition at line 7 of file print_mode.h.

Function Documentation

std::function<bool()> fhicl::detail::AlwaysUse ( )
inline
void fhicl::detail::check_nargs_for_bounded_sequences ( std::string const &  key,
std::size_t  expected,
std::size_t  provided 
)

Definition at line 8 of file check_nargs_for_bounded_sequences.cc.

Referenced by fhicl::OptionalSequence< Table< T >< art::RootInputFileSequence::Config::SecondaryFile > >::do_prepare_elements_for_validation(), fhicl::OptionalTuple< ARGS... >::do_prepare_elements_for_validation(), fhicl::Sequence< float, 3u >::do_prepare_elements_for_validation(), and fhicl::Tuple< TYPES >::do_prepare_elements_for_validation().

11 {
12  auto maybe_plural = [](std::size_t const nargs) {
13  return nargs == 1ull ? "" : "s";
14  };
15  auto has_or_have = [](std::size_t const nargs) {
16  return nargs == 1ull ? "has" : "have";
17  };
18  if (nargs != expected) {
19  std::ostringstream oss;
20  oss << '\n'
21  << nargs << " value" << maybe_plural(nargs) << ' ' << has_or_have(nargs)
22  << " been provided for the parameter with key:\n"
23  << " " << key << '\n'
24  << "which expects " << expected << " value" << maybe_plural(expected)
25  << '.';
26  throw detail::validationException{oss.str().c_str()};
27  }
28 }
std::set<std::string>& fhicl::detail::concatenate_keys ( std::set< std::string > &  keys)
inline

Definition at line 23 of file KeysToIgnore.h.

Referenced by concatenate_keys(), and fhicl::KeysToIgnore< H, T >::operator()().

24  {
25  return keys;
26  }
template<typename H , typename... T>
std::set<std::string>& fhicl::detail::concatenate_keys ( std::set< std::string > &  keys,
H const &  h,
T const &...  t 
)

Definition at line 30 of file KeysToIgnore.h.

References evd::details::begin(), concatenate_keys(), and evd::details::end().

31  {
32  keys.insert(begin(h), end(h));
33  return concatenate_keys(keys, t...);
34  }
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::set< std::string > & concatenate_keys(std::set< std::string > &keys, H const &h, T const &...t)
Definition: KeysToIgnore.h:30
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void fhicl::detail::decode ( boost::any const &  ,
void *&   
)
void fhicl::detail::decode ( boost::any const &  ,
bool &   
)
void fhicl::detail::decode ( boost::any const &  ,
ParameterSet  
)
void fhicl::detail::decode ( boost::any const &  ,
std::uintmax_t &   
)
template<class T >
tt::enable_if< tt::is_uint< T >::value, void >::type fhicl::detail::decode ( boost::any const &  a,
T &  result 
)

Definition at line 222 of file coding.h.

References decode(), and fhicl::detail::atom::value().

223 {
224  std::uintmax_t via;
225  decode(a, via);
226  result = boost::numeric_cast<T>(via);
227 }
tt::disable_if< tt::is_numeric< T >::value, void >::type decode(boost::any const &, T &)
Definition: coding.h:366
void fhicl::detail::decode ( boost::any const &  ,
std::intmax_t &   
)
template<class T >
tt::enable_if< tt::is_int< T >::value, void >::type fhicl::detail::decode ( boost::any const &  a,
T &  result 
)

Definition at line 233 of file coding.h.

References decode(), and fhicl::detail::atom::value().

234 {
235  std::intmax_t via;
236  decode(a, via);
237  result = boost::numeric_cast<T>(via);
238 }
tt::disable_if< tt::is_numeric< T >::value, void >::type decode(boost::any const &, T &)
Definition: coding.h:366
void fhicl::detail::decode ( boost::any const &  ,
ldbl  
)
template<class T >
tt::enable_if< tt::is_floating_point< T >::value, void >::type fhicl::detail::decode ( boost::any const &  a,
T &  result 
)

Definition at line 244 of file coding.h.

References decode().

245 {
246  ldbl via;
247  decode(a, via);
248  result = via; // boost::numeric_cast<T>(via);
249 }
long double ldbl
Definition: ParameterSet.cc:32
tt::disable_if< tt::is_numeric< T >::value, void >::type decode(boost::any const &, T &)
Definition: coding.h:366
void fhicl::detail::decode ( boost::any const &  ,
std::complex< ldbl > &   
)
template<class T >
void fhicl::detail::decode ( boost::any const &  a,
std::complex< T > &  result 
)

Definition at line 255 of file coding.h.

References decode().

256 {
257  std::complex<ldbl> via;
258  decode(a, via);
259  result = std::complex<T>(boost::numeric_cast<T>(via.real()),
260  boost::numeric_cast<T>(via.imag()));
261 }
tt::disable_if< tt::is_numeric< T >::value, void >::type decode(boost::any const &, T &)
Definition: coding.h:366
template<class T >
void fhicl::detail::decode ( boost::any const &  a,
std::vector< T > &  result 
)

Definition at line 267 of file coding.h.

References decode(), e, fhicl::extended_value::is_a(), fhicl::parse_value_string(), fhicl::SEQUENCE, and fhicl::type_mismatch.

268 {
269  if (a.type() == typeid(std::string)) {
270  typedef fhicl::extended_value extended_value;
272 
273  std::string str;
274  decode(a, str);
275 
276  extended_value xval;
277  std::string unparsed;
278  if (!parse_value_string(str, xval, unparsed) || !xval.is_a(SEQUENCE))
279  throw fhicl::exception(type_mismatch, "error in sequence string:\n")
280  << str << "\nat or before:\n"
281  << unparsed;
282 
283  sequence_t const& seq = sequence_t(xval);
284  result.clear();
285  T via;
286  for (sequence_t::const_iterator it = seq.begin(), e = seq.end(); it != e;
287  ++it) {
288  decode(it->to_string(), via);
289  result.push_back(via);
290  }
291  }
292 
293  else if (a.type() == typeid(ps_sequence_t)) {
294  ps_sequence_t const& seq = boost::any_cast<ps_sequence_t>(a);
295  result.clear();
296  T via;
297  for (ps_sequence_t::const_iterator it = seq.begin(), e = seq.end(); it != e;
298  ++it) {
299  decode(*it, via);
300  result.push_back(via);
301  }
302  }
303 
304  else
305  throw fhicl::exception(type_mismatch, "invalid sequence");
306 }
bool parse_value_string(std::string const &s, extended_value &v, std::string &unparsed)
Definition: parse.cc:802
tt::disable_if< tt::is_numeric< T >::value, void >::type decode(boost::any const &, T &)
Definition: coding.h:366
intermediate_table::const_iterator const_iterator
fhicl::extended_value::sequence_t sequence_t
ParameterSet::ps_sequence_t ps_sequence_t
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< boost::any > ps_sequence_t
Definition: coding.h:46
template<typename T , std::size_t SIZE>
void fhicl::detail::decode ( boost::any const &  a,
std::array< T, SIZE > &  result 
)

Definition at line 129 of file coding.h.

References decode_tuple().

130  {
131  decode_tuple(a, result);
132  }
void decode_tuple(boost::any const &, U &tuple)
Definition: coding.h:337
template<typename KEY , typename VALUE >
void fhicl::detail::decode ( boost::any const &  a,
std::pair< KEY, VALUE > &  result 
)

Definition at line 135 of file coding.h.

References decode_tuple().

136  {
137  decode_tuple(a, result);
138  }
void decode_tuple(boost::any const &, U &tuple)
Definition: coding.h:337
template<typename... ARGS>
void fhicl::detail::decode ( boost::any const &  a,
std::tuple< ARGS... > &  result 
)

Definition at line 141 of file coding.h.

References decode_tuple().

142  {
143  decode_tuple(a, result);
144  }
void decode_tuple(boost::any const &, U &tuple)
Definition: coding.h:337
template<class T >
tt::disable_if< tt::is_numeric< T >::value, void >::type fhicl::detail::decode ( boost::any const &  a,
T &  result 
)

Definition at line 366 of file coding.h.

367 {
368  result = boost::any_cast<T>(a);
369 }
template<typename U >
void fhicl::detail::decode_tuple ( boost::any const &  a,
U &  tuple 
)

Definition at line 337 of file coding.h.

References decode(), fhicl::detail::per_entry< SIZE, TUPLE >::decode_tuple_entry(), tmp, and fhicl::detail::atom::value().

Referenced by decode(), and is_table().

338 {
339  ps_sequence_t const& seq = boost::any_cast<ps_sequence_t>(a);
340 
341  constexpr std::size_t TUPLE_SIZE = std::tuple_size<U>::value;
342 
343  if (seq.size() != TUPLE_SIZE) {
344  std::ostringstream errmsg;
345  errmsg << "Number of expected arguments (" << TUPLE_SIZE
346  << ") does not match "
347  << "number of FHiCL sequence entries (" << seq.size() << "): [ ";
348  for (auto ca = seq.begin(); ca != seq.cend(); ++ca) {
349  std::string tmp;
350  decode(*ca, tmp);
351  errmsg << tmp;
352  if (ca != seq.cend() - 1) {
353  errmsg << ", ";
354  }
355  }
356  errmsg << " ]";
357  throw std::length_error(errmsg.str());
358  }
359 
360  per_entry<TUPLE_SIZE - 1, U>::decode_tuple_entry(seq, result);
361 }
Float_t tmp
Definition: plot.C:37
tt::disable_if< tt::is_numeric< T >::value, void >::type decode(boost::any const &, T &)
Definition: coding.h:366
std::string value(boost::any const &)
ParameterSet::ps_sequence_t ps_sequence_t
boost::any fhicl::detail::encode ( extended_value const &  xval)

Definition at line 25 of file encode_extended_value.cc.

References shims::map< Key, T, Compare, Allocator >::begin(), fhicl::BOOL, fhicl::COMPLEX, e, encode(), shims::map< Key, T, Compare, Allocator >::end(), fhicl::NIL, fhicl::NUMBER, fhicl::ParameterSetRegistry::put(), fhicl::ParameterSet::put(), fhicl::SEQUENCE, fhicl::STRING, fhicl::TABLE, fhicl::TABLEID, fhicl::extended_value::tag, fhicl::type_mismatch, and fhicl::UNKNOWN.

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
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
intermediate_table::table_t table_t
intermediate_table::sequence_t sequence_t
iterator end()
Definition: stdmap_shims.h:177
intermediate_table::const_iterator const_iterator
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
ps_atom_t fhicl::detail::encode ( std::string const &  value)

Definition at line 87 of file coding.cc.

References fhicl::extended_value::is_a(), fhicl::parse_value_string(), fhicl::STRING, and fhicl::type_mismatch.

Referenced by encode(), is_table(), fhicl::intermediate_table::put(), fhicl::ParameterSet::put(), fhicl::ParameterSet::put_or_replace(), fhicl::ParameterSet::put_or_replace_compatible(), and fhicl::intermediate_table::putNil().

88 {
89  bool is_quoted = value.size() >= 2 && value[0] == value.end()[-1] &&
90  (value[0] == '\"' || value[0] == '\'');
91 
92  std::string const& str = is_quoted ? value : '\'' + value + '\'';
93 
94  extended_value xval;
95  std::string unparsed;
96  if (!parse_value_string(str, xval, unparsed) || !xval.is_a(STRING))
97  throw fhicl::exception(type_mismatch, "error in input string:\n")
98  << str << "\nat or before:\n"
99  << unparsed;
100 
101  return extended_value::atom_t(xval);
102 }
bool parse_value_string(std::string const &s, extended_value &v, std::string &unparsed)
Definition: parse.cc:802
bool is_a(value_tag t) const
intermediate_table::atom_t atom_t
std::string value(boost::any const &)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
ps_atom_t fhicl::detail::encode ( char const *  value)

Definition at line 105 of file coding.cc.

References encode().

106 {
107  return encode(std::string(value));
108 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
std::string value(boost::any const &)
ps_atom_t fhicl::detail::encode ( void *  )

Definition at line 111 of file coding.cc.

References canon_nil().

112 {
113  return canon_nil();
114 }
static std::string canon_nil()
Definition: coding.cc:30
ps_atom_t fhicl::detail::encode ( bool  value)

Definition at line 117 of file coding.cc.

References literal_false(), and literal_true().

118 {
119  return value ? literal_true() : literal_false();
120 }
static ps_atom_t literal_false()
Definition: coding.cc:44
static ps_atom_t literal_true()
Definition: coding.cc:37
std::string value(boost::any const &)
ParameterSetID fhicl::detail::encode ( ParameterSet const &  value)

Definition at line 123 of file coding.cc.

References fhicl::ParameterSetRegistry::put().

124 {
125  return ParameterSetRegistry::put(value);
126 }
std::string value(boost::any const &)
ps_atom_t fhicl::detail::encode ( std::uintmax_t  value)

Definition at line 129 of file coding.cc.

References fhicl::detail::atom::value().

130 {
131  std::string result = lexical_cast<std::string>(value);
132  if (result.size() > 6) {
133  std::size_t sz = result.size() - 1;
134  result.insert(1, ".");
135  result += "e+" + lexical_cast<std::string>(sz);
136  }
137  return result;
138 }
std::string value(boost::any const &)
template<class T >
tt::enable_if<tt::is_uint<T>::value, ps_atom_t>::type fhicl::detail::encode ( T const &  )
ps_atom_t fhicl::detail::encode ( std::intmax_t  value)

Definition at line 141 of file coding.cc.

References encode().

142 {
143  std::string result = encode(std::uintmax_t(std::abs(value)));
144  if (value < 0)
145  result.insert(0, "-");
146  return result;
147 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
std::string value(boost::any const &)
template<class T >
tt::enable_if<tt::is_int<T>::value, ps_atom_t>::type fhicl::detail::encode ( T const &  )
ps_atom_t fhicl::detail::encode ( ldbl  value)

Definition at line 150 of file coding.cc.

References atom_rep(), fhicl::BOOL, canon_nil(), fhicl::COMPLEX, decode(), encode(), fhicl::ParameterSetRegistry::get(), fhicl::extended_value::is_a(), literal_infinity(), literal_true(), fhicl::NUMBER, fhicl::parse_value_string(), fhicl::type_mismatch, and fhicl::detail::atom::value().

151 {
152  if (value == std::numeric_limits<ldbl>::infinity())
153  return '+' + literal_infinity();
154  if (value == -std::numeric_limits<ldbl>::infinity())
155  return '-' + literal_infinity();
156 
157  std::intmax_t chopped = static_cast<std::intmax_t>(value);
158  if (static_cast<ldbl>(chopped) == value)
159  return encode(chopped);
160 
161  std::string result;
162  cet::canonical_number(lexical_cast<std::string>(value), result);
163  return result;
164 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
static ps_atom_t literal_infinity()
Definition: coding.cc:51
std::string value(boost::any const &)
template<class T >
tt::enable_if<tt::is_floating_point<T>::value, ps_atom_t>::type fhicl::detail::encode ( T const &  )
template<class T >
ps_atom_t fhicl::detail::encode ( std::complex< T > const &  )
template<class T >
ps_sequence_t fhicl::detail::encode ( std::vector< T > const &  )
template<class T >
tt::disable_if< tt::is_numeric< T >::value, std::string >::type fhicl::detail::encode ( T const &  value)

Definition at line 211 of file coding.h.

References fhicl::detail::atom::value().

212 {
213  return boost::lexical_cast<std::string>(value);
214 }
std::string value(boost::any const &)
template<typename T >
std::set<std::string> fhicl::detail::ensure_callable ( )

Definition at line 16 of file KeysToIgnore.h.

References TEMPLATE_ARG.

17  {
19  return T{}();
20  }
#define TEMPLATE_ARG
Definition: KeysToIgnore.h:9
bool fhicl::detail::find_an_any ( cit_size_t  it,
cit_size_t const  cend,
boost::any &  a 
)
inline

Definition at line 111 of file ParameterSetImplHelpers.h.

Referenced by fhicl::ParameterSet::find_one_(), fhicl::ParameterSet::get_one_(), and fhicl::ParameterSet::key_is_type_().

112  {
113  if (it == cend) {
114  // If we got this far, that means the element must exist,
115  // otherwise the previous recursive 'find_parameter' call would
116  // have returned false.
117  return true;
118  }
119 
120  auto const seq = boost::any_cast<ps_sequence_t>(a);
121 
122  if (*it >= seq.size())
123  return false;
124 
125  a = seq[*it];
126 
127  return find_an_any(++it, cend, a);
128  }
ParameterSet::ps_sequence_t ps_sequence_t
bool find_an_any(cit_size_t it, cit_size_t const cend, boost::any &a)
Keys fhicl::detail::get_names ( std::string const &  key)
inline

Definition at line 42 of file ParameterSetImplHelpers.h.

References fhicl::cant_find, and fhicl::detail::Keys::last().

Referenced by fhicl::ParameterSet::get_if_present(), fhicl::ParameterSet::has_key(), and fhicl::ParameterSet::key_is_type_().

43  {
44  std::vector<std::string> keys;
45  boost::algorithm::split(keys, key, boost::algorithm::is_any_of("."));
46 
47  // Remove empty keys
48  keys.erase(std::remove(keys.begin(), keys.end(), ""), keys.end());
49 
50  if (keys.empty())
51  throw fhicl::exception(cant_find, "vacuous key");
52 
53  std::string const last = keys.back();
54  keys.pop_back();
55 
56  return Keys{keys, last};
57  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
SequenceKey fhicl::detail::get_sequence_indices ( std::string const &  key)
inline

Definition at line 86 of file ParameterSetImplHelpers.h.

References geo::vect::indices().

Referenced by fhicl::ParameterSet::find_one_(), fhicl::ParameterSet::get_one_(), and fhicl::ParameterSet::key_is_type_().

87  {
88 
89  // Split "name[0][5][1]" according to delimiters "][", "[", and "]"
90  // to give {"name","0","5","1"};
91  auto tokens = cet::split_by_regex(key, R"((\]\[|\[|\]))");
92 
93  auto const name = tokens.front();
94  tokens.erase(tokens.begin());
95 
96  std::vector<std::size_t> indices;
97  cet::transform_all(
98  tokens, std::back_inserter(indices), [](std::string const& index) {
99  return std::stoul(index);
100  });
101 
102  return SequenceKey{name, indices};
103  }
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
bool fhicl::detail::is_nil ( boost::any const &  val)

Definition at line 75 of file coding.cc.

References atom_rep(), canon_nil(), is_sequence(), and is_table().

Referenced by fhicl::ParameterSet::insert_or_replace_compatible_(), and is_table().

76 {
77  bool result = false;
78  if (!(is_table(val) || is_sequence(val))) {
79  std::string str;
80  atom_rep(val, str);
81  result = (str == canon_nil());
82  }
83  return result;
84 }
bool is_sequence(boost::any const &val)
Definition: coding.h:50
bool is_table(boost::any const &val)
Definition: coding.h:56
static std::string canon_nil()
Definition: coding.cc:30
static void atom_rep(any const &a, std::string &result)
Definition: coding.cc:58
bool fhicl::detail::is_sequence_element ( std::string const &  key)
inline

Definition at line 67 of file printing_helpers.h.

References fhicl::detail::sequence::closing_brace().

Referenced by fhicl::detail::PrintAllowedConfiguration::before_action(), is_table_member(), fhicl::detail::table::printed_prefix(), fhicl::detail::sequence::printed_prefix(), and fhicl::detail::atom::printed_prefix().

68  {
69  auto pos = key.find_last_of(sequence::closing_brace());
70  return pos != std::string::npos && pos == key.size() - 1;
71  }
bool fhicl::detail::is_table_member ( std::string const &  key)
inline

Definition at line 74 of file printing_helpers.h.

References is_sequence_element().

Referenced by fhicl::detail::RegisterIfTableMember::RegisterIfTableMember().

75  {
76  auto pos1 = key.find_last_of(".");
77  if (pos1 == std::string::npos)
78  return false;
79 
80  return is_sequence_element(key) ? false : true;
81  }
bool is_sequence_element(std::string const &key)
std::string fhicl::detail::optional_parameter_message ( bool const  with_comment = true)
inline

Definition at line 7 of file optional_parameter_message.h.

Referenced by fhicl::detail::ValidateThenSet::check_keys(), and art::detail::describe().

8  {
9  std::string result;
10  if (with_comment) {
11  result += "## ";
12  }
13  result += "Any parameters prefaced with '#' are optional.";
14  return result;
15  }
std::string fhicl::detail::print_annotated_info ( std::string const &  curr_info,
std::string const &  cached_info 
)

Definition at line 27 of file printing_helpers.cc.

Referenced by fhicl::detail::PrettifierAnnotated::atom(), fhicl::detail::PrettifierAnnotated::enter_sequence(), fhicl::detail::PrettifierAnnotated::enter_table(), and nl().

29 {
30  if (!allowed_info(curr_info))
31  return "";
32  std::string const tag = " # ";
33  std::string const printed_info =
34  curr_info == cached_info ? "\"\"" : curr_info;
35  return tag + printed_info;
36 }
std::string fhicl::detail::print_prefix_annotated_info ( std::string const &  curr_info)

Definition at line 39 of file printing_helpers.cc.

Referenced by fhicl::detail::PrettifierPrefixAnnotated::atom(), fhicl::detail::PrettifierPrefixAnnotated::enter_sequence(), fhicl::detail::PrettifierPrefixAnnotated::enter_table(), and nl().

40 {
41  std::string const printed_info = allowed_info(info) ? info : "";
42  return "#SRC|" + printed_info + "|";
43 }
std::string fhicl::detail::printed_suffix ( std::string const &  key,
std::size_t const  sz 
)

Definition at line 48 of file printing_helpers.cc.

Referenced by fhicl::detail::Prettifier::atom(), fhicl::detail::PrettifierAnnotated::atom(), fhicl::detail::PrettifierPrefixAnnotated::atom(), fhicl::detail::Prettifier::exit_sequence(), fhicl::detail::PrettifierAnnotated::exit_sequence(), fhicl::detail::PrettifierPrefixAnnotated::exit_sequence(), fhicl::detail::Prettifier::exit_table(), fhicl::detail::PrettifierAnnotated::exit_table(), fhicl::detail::PrettifierPrefixAnnotated::exit_table(), and nl().

49 {
50  std::string result;
51 
52  if (sz == size_t_max)
53  return result;
54 
55  std::smatch m;
56  if (std::regex_match(key, m, std::regex{R"(.*\[(\d+)\])"}) &&
57  std::stoul(m[1]) != sz - 1) {
58  result = ",";
59  }
60  return result;
61 }
std::string fhicl::detail::strip_all_containing_names ( std::string const &  key)

Definition at line 14 of file strip_containing_names.cc.

Referenced by fhicl::detail::ParameterMetadata::set_key().

15 {
16  auto const pos = key.find_last_of(".") + 1;
17  return key.substr(pos);
18 }
std::string fhicl::detail::strip_first_containing_name ( std::string const &  key)
void fhicl::detail::throwOnSQLiteFailure ( sqlite3 *  db,
char *  msg = nullptr 
)

Definition at line 32 of file ParameterSetRegistry.cc.

References fhicl::cant_open_db, and fhicl::sql_error.

Referenced by fhicl::ParameterSetRegistry::exportTo(), fhicl::ParameterSetRegistry::find_(), fhicl::ParameterSetRegistry::importFrom(), and fhicl::ParameterSetRegistry::~ParameterSetRegistry().

33 {
34  std::string const msgString{msg ? msg : ""};
35  sqlite3_free(msg);
36  if (db == nullptr) {
37  throw fhicl::exception(fhicl::error::cant_open_db) << "Can't open DB.";
38  }
39  auto errcode = sqlite3_errcode(db);
40  if (errcode != SQLITE_OK) {
41  // Caller's responsibility to make sure this really is an error
42  // and not (say) SQLITE_ROW or SQLITE_DONE,
43  throw exception(error::sql_error, "SQLite error:")
44  << sqlite3_errstr(errcode) << " (" << errcode
45  << "): " << sqlite3_errmsg(db)
46  << (msgString.empty() ? "" : (std::string(". ") + msgString));
47  }
48 }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::string fhicl::detail::translate ( error  code)

Definition at line 12 of file exception.cc.

References fhicl::cant_find, fhicl::cant_happen, fhicl::cant_insert, fhicl::cant_open_db, fhicl::number_is_too_large, fhicl::other, fhicl::parse_error, fhicl::protection_violation, fhicl::sql_error, fhicl::type_mismatch, and fhicl::unimplemented.

13 {
14  switch (code) {
15  case cant_find:
16  return "Can't find key";
17  case cant_happen:
18  return "Can't happen";
19  case cant_insert:
20  return "Can't insert key";
22  return "Excessive value";
23  case parse_error:
24  return "Parse error";
25  case type_mismatch:
26  return "Type mismatch";
28  return "Protection violation";
29  case cant_open_db:
30  return "Can't open DB";
31  case sql_error:
32  return "SQL error";
33  case unimplemented:
34  return "Unimplemented feature";
35  case other:
36  return "Other error";
37  default:
38  return "Unknown code";
39  }
40 }
template<typename L >
void fhicl::detail::try_insert ( l,
std::string const &  key 
)

Definition at line 13 of file try_blocks.h.

References fhicl::cant_insert, and e.

Referenced by fhicl::ParameterSet::put(), fhicl::ParameterSet::put_or_replace(), and fhicl::ParameterSet::put_or_replace_compatible().

13  {
14  l(key);
15  }
16  catch (boost::bad_lexical_cast const& e) {
17  throw fhicl::exception(cant_insert, key) << e.what();
18  }
19  catch (boost::bad_numeric_cast const& e) {
20  throw fhicl::exception(cant_insert, key) << e.what();
21  }
22  catch (fhicl::exception const& e) {
23  throw fhicl::exception(cant_insert, key, e);
24  }
25  catch (std::exception const& e) {
26  throw fhicl::exception(cant_insert, key) << e.what();
27  }
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33