35 "' referenced in substitution but not present "
63 m_rules.insert (std::make_pair (pattern.name(),
64 std::make_pair (pattern, replacement)));
81 std::string
name = pattern.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;
174 if (pos !=
name.size())
262 name += cn.fullName();
296 if (
m_name != other.m_name)
302 if (
m_namespace.size() != other.m_namespace.size())
305 if (
m_targs.size() != other.m_targs.size())
311 for (
size_t i = 0; i <
m_targs.size(); ++i) {
312 if (
m_targs[i] != other.m_targs[i])
325 return !(*
this==other);
342 return match1 (pattern,
true, matches);
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) {
460 while (pos <
name.size()) {
461 if (
name[pos] ==
'<')
463 else if (
name[pos] ==
':' && pos+1 <
name.size() &&
name[pos+1] ==
':')
469 if (
name.compare (pos, 5,
"const")==0) {
493 while (pos <
name.size()) {
497 else if (c ==
')' && nest > 0)
499 else if (nest == 0 && (c ==
'<' || c ==
'>' || c ==
',' || c ==
':'))
523 std::string::size_type& pos)
525 assert (pos+1 <
name.size() &&
name[pos] ==
':' &&
name[pos+1] ==
':');
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)
557 assert (pos <
name.size() &&
name[pos] ==
'<');
563 if (pos ==
name.size())
break;
564 if (
name[pos] ==
'>') {
568 else if (
name[pos] ==
',')
585 std::string::size_type& pos)
587 while (pos <
name.size() &&
name[pos] ==
' ')
607 if (pattern.m_name[0] ==
'$') {
608 std::string var = pattern.m_name.substr (1, std::string::npos);
609 match_t::iterator it = matches.find (var);
610 if (it != matches.end()) {
611 if (pattern.m_const && !it->second.m_const) {
616 return *
this == it->second;
619 matches[var] = *
this;
620 if (pattern.m_const) {
622 matches[var].m_const =
false;
634 if (pattern.m_const && !
m_const)
637 else if (
m_const != pattern.m_const) {
641 if (
m_name != pattern.m_name)
644 if (
m_namespace.size() != pattern.m_namespace.size())
647 if (
m_targs.size() != pattern.m_targs.size())
655 for (
size_t i = 0; i <
m_targs.size(); i++) {
676 bool ret = rules.
applyTo (*
this);
681 for (
size_t i = 0; i <
m_targs.size(); i++)
Recursively separate out template arguments in a C++ class name.
Exception to signal a malformed class name.
ExcBadClassName(const std::string &name)
Exception to signal a malformed class name.
Exception to signal a missing variable.
ExcMissingVariable(const std::string &var)
Exception to signal a missing variable.
A set of transformation rules to use with ClassName.
std::string apply(const std::string &name) const
Apply transformations to a class name.
void add(const ClassName &pattern, const ClassName &replacement)
Add a new transformation rule.
bool applyTo(ClassName &cn) const
Apply the set of transformation rules to a class name object.
size_t size() const
Return the number of defined rules.
bool operator==(const ClassName &other) const
Test two expressions for equality.
bool match1(const ClassName &pattern, bool topLevel, match_t &matches) const
Match this expression against a pattern.
bool isConst() const
Get the const flag for this expression.
std::vector< ClassName > m_namespace
The containing namespace.
void subst(const match_t &matches)
Substitute variables into this expression.
std::string parsePrimary(const std::string &name, std::string::size_type &pos)
Parse a primary part of the class name.
bool m_const
Is this expression const?
void skipSpaces(const std::string &name, std::string::size_type &pos)
Skip past spaces in a string.
std::string m_name
The primary name part of this expression.
std::string fullName() const
Return the full name of the expression.
bool operator!=(const ClassName &other) const
Test two expressions for inequality.
std::vector< ClassName > m_targs
The template arguments for this name.
bool applyRules1(const Rules &rules)
Apply a set of transformation rules to this object.
ClassName substCopy(const match_t &matches) const
Return a copy of this expression with variables substituted.
std::map< std::string, ClassName > match_t
Map used to hold variable assignments from matching.
ClassName()
Default constructor.
const std::string & name() const
Return the root name of the expression.
bool match(const ClassName &pattern, match_t &matches) const
Match this expression against a pattern.
const ClassName & targ(size_t i) const
Return one template argument.
std::string qualifiedName() const
Return the namespace-qualified name of the expression.
void setConst()
Set the const flag for this expression.
void applyRules(const Rules &rules)
Apply a set of transformation rules to this object.
void parseNamespace(const std::string &name, std::string::size_type &pos)
Parse a namespace qualification.
void swap(ClassName &other)
Swap this expression with another one.
void parse(const std::string &name, std::string::size_type &pos)
Parse a string into a ClassName.
void parseTemplateArgs(const std::string &name, std::string::size_type &pos)
Parse the template part of a name.
size_t ntargs() const
Return number of template arguments.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)