aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/ResourceFinder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/ResourceFinder.cc')
-rw-r--r--libqpdf/ResourceFinder.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/libqpdf/ResourceFinder.cc b/libqpdf/ResourceFinder.cc
new file mode 100644
index 00000000..74ba671f
--- /dev/null
+++ b/libqpdf/ResourceFinder.cc
@@ -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;
+}