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); } }
bool operator< ( const Name& left, const Name& right ) { return left.last() < right.last() || ( left.last() == right.last() && left.first() < right.first() ); }
bool operator== ( const Name& left, const Name& right ) { return left.last() == right.last() && left.first() == right.first(); }