1 #ifndef fhiclcpp_ParameterSet_h 2 #define fhiclcpp_ParameterSet_h 10 #include "boost/any.hpp" 11 #include "boost/lexical_cast.hpp" 12 #include "boost/numeric/conversion/cast.hpp" 13 #include "cetlib_except/demangle.h" 29 #include <unordered_map> 38 using annot_t = std::unordered_map<std::string, std::string>;
56 std::vector<std::string>
get_names()
const;
61 bool has_key(std::string
const& key)
const;
68 template <
class T,
class Via>
71 T convert(Via
const&))
const;
74 T
get(std::string
const& key)
const;
75 template <
class T,
class Via>
76 T
get(std::string
const& key, T convert(Via
const&))
const;
78 T
get(std::string
const& key, T
const& default_value)
const;
79 template <
class T,
class Via>
80 T
get(std::string
const& key,
81 T
const& default_value,
82 T convert(Via
const&))
const;
90 void put(std::string
const& key);
92 void put(std::string
const& key, T
const& value);
100 bool erase(std::string
const& key);
107 using map_t = std::map<std::string, boost::any>;
115 void insert_(std::string
const& key, boost::any
const& value);
118 boost::any
const& value);
120 std::string
to_string_(
bool compact =
false)
const;
121 std::string
stringify_(boost::any
const& a,
bool compact =
false)
const;
124 std::function<
bool(boost::any
const&)> func)
const;
128 bool get_one_(std::string
const& key, T& value)
const;
129 bool find_one_(std::string
const& key)
const;
172 auto insert = [
this, &
value](
auto const& key) {
183 auto insert_or_replace = [
this, &
value](
auto const& key) {
186 srcMapping_.erase(key);
196 auto insert_or_replace_compatible = [
this, &
value](
auto const& key) {
199 srcMapping_.erase(key);
215 template <
class T,
class Via>
219 T convert(Via
const&))
const 225 result = convert(go_between);
238 template <
class T,
class Via>
256 template <
class T,
class Via>
259 T
const& default_value,
260 T convert(Via
const&))
const 263 return get_if_present(key, result, convert) ? result : default_value;
271 return id() == other.
id();
288 if (it == mapping_.end()) {
302 std::ostringstream errmsg;
303 errmsg <<
"\nUnsuccessful attempt to convert FHiCL parameter '" << key
304 <<
"' to type '" << cet::demangle_symbol(
typeid(value).name())
306 <<
"[Specific error:]";
310 std::ostringstream errmsg;
311 errmsg <<
"\nUnsuccessful attempt to convert FHiCL parameter '" << key
312 <<
"' to type '" << cet::demangle_symbol(
typeid(value).name())
314 <<
"[Specific error:]\n" 315 << e.what() <<
"\n\n";
std::string stringify_(boost::any const &a, bool compact=false) const
bool operator!=(ParameterSet const &other) const
bool get_one_(std::string const &key, T &value) const
void decode(boost::any const &, std::string &)
ps_atom_t encode(std::string const &)
void insert_or_replace_compatible_(std::string const &key, boost::any const &value)
Keys get_names(std::string const &key)
std::unordered_map< std::string, std::string > annot_t
bool is_sequence(boost::any const &val)
bool is_table(boost::any const &val)
map_t::const_iterator map_iter_t
bool is_key_to_sequence(std::string const &key) const
std::vector< std::string > get_pset_names() const
void try_insert(L l, std::string const &key)
bool is_key_to_table(std::string const &key) const
std::map< std::string, boost::any > map_t
T get(std::string const &key) const
bool operator==(ParameterSet const &other) const
void put_or_replace_compatible(std::string const &key, T const &value)
void insert_(std::string const &key, boost::any const &value)
std::string to_indented_string() const
void decode(boost::any const &a, InputTag &tag)
fhicl::detail::ps_atom_t ps_atom_t
bool get_if_present(std::string const &key, T &value) const
void walk(ParameterSetWalker &psw) const
void insert_or_replace_(std::string const &key, boost::any const &value)
bool has_key(std::string const &key) const
std::string to_compact_string() const
SequenceKey get_sequence_indices(std::string const &key)
std::vector< std::string > get_all_keys() const
fhicl::detail::ps_sequence_t ps_sequence_t
ParameterSetID id() const
bool key_is_type_(std::string const &key, std::function< bool(boost::any const &)> func) const
std::string value(boost::any const &)
bool descend_(std::vector< std::string > const &names, ParameterSet &ps) const
std::string get_src_info(std::string const &key) const
std::vector< std::string > get_names() const
bool is_key_to_atom(std::string const &key) const
bool erase(std::string const &key)
bool find_one_(std::string const &key) const
void put_or_replace(std::string const &key)
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
std::vector< boost::any > ps_sequence_t
std::string to_string_(bool compact=false) const
bool find_an_any(cit_size_t it, cit_size_t const cend, boost::any &a)
std::string to_string() const