Name.h
Go to the documentation of this file.
1 #ifndef fhiclcpp_types_Name_h
2 #define fhiclcpp_types_Name_h
3 
4 #include <string>
5 
6 namespace fhicl {
7 
9 
10  struct Name {
11 
12  explicit Name(std::string const& name = "") : value(name) {}
14 
15  static Name
16  sequence_element(std::size_t const i)
17  {
18  return Name{index(i)};
19  }
20 
21  static Name
22  sequence_element(std::string const& key_stem, std::size_t const i)
23  {
24  return Name{key_stem + index(i)};
25  }
26 
27  // Sometimes the key has '[' and ']' literals in it. Those must be
28  // padded with an escape character so the regex library doesn't
29  // think we're trying to specify a character set.
30  static std::string
32  {
33  return fhicl::get_regex_replace_str(key);
34  }
35 
36  private:
37  static std::string
38  index(std::size_t const i)
39  {
40  return "[" + std::to_string(i) + "]";
41  }
42  };
43 }
44 
45 #endif /* fhiclcpp_types_Name_h */
46 
47 // Local variables:
48 // mode: c++
49 // End:
static QCString name
Definition: declinfo.cpp:673
static Name sequence_element(std::string const &key_stem, std::size_t const i)
Definition: Name.h:22
Name(std::string const &name="")
Definition: Name.h:12
std::string string
Definition: nybbler.cc:12
def key(type, name=None)
Definition: graph.py:13
std::string value
Definition: Name.h:13
static Name sequence_element(std::size_t const i)
Definition: Name.h:16
static std::string regex_safe(std::string const &key)
Definition: Name.h:31
std::string get_regex_replace_str(std::string const &str)
Definition: Name.cc:11
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString str
static std::string index(std::size_t const i)
Definition: Name.h:38