1 #include "fhiclcpp/detail/printing_helpers.h"
2 #include "fhiclcpp/types/detail/strip_containing_names.h"
7 OptionalAtom<T>::OptionalAtom(Name&& name)
8 : OptionalAtom<T>::OptionalAtom(std::move(name), Comment(""))
12 OptionalAtom<T>::OptionalAtom(Name&& name,
14 : AtomBase{std::move(name), std::move(comment), par_style::OPTIONAL, detail::AlwaysUse()}
15 , RegisterIfTableMember{this}
17 NameStackRegistry::end_of_ctor();
21 OptionalAtom<T>::OptionalAtom(Name&& name,
23 std::function<bool()> maybeUse)
24 : AtomBase{std::move(name), std::move(comment), par_style::OPTIONAL_CONDITIONAL, maybeUse}
25 , RegisterIfTableMember{this}
27 NameStackRegistry::end_of_ctor();
32 OptionalAtom<T>::get_stringified_value() const
34 std::stringstream oss;
36 using namespace detail::yes_defaults;
37 oss << maybe_quotes<T>(value_) ;
40 using namespace detail::no_defaults;
41 oss << expected_types<T>();
48 OptionalAtom<T>::do_set_value(fhicl::ParameterSet const& pset, bool const trimParent)
50 std::string const& rkey = key();
51 std::string const& key = trimParent ? detail::strip_first_containing_name(rkey) : rkey;
52 has_value_ = pset.get_if_present<T>(key, value_);