2 #include "cetlib/container_algorithms.h" 18 std::set<std::string>
const& keysToIgnore)
62 return e.find(k +
'[') == 0ull or
e == k;
88 <<
"The supplied value of the parameter:\n" 89 <<
" " << s.
key() <<
'\n' 90 <<
"does not represent a sequence.\n";
94 std::size_t
const nElems =
96 return std::regex_match(k,
r);
109 auto const& name = dp.
name();
111 std::regex const r{pattern};
114 return std::regex_search(k,
r);
126 using key_set = std::set<std::string>;
129 removeIgnorableKeys(key_set
const& ignorable,
130 std::vector<std::string>& extra,
131 std::vector<cet::exempt_ptr<ParameterBase>>& missing)
133 for (
auto const& key : ignorable) {
139 auto it = cet::find_in_all(extra, subkey);
140 if (it != extra.cend()) {
141 auto match = [&subkey](std::string
const& key) {
142 return key.find(subkey) == 0ul;
144 auto const end = std::find_if_not(it, extra.end(), match);
145 extra.erase(it,
end);
151 std::remove_if(missing.begin(), missing.end(), [&subkey](
auto p) {
152 return p->key() == subkey;
155 missing.erase(mit, missing.end());
160 show_parents(std::string
const& k)
162 std::size_t
const freq =
163 std::count(k.begin(), k.end(),
'.') + std::count(k.begin(), k.end(),
'[');
169 std::vector<cet::exempt_ptr<ParameterBase>>
const& missingParams)
171 if (missingParams.empty())
174 std::string
const prefix{
" - " + std::string(3,
' ')};
176 std::ostringstream oss;
177 oss <<
"Missing parameters:\n";
178 for (
auto p : missingParams) {
192 std::vector<std::string>
const& extraKeys)
194 if (extraKeys.empty())
197 std::ostringstream oss;
198 oss <<
"Unsupported parameters:\n\n";
199 for (
auto const& key : extraKeys) {
200 oss <<
" + " << std::setw(30) <<
std::left << key <<
" [ " 216 if (!errmsg.empty()) {
void prepare_elements_for_validation(std::size_t const n)
void enter_sequence(SequenceBase &p) override
void set_value(fhicl::ParameterSet const &ps)
bool preset_value(fhicl::ParameterSet const &ps)
void enter_table(TableBase &) override
std::set< std::string > ignorableKeys_
std::vector< std::string > userKeys_
std::string optional_parameter_message(bool const with_comment=true)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
bool is_key_to_sequence(std::string const &key) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::string strip_first_containing_name(std::string const &key)
void walk_over(tt::maybe_const_t< ParameterBase, C > &)
ParameterSet const & pset_
par_type parameter_type() const
std::string const & name() const
std::string const & key() const
void delegated_parameter(DelegateBase &) override
bool has_key(std::string const &key) const
ValidateThenSet(ParameterSet const &pset, std::set< std::string > const &keysToIgnore)
std::vector< cet::exempt_ptr< ParameterBase > > missingParameters_
static std::string regex_safe(std::string const &key)
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
void atom(AtomBase &) override
std::string get_src_info(std::string const &key) const
void after_action(ParameterBase &p) override
bool before_action(ParameterBase &p) override
cet::coded_exception< error, detail::translate > exception
bool is_sequence(std::any const &val)