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

parameter set interface More...

Namespaces

 comment_detail
 
 detail
 
 has_insertion_operator_impl
 
 sequence_detail
 
 tuple_detail
 

Classes

struct  ass_parser
 
class  Atom
 
struct  bin_parser
 
struct  binding_parser
 
struct  Comment
 
class  ConfigurationTable
 
struct  dbid_parser
 
class  DelegatedParameter
 
struct  dss_parser
 
class  extended_value
 
struct  has_insertion_operator
 
struct  hex_parser
 
class  intermediate_table
 
struct  KeysToIgnore
 
struct  MaybeUseFunction
 
struct  Name
 
class  NameStackRegistry
 
struct  NoInsert
 
class  OptionalAtom
 
class  OptionalDelegatedParameter
 
class  OptionalSequence
 
class  OptionalSequence< T,-1ull >
 
class  OptionalTable
 
class  OptionalTuple
 
class  OptionalTupleAs
 
class  OptionalTupleAs< T(ARGS...)>
 
class  ParameterSet
 
class  ParameterSetID
 
class  ParameterSetRegistry
 
class  ParameterSetWalker
 
struct  real_parser
 
class  Sequence
 
class  Sequence< T,-1ull >
 
class  Table
 
class  TableFragment
 
class  Tuple
 
class  TupleAs
 
class  TupleAs< T(ARGS...)>
 
struct  uint_parser
 
class  WrappedTable
 
struct  YesInsert
 

Typedefs

using exception = cet::coded_exception< error, detail::translate >
 
template<typename T >
using NullaryConfigPredicate_t = bool(T::*)() const
 

Enumerations

enum  error {
  cant_find, cant_happen, cant_insert, number_is_too_large,
  parse_error, type_mismatch, protection_violation, cant_open_db,
  sql_error, unimplemented, other
}
 
enum  value_tag {
  UNKNOWN, NIL, BOOL, NUMBER,
  COMPLEX, STRING, SEQUENCE, TABLE,
  TABLEID
}
 
enum  Protection : unsigned char { Protection::NONE, Protection::PROTECT_IGNORE, Protection::PROTECT_ERROR }
 
enum  par_type {
  par_type::ATOM, par_type::TABLE, par_type::SEQ_VECTOR, par_type::SEQ_ARRAY,
  par_type::TUPLE, par_type::DELEGATE, par_type::NTYPES
}
 
enum  par_style {
  par_style::REQUIRED, par_style::REQUIRED_CONDITIONAL, par_style::DEFAULT, par_style::DEFAULT_CONDITIONAL,
  par_style::OPTIONAL, par_style::OPTIONAL_CONDITIONAL, par_style::NTYPES
}
 

Functions

void decompose_parameterset (fhicl::ParameterSet const &top, std::vector< std::string > &records, std::vector< std::string > &hashes)
 
void decompose_fhicl (std::string const &filename, std::vector< std::string > &records, std::vector< std::string > &hashes)
 
void parse_file_and_fill_db (std::string const &filename, sqlite3 *db)
 
void make_ParameterSet (intermediate_table const &tbl, ParameterSet &ps)
 
void make_ParameterSet (extended_value const &xval, ParameterSet &ps)
 
void make_ParameterSet (std::string const &str, ParameterSet &ps)
 
void make_ParameterSet (std::string const &filename, cet::filepath_maker &maker, ParameterSet &ps)
 
std::ostream & operator<< (std::ostream &, ParameterSetID const &)
 
bool parse_value_string (std::string const &s, extended_value &v, std::string &unparsed)
 
void parse_document (std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
 
void parse_document (std::istream &is, cet::filepath_maker &maker, intermediate_table &result)
 
void parse_document (std::string const &s, intermediate_table &result)
 
std::string to_string (Protection p)
 
bool maximally_munched (char const ch)
 
bool maximally_munched_number (char const ch)
 
bool maximally_munched_ass (char const ch)
 
bool maximally_munched_dss (char const ch)
 
template<typename T >
std::function< bool()> use_if (T *p, NullaryConfigPredicate_t< T > f)
 
template<typename T >
std::function< bool()> use_unless (T *p, NullaryConfigPredicate_t< T > f)
 
bool is_table (par_type const pt)
 
bool is_sequence (par_type const pt)
 
bool is_atom (par_type const pt)
 
std::string const get_regex_replace_str (std::string const &istr)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, OptionalTable< T > const &t)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, Table< T > const &t)
 

Detailed Description

parameter set interface

Typedef Documentation

using fhicl::exception = typedef cet::coded_exception<error, detail::translate>

Definition at line 33 of file exception.h.

template<typename T >
using fhicl::NullaryConfigPredicate_t = typedef bool (T::*)() const

Definition at line 17 of file ConfigPredicate.h.

Enumeration Type Documentation

Enumerator
cant_find 
cant_happen 
cant_insert 
number_is_too_large 
parse_error 
type_mismatch 
protection_violation 
cant_open_db 
sql_error 
unimplemented 
other 

Definition at line 15 of file exception.h.

enum fhicl::par_style
strong
Enumerator
REQUIRED 
REQUIRED_CONDITIONAL 
DEFAULT 
DEFAULT_CONDITIONAL 
OPTIONAL 
OPTIONAL_CONDITIONAL 
NTYPES 

Definition at line 37 of file ParameterArgumentTypes.h.

enum fhicl::par_type
strong
Enumerator
ATOM 
TABLE 
SEQ_VECTOR 
SEQ_ARRAY 
TUPLE 
DELEGATE 
NTYPES 

Definition at line 8 of file ParameterArgumentTypes.h.

enum fhicl::Protection : unsigned char
strong
Enumerator
UNKNOWN 
NIL 
BOOL 
NUMBER 
COMPLEX 
STRING 
SEQUENCE 
TABLE 
TABLEID 

Definition at line 22 of file extended_value.h.

Function Documentation

void fhicl::decompose_fhicl ( std::string const &  filename,
std::vector< std::string > &  records,
std::vector< std::string > &  hashes 
)

Definition at line 5 of file DatabaseSupport.cc.

References decompose_parameterset(), and make_ParameterSet().

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 }
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
void decompose_parameterset(fhicl::ParameterSet const &top, std::vector< std::string > &records, std::vector< std::string > &hashes)
void fhicl::decompose_parameterset ( fhicl::ParameterSet const &  top,
std::vector< std::string > &  records,
std::vector< std::string > &  hashes 
)

Definition at line 17 of file DatabaseSupport.cc.

References fhicl::ParameterSet::get(), fhicl::ParameterSet::get_names(), fhicl::ParameterSet::id(), fhicl::ParameterSet::is_key_to_sequence(), fhicl::ParameterSet::is_key_to_table(), fhicl::ParameterSet::to_compact_string(), and fhicl::ParameterSetID::to_string().

Referenced by decompose_fhicl().

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 }
void decompose_parameterset(fhicl::ParameterSet const &top, std::vector< std::string > &records, std::vector< std::string > &hashes)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::string const fhicl::get_regex_replace_str ( std::string const &  istr)

Definition at line 8 of file Name.cc.

Referenced by fhicl::Name::regex_safe().

9  {
10  static std::regex const r("\\[|\\]");
11  auto ostr = std::regex_replace(istr, r, "\\$&");
12  return ostr;
13  }
bool fhicl::is_atom ( par_type const  pt)
inline

Definition at line 32 of file ParameterArgumentTypes.h.

References ATOM.

Referenced by evgen::MARLEYHelper::fhicl_parameter_to_json(), and fhicl::detail::ParameterWalker< C >::walk_over().

33  {
34  return pt == par_type::ATOM;
35  }
TMarker * pt
Definition: egs.C:25
bool fhicl::is_sequence ( par_type const  pt)
inline

Definition at line 25 of file ParameterArgumentTypes.h.

References SEQ_ARRAY, SEQ_VECTOR, and TUPLE.

Referenced by evgen::MARLEYHelper::fhicl_parameter_to_json().

26  {
27  return pt == par_type::SEQ_VECTOR || pt == par_type::SEQ_ARRAY ||
28  pt == par_type::TUPLE;
29  }
TMarker * pt
Definition: egs.C:25
bool fhicl::is_table ( par_type const  pt)
inline

Definition at line 19 of file ParameterArgumentTypes.h.

References TABLE.

Referenced by evgen::MARLEYHelper::fhicl_parameter_to_json().

20  {
21  return pt == par_type::TABLE;
22  }
TMarker * pt
Definition: egs.C:25
void fhicl::make_ParameterSet ( extended_value const &  xval,
ParameterSet ps 
)

Definition at line 42 of file make_ParameterSet.cc.

References fhicl::extended_value::is_a(), fhicl::ParameterSet::put(), TABLE, and type_mismatch.

43 {
44  if (!xval.is_a(TABLE))
45  throw fhicl::exception(type_mismatch, "extended value not a table");
46 
47  table_t const& tbl = table_t(xval);
48  for (auto const& pr : tbl) {
49  if (!pr.second.in_prolog)
50  ps.put(pr.first, pr.second);
51  }
52 }
intermediate_table::table_t table_t
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void fhicl::make_ParameterSet ( std::string const &  str,
ParameterSet ps 
)

Definition at line 57 of file make_ParameterSet.cc.

References make_ParameterSet(), and parse_document().

58 {
60  parse_document(str, tbl);
61  make_ParameterSet(tbl, ps);
62 }
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
Definition: parse.cc:856
void fhicl::make_ParameterSet ( std::string const &  filename,
cet::filepath_maker &  maker,
ParameterSet ps 
)

Definition at line 67 of file make_ParameterSet.cc.

References make_ParameterSet(), and parse_document().

70 {
72  parse_document(filename, maker, tbl);
73  make_ParameterSet(tbl, ps);
74 }
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
Definition: parse.cc:856
bool fhicl::maximally_munched ( char const  ch)
inline

Definition at line 28 of file tokens.h.

Referenced by maximally_munched_ass(), maximally_munched_dss(), and maximally_munched_number().

29  {
30  return !std::isgraph(ch) || ch == '#' || ch == '/' || ch == ',' ||
31  ch == ']' || ch == '}';
32  }
bool fhicl::maximally_munched_ass ( char const  ch)
inline

Definition at line 41 of file tokens.h.

References maximally_munched().

Referenced by fhicl::ass_parser::parse().

42  {
43  return maximally_munched(ch) || ch == '.' || ch == '[' || ch == ':';
44  }
bool maximally_munched(char const ch)
Definition: tokens.h:28
bool fhicl::maximally_munched_dss ( char const  ch)
inline

Definition at line 47 of file tokens.h.

References bin, and maximally_munched().

Referenced by fhicl::dss_parser::parse().

48  {
49  return maximally_munched(ch);
50  }
bool maximally_munched(char const ch)
Definition: tokens.h:28
bool fhicl::maximally_munched_number ( char const  ch)
inline

Definition at line 35 of file tokens.h.

References maximally_munched().

Referenced by fhicl::real_parser::parse(), fhicl::uint_parser::parse(), fhicl::hex_parser::parse(), fhicl::dbid_parser::parse(), and fhicl::bin_parser::parse().

36  {
37  return maximally_munched(ch) || ch == ')';
38  }
bool maximally_munched(char const ch)
Definition: tokens.h:28
ostream & fhicl::operator<< ( std::ostream &  os,
ParameterSetID const &  psid 
)

Definition at line 142 of file ParameterSetID.cc.

References fhicl::ParameterSetID::to_string().

143 {
144  return os << psid.to_string();
145 }
template<typename T >
std::ostream& fhicl::operator<< ( std::ostream &  os,
OptionalTable< T > const &  t 
)
inline

Definition at line 100 of file OptionalTable.h.

101  {
102  std::ostringstream config;
103  t.print_allowed_configuration(config);
104  return os << config.str();
105  }
template<typename T >
std::ostream& fhicl::operator<< ( std::ostream &  os,
Table< T > const &  t 
)
inline

Definition at line 110 of file Table.h.

111  {
112  std::ostringstream config;
113  t.print_allowed_configuration(config);
114  return os << config.str();
115  }
void fhicl::parse_document ( std::string const &  filename,
cet::filepath_maker &  maker,
intermediate_table result 
)

Definition at line 856 of file parse.cc.

Referenced by art::BasicOptionsHandler::doProcessOptions(), main(), make_ParameterSet(), parse_document(), testing::BasicTesterEnvironment< ConfigurationClass >::ParseParameters(), and art::run_art_string_config().

859 {
860  parse_document_(cet::includer(filename, maker), result);
861 } // parse_document()
void fhicl::parse_document ( std::istream &  is,
cet::filepath_maker &  maker,
intermediate_table result 
)

Definition at line 864 of file parse.cc.

867 {
868  parse_document_(cet::includer(is, maker), result);
869 } // parse_document()
void fhicl::parse_document ( std::string const &  s,
intermediate_table result 
)
inline

Definition at line 32 of file parse.h.

References parse_document().

33  {
34  std::istringstream is{s};
35  cet::filepath_maker m;
36  parse_document(is, m, result);
37  }
Float_t s
Definition: plot.C:23
void parse_document(std::string const &s, intermediate_table &result)
Definition: parse.h:32
void fhicl::parse_file_and_fill_db ( std::string const &  filename,
sqlite3 *  db 
)

Definition at line 48 of file DatabaseSupport.cc.

References fhicl::ParameterSetRegistry::exportTo(), make_ParameterSet(), and fhicl::ParameterSetRegistry::put().

Referenced by main().

49 {
51  cet::filepath_maker fpm;
52  make_ParameterSet(filename, fpm, top);
55 }
static ParameterSetID const & put(ParameterSet const &ps)
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
static void exportTo(sqlite3 *db)
bool fhicl::parse_value_string ( std::string const &  s,
extended_value v,
std::string &  unparsed 
)

Definition at line 802 of file parse.cc.

References evd::details::begin(), e, evd::details::end(), shims::lit(), parse_error, and s.

Referenced by fhicl::detail::decode(), and fhicl::detail::encode().

805 {
806  typedef std::string::const_iterator iter_t;
807  typedef qi::rule<iter_t> ws_t;
808  ws_t whitespace = space | lit('#') >> *(char_ - eol) >> eol |
809  lit("//") >> *(char_ - eol) >> eol;
810  value_parser<iter_t, ws_t> p;
811  iter_t begin = s.begin();
812  iter_t const end = s.end();
813  bool const b =
814  qi::phrase_parse(begin, end, p >> *whitespace, whitespace, result) &&
815  begin == end;
816  unparsed = std::string(begin, end);
817  return b;
818 } // parse_value_string()
Float_t s
Definition: plot.C:23
auto lit(char arg)
Definition: parse_shims.h:11
intermediate_table::const_iterator const_iterator
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::string fhicl::to_string ( Protection  p)

Definition at line 4 of file Protection.cc.

Referenced by fhicl::detail::HashParameterSetID::operator()().

5 {
6  std::string result;
7  switch (p) {
8  case Protection::NONE:
9  result = "NONE";
10  break;
11  case Protection::PROTECT_IGNORE:
12  result = "PROTECT_IGNORE";
13  break;
14  case Protection::PROTECT_ERROR:
15  result = "PROTECT_ERROR";
16  break;
17  }
18  return result;
19 }
template<typename T >
std::function<bool()> fhicl::use_if ( T *  p,
NullaryConfigPredicate_t< T >  f 
)

Definition at line 21 of file ConfigPredicate.h.

References f.

22  {
23  return [p, f]() { return (p->*f)(); };
24  }
TFile f
Definition: plotHisto.C:6
template<typename T >
std::function<bool()> fhicl::use_unless ( T *  p,
NullaryConfigPredicate_t< T >  f 
)

Definition at line 28 of file ConfigPredicate.h.

References f.

29  {
30  return [p, f]() { return !(p->*f)(); };
31  }
TFile f
Definition: plotHisto.C:6