22 using namespace fhicl;
50 std::ostringstream oss;
51 oss << key <<
"[" << i++ <<
"]";
52 src_map[oss.str()] = xval.src_info;
53 fill_src_info(xval, oss.str(), src_map);
58 get_pset_via_any(std::any
const&
a)
71 for (
auto const& [
key,
value] : tbl) {
87 auto const& tbl =
table_t(xval);
88 for (
auto const& [
key,
value] : tbl) {
131 result.append(stringify_(*seq.begin(), compact));
132 for (
auto it = seq.cbegin(),
e = seq.cend(); ++it !=
e;) {
133 result.append(1,
',').append(stringify_(*it, compact));
136 result.append(1,
']');
139 result = str ==
string(9,
'\0') ?
"@nil" :
str;
149 return mapping_.empty();
155 if (!id_.is_valid()) {
165 if (mapping_.empty()) {
168 auto it = mapping_.begin();
170 stringify_(it->second, compact));
171 for (
auto const e = mapping_.end(); ++it !=
e;) {
173 stringify_(it->second, compact));
192 for (
auto const& [
key,
value] : mapping_) {
213 auto it = mapping_.find(skey.name());
214 if (it == mapping_.end()) {
222 std::optional<ParameterSet>
226 return std::make_optional(*
this);
229 std::optional<ParameterSet>
result;
230 for (
auto const&
name : names) {
231 if (!
p->find_one_(
name)) {
234 if (!
p->is_key_to_table(
name)) {
250 auto ps = descend_(
keys.tables());
251 return ps ?
ps->find_one_(
keys.last()) :
false;
260 return result != srcMapping_.cend() ?
result->second :
"";
274 put_or_replace(key,
nullptr);
283 if (key.find(
'.') != std::string::npos) {
292 check_put_local_key(key);
293 if (!mapping_.emplace(key, value).second) {
302 check_put_local_key(key);
310 check_put_local_key(key);
311 auto item = mapping_.find(key);
312 if (item == mapping_.end()) {
317 auto is_non_nil_atom = [](any
const& v) {
323 <<
"can't use non-sequence to replace sequence.";
326 }
else if (is_non_nil_atom(item->second) &&
329 <<
"can't use non-atom to replace non-nil atom.";
332 item->second =
value;
340 bool const did_erase{1u == mapping_.erase(key)};
350 auto ps = descend_(split_keys.tables());
357 auto it = ps->mapping_.find(skey.name());
358 if (it == ps->mapping_.end()) {
364 skey.indices().cbegin(), skey.indices().cend(),
a) ?
411 auto insert = [
this, &
value](
auto const&
key) {
413 this->insert_(key, std::any(
encode(value)));
414 fill_src_info(value, key, srcMapping_);
425 std::stack<ParameterSet const*> ps_stack;
428 std::function<void(std::string const&, std::any const&)> act_on_element =
431 auto const*
ps = ps_stack.top();
438 for (
auto const& [nested_key, nested_a] : ps->
mapping_) {
439 act_on_element(nested_key, nested_a);
446 for (
auto const& elem : any_cast<ps_sequence_t>(
a)) {
448 act_on_element(new_key, elem);
458 for (
auto const& [key,
value] : mapping_) {
459 act_on_element(key,
value);
468 return to_indented_string(0u);
474 return to_indented_string(initial_indent_level,
false);
479 bool const annotate)
const
void do_before_action(key_t const &k, any_t const &a, ParameterSet const *ps)
bool is_a(value_tag const t) const noexcept
ps_atom_t encode(std::string const &)
static ParameterSet make(intermediate_table const &tbl)
static collection_type const & get() noexcept
Keys get_names(std::string const &key)
std::unordered_map< std::string, std::string > annot_t
intermediate_table::table_t table_t
int find(char c, int index=0, bool cs=TRUE) const
void do_enter_sequence(key_t const &k, any_t const &a)
bool find_an_any(cit_size_t it, cit_size_t const cend, std::any &a)
void do_exit_table(key_t const &k, any_t const &a)
std::vector< std::any > ps_sequence_t
std::vector< std::string > get_pset_names() const
void try_insert(L l, std::string const &key)
def walk(top, topdown=True)
std::vector< extended_value > sequence_t
static constexpr std::size_t max_str_size() noexcept
std::string to_indented_string() const
fhicl::detail::ps_atom_t ps_atom_t
void insert_(std::string const &key, std::any const &value)
std::optional< ParameterSet > descend_(std::vector< std::string > const &names) const
void insert_or_replace_compatible_(std::string const &key, std::any const &value)
void walk(ParameterSetWalker &psw) const
bool has_key(std::string const &key) const
static constexpr double ps
bool is_nil(std::any const &val)
auto transform_all(Container &, OutputIt, UnaryOp)
void do_after_action(key_t const &k)
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
void do_exit_sequence(key_t const &k, any_t const &a)
std::vector< key_t > const & result()
bool key_is_type_(std::string const &key, std::function< bool(std::any const &)> func) const
std::string get_src_info(std::string const &key) const
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
std::string result() const
void reset(ParameterSet const &)
std::vector< std::string > get_names() const
std::string stringify_(std::any const &a, bool compact=false) const
bool is_table(std::any const &val)
bool erase(std::string const &key)
void do_atom(key_t const &k, any_t const &a)
static std::vector< std::string > const names
def maker(G, ac, typename)
bool find_one_(std::string const &key) const
void put_or_replace(std::string const &key)
void function(int client, int *resource, int parblock, int *test, int p)
std::string to_string(ModuleType const mt)
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
bool is_sequence(std::any const &val)
QCString & append(const char *s)
void do_enter_table(key_t const &k, any_t const &a)
std::string to_string_(bool compact=false) const
void insert_or_replace_(std::string const &key, std::any const &value)