Namespaces | Classes | Typedefs | Enumerations | Functions
fhicl::detail Namespace Reference

Namespaces

 atom
 
 no_defaults
 
 sequence
 
 table
 
 yes_defaults
 

Classes

struct  AllowedConfiguration
 
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_v< std::complex< U > >|| std::is_pointer_v< std::complex< U > > >::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  it_value_get< T, typename tt::disable_if< std::is_reference_v< T >|| std::is_pointer_v< T > >::type >
 
class  KeyAssembler
 
class  Keys
 
class  MaybeDisplayParent
 
class  ParameterBase
 
class  ParameterMetadata
 
class  ParameterWalker
 
struct  per_entry
 
struct  per_entry< 0, TUPLE >
 
class  per_thread_holder
 
class  Prettifier
 
class  PrettifierAnnotated
 
class  PrettifierPrefixAnnotated
 
class  PrintAllowedConfiguration
 
class  RegisterIfTableMember
 
class  SearchAllowedConfiguration
 
class  SequenceBase
 
class  SequenceKey
 
class  TableBase
 
class  TableMemberRegistry
 
struct  thread_hash_compare
 
class  ValidateThenSet
 
class  validationException
 
class  ValuePrinter
 
struct  void_t< decltype(typename T::Parameters{ std::declval< fhicl::Name >()})>
 

Typedefs

using ps_atom_t = std::string
 
using ps_sequence_t = std::vector< std::any >
 
using ldbl = long double
 
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 (std::any const &val)
 
bool is_table (std::any const &val)
 
bool is_nil (std::any const &val)
 
ps_atom_t encode (std::string const &)
 
ps_atom_t encode (char const *)
 
ps_atom_t encode (std::nullptr_t)
 
ps_atom_t encode (bool)
 
ParameterSetID encode (ParameterSet const &)
 
ps_atom_t encode (std::uintmax_t)
 
template<class T >
std::enable_if_t< tt::is_uint< T >::value, ps_atom_tencode (T const &)
 
ps_atom_t encode (std::intmax_t)
 
template<class T >
std::enable_if_t< tt::is_int< T >::value, ps_atom_tencode (T const &)
 
ps_atom_t encode (ldbl)
 
template<class T >
std::enable_if_t< std::is_floating_point_v< T >, ps_atom_tencode (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_t< tt::is_numeric< T >::value, std::stringencode (T const &)
 
void decode (std::any const &, std::string &)
 
void decode (std::any const &, std::nullptr_t &)
 
void decode (std::any const &, bool &)
 
void decode (std::any const &, ParameterSet &)
 
void decode (std::any const &, std::uintmax_t &)
 
template<class T >
std::enable_if_t< tt::is_uint< T >::value > decode (std::any const &, T &)
 
void decode (std::any const &, std::intmax_t &)
 
template<class T >
std::enable_if_t< tt::is_int< T >::value > decode (std::any const &, T &)
 
void decode (std::any const &, ldbl &)
 
template<class T >
std::enable_if_t< std::is_floating_point_v< T > > decode (std::any const &, T &)
 
void decode (std::any const &, std::complex< ldbl > &)
 
template<class T >
void decode (std::any const &, std::complex< T > &)
 
template<class T >
void decode (std::any const &, std::vector< T > &)
 
template<typename U >
void decode_tuple (std::any const &, U &tuple)
 
template<typename T , std::size_t SIZE>
void decode (std::any const &a, std::array< T, SIZE > &result)
 
template<typename KEY , typename VALUE >
void decode (std::any const &a, std::pair< KEY, VALUE > &result)
 
template<typename... ARGS>
void decode (std::any const &a, std::tuple< ARGS... > &result)
 
template<class T >
tt::disable_if_t< tt::is_numeric< T >::value > decode (std::any const &, T &)
 
std::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, std::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)
 
std::size_t index_for_sequence_element (std::string const &name)
 
template<typename L >
void try_insert (L l, std::string const &key)
 
std::string translate (error)
 
void throwOnSQLiteFailure (int rc, char *msg=nullptr)
 
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::stringensure_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)
 
int fhicl_get_impl (int argc, char **argv)
 
template<typename T >
std::string name_of ()
 
template<>
std::string name_of< std::string > ()
 

Typedef Documentation

Definition at line 16 of file MaybeDisplayParent.h.

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

Definition at line 70 of file ParameterSetImplHelpers.h.

Definition at line 69 of file KeyAssembler.h.

using fhicl::detail::ldbl = typedef long double

Definition at line 46 of file coding.h.

Definition at line 70 of file KeyAssembler.h.

Definition at line 44 of file coding.h.

using fhicl::detail::ps_sequence_t = typedef std::vector<std::any>

Definition at line 45 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  };
#define INITIAL
Definition: code.cpp:12348
Enumerator
raw 
annotated 
prefix_annotated 

Definition at line 5 of file print_mode.h.

Function Documentation

std::function<bool()> fhicl::detail::AlwaysUse ( )
inline

Definition at line 10 of file ConfigPredicate.h.

11  {
12  return []() { return true; };
13  }
void fhicl::detail::check_nargs_for_bounded_sequences ( std::string const &  key,
std::size_t  expected,
std::size_t  provided 
)

Definition at line 9 of file check_nargs_for_bounded_sequences.cc.

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

Definition at line 22 of file KeysToIgnore.h.

23  {
24  return keys;
25  }
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 29 of file KeysToIgnore.h.

30  {
31  keys.insert(begin(h), end(h));
32  return concatenate_keys(keys, t...);
33  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::set< std::string > & concatenate_keys(std::set< std::string > &keys, H const &h, T const &...t)
Definition: KeysToIgnore.h:29
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
void fhicl::detail::decode ( std::any const &  ,
std::string  
)
void fhicl::detail::decode ( std::any const &  ,
std::nullptr_t &   
)
void fhicl::detail::decode ( std::any const &  ,
bool  
)
void fhicl::detail::decode ( std::any const &  ,
ParameterSet  
)
void fhicl::detail::decode ( std::any const &  ,
std::uintmax_t &   
)
template<class T >
std::enable_if_t< tt::is_uint< T >::value > fhicl::detail::decode ( std::any const &  a,
T &  result 
)

Definition at line 211 of file coding.h.

212 {
213  std::uintmax_t via;
214  decode(a, via);
215  result = boost::numeric_cast<T>(via);
216 }
static QCString result
tt::disable_if_t< tt::is_numeric< T >::value > decode(std::any const &, T &)
Definition: coding.h:353
const double a
void fhicl::detail::decode ( std::any const &  ,
std::intmax_t &   
)
template<class T >
std::enable_if_t< tt::is_int< T >::value > fhicl::detail::decode ( std::any const &  a,
T &  result 
)

Definition at line 222 of file coding.h.

223 {
224  std::intmax_t via;
225  decode(a, via);
226  result = boost::numeric_cast<T>(via);
227 }
static QCString result
tt::disable_if_t< tt::is_numeric< T >::value > decode(std::any const &, T &)
Definition: coding.h:353
const double a
void fhicl::detail::decode ( std::any const &  ,
ldbl  
)
template<class T >
std::enable_if_t< std::is_floating_point_v< T > > fhicl::detail::decode ( std::any const &  a,
T &  result 
)

Definition at line 233 of file coding.h.

234 {
235  ldbl via;
236  decode(a, via);
237  result = via; // boost::numeric_cast<T>(via);
238 }
static QCString result
long double ldbl
Definition: ParameterSet.cc:33
tt::disable_if_t< tt::is_numeric< T >::value > decode(std::any const &, T &)
Definition: coding.h:353
const double a
void fhicl::detail::decode ( std::any const &  ,
std::complex< ldbl > &   
)
template<class T >
void fhicl::detail::decode ( std::any const &  a,
std::complex< T > &  result 
)

Definition at line 244 of file coding.h.

245 {
246  std::complex<ldbl> via;
247  decode(a, via);
248  result = std::complex<T>{boost::numeric_cast<T>(via.real()),
249  boost::numeric_cast<T>(via.imag())};
250 }
static QCString result
tt::disable_if_t< tt::is_numeric< T >::value > decode(std::any const &, T &)
Definition: coding.h:353
const double a
template<class T >
void fhicl::detail::decode ( std::any const &  a,
std::vector< T > &  result 
)

Definition at line 256 of file coding.h.

257 {
258  if (a.type() == typeid(std::string)) {
259  typedef fhicl::extended_value extended_value;
261 
263  decode(a, str);
264 
265  extended_value xval;
267  if (!parse_value_string(str, xval, unparsed) || !xval.is_a(SEQUENCE))
268  throw fhicl::exception(type_mismatch, "error in sequence string:\n")
269  << str << "\nat or before:\n"
270  << unparsed;
271 
272  sequence_t const& seq = sequence_t(xval);
273  result.clear();
274  T via;
275  for (auto const& e : seq) {
276  decode(e.to_string(), via);
277  result.push_back(via);
278  }
279  }
280 
281  else if (a.type() == typeid(ps_sequence_t)) {
282  ps_sequence_t const& seq = std::any_cast<ps_sequence_t>(a);
283  result.clear();
284  T via;
285  for (auto const& e : seq) {
286  decode(e, via);
287  result.push_back(via);
288  }
289  }
290 
291  else
292  throw fhicl::exception(type_mismatch, "invalid sequence");
293 }
bool parse_value_string(std::string const &s, extended_value &v, std::string &unparsed)
Definition: parse.cc:669
std::string string
Definition: nybbler.cc:12
tt::disable_if_t< tt::is_numeric< T >::value > decode(std::any const &, T &)
Definition: coding.h:353
std::vector< std::any > ps_sequence_t
Definition: coding.h:45
const double e
const double a
fhicl::extended_value::sequence_t sequence_t
ParameterSet::ps_sequence_t ps_sequence_t
static QCString str
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T , std::size_t SIZE>
void fhicl::detail::decode ( std::any const &  a,
std::array< T, SIZE > &  result 
)

Definition at line 124 of file coding.h.

125  {
126  decode_tuple(a, result);
127  }
void decode_tuple(std::any const &, U &tuple)
Definition: coding.h:324
const double a
template<typename KEY , typename VALUE >
void fhicl::detail::decode ( std::any const &  a,
std::pair< KEY, VALUE > &  result 
)

Definition at line 130 of file coding.h.

131  {
133  }
static QCString result
void decode_tuple(std::any const &, U &tuple)
Definition: coding.h:324
const double a
template<typename... ARGS>
void fhicl::detail::decode ( std::any const &  a,
std::tuple< ARGS... > &  result 
)

Definition at line 136 of file coding.h.

137  {
139  }
static QCString result
void decode_tuple(std::any const &, U &tuple)
Definition: coding.h:324
const double a
template<class T >
tt::disable_if_t< tt::is_numeric< T >::value > fhicl::detail::decode ( std::any const &  a,
T &  result 
)

Definition at line 353 of file coding.h.

354 {
355  result = std::any_cast<T>(a);
356 }
static QCString result
const double a
template<typename U >
void fhicl::detail::decode_tuple ( std::any const &  a,
U &  tuple 
)

Definition at line 324 of file coding.h.

325 {
326  auto const seq = std::any_cast<ps_sequence_t>(a);
327 
328  constexpr std::size_t TUPLE_SIZE = std::tuple_size_v<U>;
329 
330  if (seq.size() != TUPLE_SIZE) {
331  std::ostringstream errmsg;
332  errmsg << "Number of expected arguments (" << TUPLE_SIZE
333  << ") does not match "
334  << "number of FHiCL sequence entries (" << seq.size() << "): [ ";
335  for (auto ca = seq.begin(); ca != seq.cend(); ++ca) {
337  decode(*ca, tmp);
338  errmsg << tmp;
339  if (ca != seq.cend() - 1) {
340  errmsg << ", ";
341  }
342  }
343  errmsg << " ]";
344  throw std::length_error(errmsg.str());
345  }
346 
347  per_entry<TUPLE_SIZE - 1, U>::decode_tuple_entry(seq, result);
348 }
static QCString result
std::string string
Definition: nybbler.cc:12
tt::disable_if_t< tt::is_numeric< T >::value > decode(std::any const &, T &)
Definition: coding.h:353
const double a
string tmp
Definition: languages.py:63
ParameterSet::ps_sequence_t ps_sequence_t
std::any fhicl::detail::encode ( extended_value const &  xval)

Definition at line 24 of file encode_extended_value.cc.

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  complex_t const& cmplx = complex_t(xval);
35  return '(' + cmplx.first + ',' + cmplx.second + ')';
36  }
37 
38  case SEQUENCE: {
40  sequence_t const& seq = sequence_t(xval);
41  for (sequence_t::const_iterator it = seq.begin(), e = seq.end(); it != e;
42  ++it)
43  result.push_back(std::any(encode(*it)));
44  return result;
45  }
46 
47  case TABLE: {
49  table_t const& tbl = table_t(xval);
51  for (const_iterator it = tbl.begin(), e = tbl.end(); it != e; ++it) {
52  if (!it->second.in_prolog)
53  result.put(it->first, it->second);
54  }
55  return ParameterSetRegistry::put(result);
56  }
57 
58  case TABLEID: {
59  atom_t const& tableID = atom_t(xval);
60  return ParameterSetID(tableID);
61  }
62 
63  case UNKNOWN:
64  default: {
65  throw fhicl::exception(type_mismatch, "unknown extended value");
66  }
67  }
68 } // encode()
intermediate_table::complex_t complex_t
iterator begin()
Definition: stdmap_shims.h:150
static QCString result
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
intermediate_table::const_iterator const_iterator
intermediate_table::table_t table_t
intermediate_table::sequence_t sequence_t
iterator end()
Definition: stdmap_shims.h:171
const double e
fhicl::extended_value::sequence_t sequence_t
intermediate_table::atom_t atom_t
ParameterSet::ps_sequence_t ps_sequence_t
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.

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;
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:669
bool is_a(value_tag const t) const noexcept
std::string string
Definition: nybbler.cc:12
intermediate_table::atom_t atom_t
static QCString str
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.

106 {
107  return encode(std::string(value));
108 }
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
std::string string
Definition: nybbler.cc:12
ps_atom_t fhicl::detail::encode ( std::nullptr_t  )

Definition at line 111 of file coding.cc.

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.

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
ParameterSetID fhicl::detail::encode ( ParameterSet const &  value)

Definition at line 123 of file coding.cc.

124 {
125  return ParameterSetRegistry::put(value);
126 }
ps_atom_t fhicl::detail::encode ( std::uintmax_t  value)

Definition at line 129 of file coding.cc.

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 }
static QCString result
std::string string
Definition: nybbler.cc:12
template<class T >
std::enable_if_t<tt::is_uint<T>::value, ps_atom_t> fhicl::detail::encode ( T const &  )
ps_atom_t fhicl::detail::encode ( std::intmax_t  value)

Definition at line 141 of file coding.cc.

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

Definition at line 150 of file coding.cc.

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 
162  cet::canonical_number(lexical_cast<std::string>(value), result);
163  return result;
164 }
bool canonical_number(std::string const &value, std::string &result)
static QCString result
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
std::string string
Definition: nybbler.cc:12
static ps_atom_t literal_infinity()
Definition: coding.cc:51
template<class T >
std::enable_if_t<std::is_floating_point_v<T>, ps_atom_t> 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_t< tt::is_numeric< T >::value, std::string > fhicl::detail::encode ( T const &  value)

Definition at line 200 of file coding.h.

201 {
202  return boost::lexical_cast<std::string>(value);
203 }
std::string string
Definition: nybbler.cc:12
template<typename T >
std::set<std::string> fhicl::detail::ensure_callable ( )

Definition at line 15 of file KeysToIgnore.h.

16  {
17  static_assert(tt::is_callable<T>::value);
18  return T{}();
19  }
int fhicl::detail::fhicl_get_impl ( int  argc,
char **  argv 
)

Definition at line 231 of file fhicl_get_impl.cc.

231  {
232  supported_types_t const printer_for_types{};
233  auto const maybe_opts = process_arguments(argc, argv, printer_for_types);
234 
235  if (std::holds_alternative<Help>(maybe_opts)) {
236  std::cout << std::get<Help>(maybe_opts).msg;
237  return 0;
238  }
239 
240  auto const& opts = std::get<Options>(maybe_opts);
241 
242  auto const pset =
243  fhicl::ParameterSet::make(opts.input_filename, *opts.policy);
244 
245  auto const& key = opts.parameter_key;
246 
247  if (opts.names_in) {
248  print_table_names(pset, key, opts.allow_missing);
249  return 0;
250  }
251 
252  if (not pset.has_key(key)) {
253  throw cet::exception{config} << "A parameter with the fully-qualified key '"
254  << key << "' does not exist.";
255  }
256 
257  if (not empty(opts.atom_as)) {
258  printer_for_types.value_for_atom(pset, opts.atom_as, key);
259  return 0;
260  }
261 
262  if (not empty(opts.sequence_of)) {
263  printer_for_types.value_for_sequence(pset, opts.sequence_of, key);
264  return 0;
265  }
266 
267  return 0;
268 }
269 catch (std::exception const& e) {
270  std::cerr << e.what();
271  return 1;
272 }
void msg(const char *fmt,...)
Definition: message.cpp:107
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
const double e
def key(type, name=None)
Definition: graph.py:13
static Config * config
Definition: config.cpp:1054
opts
Definition: ECLAPI.py:241
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
bool fhicl::detail::find_an_any ( cit_size_t  it,
cit_size_t const  cend,
std::any &  a 
)
inline

Definition at line 73 of file ParameterSetImplHelpers.h.

74  {
75  if (it == cend) {
76  // If we got this far, that means the element must exist,
77  // otherwise the previous recursive 'find_parameter' call would
78  // have returned false.
79  return true;
80  }
81 
82  auto seq = std::any_cast<ps_sequence_t>(a);
83  if (*it >= seq.size())
84  return false;
85 
86  a = std::move(seq[*it]);
87 
88  return find_an_any(++it, cend, a);
89  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
bool find_an_any(cit_size_t it, cit_size_t const cend, std::any &a)
const double a
def move(depos, offset)
Definition: depos.py:107
ParameterSet::ps_sequence_t ps_sequence_t
Keys fhicl::detail::get_names ( std::string const &  key)

Definition at line 17 of file ParameterSetImplHelpers.cc.

18  {
19  std::vector<std::string> keys;
20  boost::algorithm::split(keys, key, boost::algorithm::is_any_of("."));
21 
22  // Remove empty keys
23  keys.erase(std::remove(keys.begin(), keys.end(), ""), keys.end());
24 
25  if (keys.empty())
26  throw fhicl::exception(fhicl::cant_find, "vacuous key");
27 
28  std::string const last = keys.back();
29  keys.pop_back();
30 
31  return Keys{keys, last};
32  }
std::string string
Definition: nybbler.cc:12
def key(type, name=None)
Definition: graph.py:13
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
SequenceKey fhicl::detail::get_sequence_indices ( std::string const &  key)

Definition at line 35 of file ParameterSetImplHelpers.cc.

36  {
37  // Split "name[0][5][1]" according to delimiters "][", "[", and "]"
38  // to give {"name","0","5","1"};
39  auto tokens = cet::split_by_regex(key, reBrackets);
40 
41  auto const name = tokens.front();
42  tokens.erase(tokens.begin());
43 
44  std::vector<std::size_t> indices;
46  tokens, std::back_inserter(indices), [](std::string const& index) {
47  return std::stoul(index);
48  });
49  return SequenceKey{name, indices};
50  }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
std::vector< std::string > split_by_regex(std::string const &str, std::regex const &reDelimSet)
def key(type, name=None)
Definition: graph.py:13
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
auto transform_all(Container &, OutputIt, UnaryOp)
std::size_t fhicl::detail::index_for_sequence_element ( std::string const &  name)

Definition at line 110 of file printing_helpers.cc.

111 {
112  if (!is_sequence_element(name)) {
113  throw exception{error::other,
114  "An error occurred while converting a name to a sequence "
115  "element index.\n"}
116  << "The name '" << name << "' does not correspond to a sequence element.";
117  }
118  auto const b = name.find_last_of("[");
119  assert(b != std::string::npos);
120  auto const e = name.find_last_of("]");
121  assert(e == name.length() - 1);
122  auto const start = b + 1;
123  assert(start < e);
124  return std::stoull(name.substr(start, e - start));
125 }
static QCString name
Definition: declinfo.cpp:673
bool is_sequence_element(std::string const &key)
uint length() const
Definition: qcstring.h:195
const double e
static bool * b
Definition: config.cpp:1043
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool fhicl::detail::is_nil ( std::any const &  val)

Definition at line 75 of file coding.cc.

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

Definition at line 49 of file coding.h.

50  {
51  return val.type() == typeid(ps_sequence_t);
52  }
std::vector< std::any > ps_sequence_t
Definition: coding.h:45
bool fhicl::detail::is_sequence_element ( std::string const &  key)
inline

Definition at line 64 of file printing_helpers.h.

65  {
66  auto pos = key.find_last_of(sequence::closing_brace());
67  return pos != std::string::npos && pos == key.size() - 1;
68  }
def key(type, name=None)
Definition: graph.py:13
bool fhicl::detail::is_table ( std::any const &  val)
inline

Definition at line 55 of file coding.h.

56  {
57  return val.type() == typeid(ParameterSetID);
58  }
bool fhicl::detail::is_table_member ( std::string const &  key)
inline

Definition at line 71 of file printing_helpers.h.

72  {
73  auto pos1 = key.find_last_of(".");
74  if (pos1 == std::string::npos)
75  return false;
76 
77  return not is_sequence_element(key);
78  }
bool is_sequence_element(std::string const &key)
def key(type, name=None)
Definition: graph.py:13
template<typename T >
std::string fhicl::detail::name_of ( )

Definition at line 61 of file Printer.h.

62  {
63  return cet::demangle_symbol(typeid(T).name());
64  }
static QCString name
Definition: declinfo.cpp:673

Definition at line 68 of file Printer.h.

69  {
70  return "string";
71  }
std::string fhicl::detail::nl ( std::size_t  i = 1)
inline

Definition at line 18 of file printing_helpers.h.

19  {
20  return std::string(i, '\n');
21  }
std::string string
Definition: nybbler.cc:12
std::string fhicl::detail::optional_parameter_message ( bool const  with_comment = true)
inline

Definition at line 6 of file optional_parameter_message.h.

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

Definition at line 29 of file printing_helpers.cc.

31 {
32  if (!allowed_info(curr_info))
33  return "";
34  std::string const tag = " # ";
35  std::string const printed_info =
36  curr_info == cached_info ? "\"\"" : curr_info;
37  return tag + printed_info;
38 }
std::string string
Definition: nybbler.cc:12
std::string fhicl::detail::print_prefix_annotated_info ( std::string const &  curr_info)

Definition at line 41 of file printing_helpers.cc.

42 {
43  std::string const printed_info = allowed_info(info) ? info : "";
44  return "#SRC|" + printed_info + "|";
45 }
std::string string
Definition: nybbler.cc:12
std::string fhicl::detail::printed_suffix ( std::string const &  key,
std::size_t const  sz 
)

Definition at line 50 of file printing_helpers.cc.

51 {
53 
54  if (sz == size_t_max)
55  return result;
56 
57  std::smatch m;
58  if (std::regex_match(key, m, reSequenceElement) &&
59  std::stoul(m[1]) != sz - 1) {
60  result = ",";
61  }
62  return result;
63 }
static QCString result
std::string string
Definition: nybbler.cc:12
def key(type, name=None)
Definition: graph.py:13
std::string fhicl::detail::strip_all_containing_names ( std::string const &  key)

Definition at line 14 of file strip_containing_names.cc.

15 {
16  auto const pos = key.find_last_of(".") + 1;
17  return key.substr(pos);
18 }
def key(type, name=None)
Definition: graph.py:13
std::string fhicl::detail::strip_first_containing_name ( std::string const &  key)

Definition at line 7 of file strip_containing_names.cc.

8 {
9  auto const pos = key.find_first_of(".") + 1;
10  return key.substr(pos);
11 }
def key(type, name=None)
Definition: graph.py:13
void fhicl::detail::throwOnSQLiteFailure ( int  rc,
char *  msg = nullptr 
)

Definition at line 41 of file ParameterSetRegistry.cc.

42 {
43  std::string const msgString{msg ? msg : ""};
44  sqlite3_free(msg);
45  if (errcode != SQLITE_OK) {
46  // Caller's responsibility to make sure this really is an error
47  // and not (say) SQLITE_ROW or SQLITE_DONE,
48  throw exception(error::sql_error, "SQLite error:")
49  << sqlite3_errstr(errcode) << " (" << errcode << ')'
50  << (msgString.empty() ? "" : (std::string(": ") + msgString));
51  }
52 }
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void fhicl::detail::throwOnSQLiteFailure ( sqlite3 db,
char *  msg = nullptr 
)

Definition at line 55 of file ParameterSetRegistry.cc.

56 {
57  if (db == nullptr) {
58  sqlite3_free(msg);
59  throw fhicl::exception(fhicl::error::cant_open_db) << "Can't open DB.";
60  }
61  auto const errcode = sqlite3_errcode(db);
62  throwOnSQLiteFailure(errcode, msg);
63 }
void msg(const char *fmt,...)
Definition: message.cpp:107
void throwOnSQLiteFailure(int rc, char *msg=nullptr)
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.

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 }
CodeOutputInterface * code
template<typename L >
void fhicl::detail::try_insert ( l,
std::string const &  key 
)

Definition at line 11 of file try_blocks.h.

11  {
12  l(key);
13  }
14  catch (boost::bad_lexical_cast const& e) {
15  throw fhicl::exception{cant_insert, key} << e.what();
16  }
17  catch (boost::bad_numeric_cast const& e) {
18  throw fhicl::exception{cant_insert, key} << e.what();
19  }
20  catch (fhicl::exception const& e) {
21  throw fhicl::exception{cant_insert, key, e};
22  }
23  catch (std::exception const& e) {
24  throw fhicl::exception{cant_insert, key} << e.what();
25  }
static QStrList * l
Definition: config.cpp:1044
const double e
def key(type, name=None)
Definition: graph.py:13
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33