UnknownType::UnknownType(const Name& name) : Type(Name(name.last())) { if (!name.isSimple()) { /* * As we need to support UnknownType instances with qualified names, * but NamedEntity's name() method guarantees to return a simple name, * we need a small hack: we create auxiliary NamedEntity instances and * chain them together with addChild() so that the * UnknownType's qualifiedName() method will return the correct * full name, while name() will only return the simple name. */ Name::identifiers_iterator it = name.identifiers_begin(); mQualifiedNameParents.push_back(new NamedEntity(Name(*it))); it++; for (; it != --name.identifiers_end(); it++) { NamedEntity* parent = new NamedEntity(Name(*it)); mQualifiedNameParents.back()->addChild(parent); mQualifiedNameParents.push_back(parent); } mQualifiedNameParents.back()->addChild(this); } }
Name Name::operator+(const Name& other) const { Name ret(identifiers_begin(), identifiers_end()); ret.mIdentifiers.insert(ret.mIdentifiers.end(), other.identifiers_begin(), other.identifiers_end()); return ret; }
bool Name::operator==(const Name& other) const { if (countIdentifiers() != other.countIdentifiers()) return false; Name::identifiers_iterator it1 = identifiers_begin(); Name::identifiers_iterator it2 = other.identifiers_begin(); do { if (*it1 != *it2) return false; it1++; it2++; } while (it1 != identifiers_end()); return true; }