bool Archive::getMembersBySymbol(std::string name, std::vector<Symtab *> &matches) { if (!symbolTableParsed && !parseSymbolTable()) return false; std::pair<std::multimap<string, ArchiveMember *>::iterator, std::multimap<string, ArchiveMember *>::iterator> range_it; range_it = membersBySymbol.equal_range(name); auto begin = range_it.first; auto end = range_it.second; for (; begin != end; ++begin) { ArchiveMember *member = begin->second; Symtab *img = member->getSymtab(); if (!img && !parseMember(img, member)) return false; matches.push_back(img); } return true; }
bool Archive::getMemberByGlobalSymbol(Symtab *&img, string& symbol_name) { if( !symbolTableParsed ) { if( !parseSymbolTable() ) { return false; } } std::pair<std::multimap<string, ArchiveMember *>::iterator, std::multimap<string, ArchiveMember *>::iterator> range_it; range_it = membersBySymbol.equal_range(symbol_name); // Symbol not found in symbol table if( range_it.first == range_it.second ) { serr = No_Such_Member; errMsg = MEMBER_DNE; return false; } ArchiveMember *foundMember = range_it.first->second; // Duplicate symbol found in symbol table ++(range_it.first); if( range_it.first != range_it.second ) { serr = Duplicate_Symbol; errMsg = symbol_name; return false; } img = foundMember->getSymtab(); if( img == NULL ) { if( !parseMember(img, foundMember) ) { return false; } } return true; }