9 #include "boost/algorithm/string.hpp" 10 #include "boost/any.hpp" 17 using namespace fhicl;
83 boost::any
const&
value)
92 bool result = (found_val !=
nullptr);
103 bool result = (found_val !=
nullptr);
105 *found_val = std::move(
value);
117 std::vector<std::string>
const& key =
split(name);
119 for (
unsigned k = 0, sz = key.size(); k != sz; ++k) {
120 std::string
const& this_key = key[k];
121 if (this_key.empty())
123 else if (std::isdigit(this_key[0])) {
126 <<
"-- not a sequence (at part \"" << this_key <<
"\")";
128 unsigned i = std::atoi(this_key.c_str());
135 <<
"-- not a table (at part \"" << this_key <<
"\")";
151 std::vector<std::string>
const& key =
split(name);
153 for (
unsigned k = 0, sz = key.size(); k != sz; ++k) {
154 std::string
const& this_key = key[k];
155 if (this_key.empty())
157 else if (std::isdigit(this_key[0])) {
162 unsigned i = std::atoi(this_key.c_str());
188 auto const& key(
split(name));
190 auto t(boost::any_cast<table_t>(&p->value));
193 (((it = t->find(key[0])) == t->end()) || it->second.in_prolog)) {
196 bool at_sequence(
false);
197 for (
auto const& this_key : key) {
198 if (this_key.empty())
200 else if (std::isdigit(this_key[0])) {
203 <<
"-- not a sequence (at part \"" << this_key <<
"\")";
205 unsigned i = std::atoi(this_key.c_str());
214 <<
"-- not a table (at part \"" << this_key <<
"\")";
216 t = boost::any_cast<
table_t>(&p->value);
217 it = t->
find(this_key);
218 if (it == t->end()) {
222 auto prot = p->protection;
225 << ((this_key != name) ? (std::string(
"Part \"") + this_key +
226 "\" of specification to be erased\n") :
228 <<
'"' << name <<
"\" is protected on " << p->pretty_src_info()
238 if (it != t->end()) {
249 std::vector<std::string>
const& key =
split(name);
251 if (it != t.
end() && it->second.in_prolog) {
256 if ((!located.first->is_a(
NIL)) &&
257 value.
protection > located.first->protection) {
259 <<
'"' << name <<
"\" cannot be assigned with increased protection" 260 <<
"\n(previous definition on " << (located.first)->pretty_src_info()
263 return located.second ? located.first :
nullptr;
266 std::pair<extended_value*, bool>
269 std::pair<extended_value*, bool> result(
nullptr,
true);
270 std::vector<std::string>
const& key =
split(name);
273 for (
unsigned k = 0, sz = key.size(); k != sz; ++k) {
274 std::string
const& this_key = key[k];
275 if (this_key.empty())
277 else if (std::isdigit(this_key[0])) {
283 <<
"-- not a sequence (at part \"" << this_key <<
"\")";
285 unsigned i = std::atoi(this_key.c_str());
286 while (
s.size() <= i) {
287 s.push_back(nil_item());
298 <<
"-- not a table (at part \"" << this_key <<
"\")";
302 p = &t.emplace(this_key, nil_item()).first->second;
308 << ((this_key != name) ? (std::string(
"Part \"") + this_key +
309 "\" of specification to be overwritten\n") :
311 <<
'"' << name <<
"\" is protected on " << p->
pretty_src_info() <<
'\n';
313 result.second =
false;
321 std::vector<std::string>
324 std::vector<std::string> result;
325 boost::algorithm::split(
size_t erase(Key const &key)
bool isSnippetMode(bool m)
bool is_a(value_tag t) const
std::string value(boost::any const &)
std::string pretty_src_info() const
void set_prolog(bool new_prolog_state)
iterator find(Key const &key)
cet::coded_exception< error, detail::translate > exception