forked from qpdf/qpdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create ResourceFinder from NameWatcher in QPDFPageObjectHelper
- Loading branch information
1 parent
b444ab3
commit 37fcc5f
Showing
4 changed files
with
67 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <qpdf/ResourceFinder.hh> | ||
|
||
ResourceFinder::ResourceFinder() : | ||
saw_bad(false) | ||
{ | ||
} | ||
|
||
void | ||
ResourceFinder::handleToken(QPDFTokenizer::Token const& token) | ||
{ | ||
if ((token.getType() == QPDFTokenizer::tt_word) && | ||
(! this->last_name.empty())) | ||
{ | ||
this->names.insert(this->last_name); | ||
} | ||
else if (token.getType() == QPDFTokenizer::tt_name) | ||
{ | ||
this->last_name = | ||
QPDFObjectHandle::newName(token.getValue()).getName(); | ||
} | ||
else if (token.getType() == QPDFTokenizer::tt_bad) | ||
{ | ||
saw_bad = true; | ||
} | ||
writeToken(token); | ||
} | ||
|
||
std::set<std::string> const& | ||
ResourceFinder::getNames() const | ||
{ | ||
return this->names; | ||
} | ||
|
||
bool | ||
ResourceFinder::sawBad() const | ||
{ | ||
return this->saw_bad; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef RESOURCEFINDER_HH | ||
#define RESOURCEFINDER_HH | ||
|
||
#include <qpdf/QPDFObjectHandle.hh> | ||
|
||
class ResourceFinder: public QPDFObjectHandle::TokenFilter | ||
{ | ||
public: | ||
ResourceFinder(); | ||
virtual ~ResourceFinder() = default; | ||
virtual void handleToken(QPDFTokenizer::Token const&) override; | ||
std::set<std::string> const& getNames() const; | ||
bool sawBad() const; | ||
|
||
private: | ||
std::string last_name; | ||
std::set<std::string> names; | ||
std::map<std::string, std::set<std::string>> names_by_resource_type; | ||
bool saw_bad; | ||
}; | ||
|
||
#endif // RESOURCEFINDER_HH |