NameStackRegistry.cc
Go to the documentation of this file.
2 #include "fhiclcpp/exception.h"
3 
4 #include <numeric>
5 #include <regex>
6 
7 namespace {
8  std::regex const re_sequence_element{R"(\[\d+\])"};
9 }
10 
11 namespace fhicl {
14  {
15  if (name.empty()) {
16  throw exception{error::other, "NameStackRegistry::full_key"}
17  << "Cannot insert empty name into 'NameStackRegistry'.\n";
18  }
19 
20  auto& names = instance_().names_;
21  if (names.empty() || std::regex_match(name, re_sequence_element)) {
22  names.emplace_back(name);
23  } else {
24  names.emplace_back("." + name);
25  }
26  return std::accumulate(names.begin(), names.end(), std::string{});
27  }
28 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
static NameStackRegistry & instance_()
static std::string full_key(std::string const &key)
static std::vector< std::string > const names
Definition: FragmentType.hh:8
std::vector< std::string > names_
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33