2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-03 19:00:51 +00:00
qpdf/libqpdf/qpdf/ResourceFinder.hh
Jay Berkenbilt e17585c2d2 Remove unreferenced: ignore names that are not Fonts or XObjects
Converted ResourceFinder to ParserCallbacks so we can better detect
the name that precedes various operators and use the operators to sort
the names into resource types. This enables us to be smarter about
detecting unreferenced resources in pages and also sets the stage for
reconciling differences in /DR across documents.
2021-03-03 17:05:49 -05:00

30 lines
839 B
C++

#ifndef RESOURCEFINDER_HH
#define RESOURCEFINDER_HH
#include <qpdf/QPDFObjectHandle.hh>
class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
{
public:
ResourceFinder();
virtual ~ResourceFinder() = default;
virtual void handleObject(QPDFObjectHandle, size_t, size_t) override;
virtual void handleWarning() override;
std::set<std::string> const& getNames() const;
std::map<std::string,
std::map<std::string,
std::set<size_t>>> const& getNamesByResourceType() const;
bool sawBad() const;
private:
std::string last_name;
size_t last_name_offset;
std::set<std::string> names;
std::map<std::string,
std::map<std::string,
std::set<size_t>>> names_by_resource_type;
bool saw_bad;
};
#endif // RESOURCEFINDER_HH