|
ATLAS Offline Software
|
Go to the documentation of this file.
24 : std::runtime_error (
"ExcBadClassName: Malformed class name: `" +
34 : std::runtime_error (
"ExcMissingVariable: Variable `" +
var +
35 "' referenced in substitution but not present "
46 return m_rules.size();
63 m_rules.insert (std::make_pair (
pattern.name(),
64 std::make_pair (
pattern, replacement)));
82 m_rules.insert (std::make_pair (
name,
83 std::make_pair (std::move(
pattern),
84 std::move(replacement))));
102 rulemap_t::const_iterator
it = m_rules.find (cn.
name());
103 while (
it != m_rules.end() &&
it->first == cn.
name()) {
105 if (cn.
match (
it->second.first, matches)) {
106 bool const_save = cn.
isConst();
107 cn =
it->second.second.substCopy (matches);
153 std::string sname =
name;
154 std::string::size_type
pos = 0;
157 if (
pos != sname.size())
171 std::string::size_type
pos = 0;
262 name += cn.fullName();
325 return !(*
this==
other);
360 std::string
var =
m_name.substr (1, std::string::npos);
361 match_t::const_iterator
it = matches.find (
var);
362 if (
it != matches.end()) {
450 if (
m_name.compare (0, 6,
"const ") ==0) {
469 if (
name.compare (
pos, 5,
"const")==0) {
497 else if (
c ==
')' && nest > 0)
499 else if (nest == 0 && (
c ==
'<' ||
c ==
'>' ||
c ==
',' ||
c ==
':'))
523 std::string::size_type&
pos)
536 while (
p->m_namespace.size() > 0)
537 p = &
p->m_namespace[0];
538 p->m_namespace.push_back (std::move(
ns));
555 std::string::size_type&
pos)
585 std::string::size_type&
pos)
607 if (
pattern.m_name[0] ==
'$') {
608 std::string
var =
pattern.m_name.substr (1, std::string::npos);
610 if (
it != matches.end()) {
611 if (
pattern.m_const && !
it->second.m_const) {
616 return *
this ==
it->second;
619 matches[
var] = *
this;
622 matches[
var].m_const =
false;
676 bool ret = rules.
applyTo (*
this);
JetConstituentVector::iterator iterator
Recursively separate out template arguments in a C++ class name.
void add(const ClassName &pattern, const ClassName &replacement)
Add a new transformation rule.
size_t size() const
Return the number of defined rules.
bool isConst() const
Get the const flag for this expression.
const std::string & name() const
Return the root name of the expression.
void subst(const match_t &matches)
Substitute variables into this expression.
void swap(ClassName &other)
Swap this expression with another one.
ExcBadClassName(const std::string &name)
Exception to signal a malformed class name.
void setConst()
Set the const flag for this expression.
Exception to signal a missing variable.
ExcMissingVariable(const std::string &var)
Exception to signal a missing variable.
void parse(const std::string &name, std::string::size_type &pos)
Parse a string into a ClassName.
bool m_const
Is this expression const?
void parseNamespace(const std::string &name, std::string::size_type &pos)
Parse a namespace qualification.
bool applyTo(ClassName &cn) const
Apply the set of transformation rules to a class name object.
void skipSpaces(const std::string &name, std::string::size_type &pos)
Skip past spaces in a string.
size_t ntargs() const
Return number of template arguments.
Recursively separate out template arguments in a C++ class name.
bool operator!=(const ClassName &other) const
Test two expressions for inequality.
std::vector< ClassName > m_namespace
The containing namespace.
std::vector< ClassName > m_targs
The template arguments for this name.
bool operator==(const ClassName &other) const
Test two expressions for equality.
void parseTemplateArgs(const std::string &name, std::string::size_type &pos)
Parse the template part of a name.
std::string fullName() const
Return the full name of the expression.
std::string apply(const std::string &name) const
Apply transformations to a class name.
A set of transformation rules to use with ClassName.
const ClassName & targ(size_t i) const
Return one template argument.
bool match1(const ClassName &pattern, bool topLevel, match_t &matches) const
Match this expression against a pattern.
bool applyRules1(const Rules &rules)
Apply a set of transformation rules to this object.
void applyRules(const Rules &rules)
Apply a set of transformation rules to this object.
Exception to signal a malformed class name.
std::map< std::string, ClassName > match_t
Map used to hold variable assignments from matching.
ClassName()
Default constructor.
std::string parsePrimary(const std::string &name, std::string::size_type &pos)
Parse a primary part of the class name.
ClassName substCopy(const match_t &matches) const
Return a copy of this expression with variables substituted.
std::string m_name
The primary name part of this expression.
std::string qualifiedName() const
Return the namespace-qualified name of the expression.
bool match(const ClassName &pattern, match_t &matches) const
Match this expression against a pattern.