summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-10-04 21:50:36 +0200
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2023-01-07 21:24:51 +0100
commitb252e70cb6c1637d1e50f1cf5cbccb5726ba06f0 (patch)
treea5a39c3e5b911983139b729a40d13063938aff83 /include
parentf689769ccab2f98924f5e22ed145fdbd041f5e1d (diff)
downloadqpdf-b252e70cb6c1637d1e50f1cf5cbccb5726ba06f0.tar.zst
Add new methods QPDFTokenizer::getType, getValue, getRawValue and getErrorMessage
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFTokenizer.hh32
1 files changed, 31 insertions, 1 deletions
diff --git a/include/qpdf/QPDFTokenizer.hh b/include/qpdf/QPDFTokenizer.hh
index ec9e66c7..b9642fc3 100644
--- a/include/qpdf/QPDFTokenizer.hh
+++ b/include/qpdf/QPDFTokenizer.hh
@@ -219,7 +219,15 @@ class QPDFTokenizer
bool nextToken(
InputSource& input, std::string const& context, size_t max_len = 0);
- private:
+ // The following methods are only valid after nextToken has been called
+ // and until another QPDFTokenizer method is called. They allow the results
+ // of calling nextToken to be accessed without creating a Token, thus
+ // avoiding copying information that may not be needed.
+ inline token_type_e getType() const noexcept;
+ inline std::string const& getValue() const noexcept;
+ inline std::string const& getRawValue() const noexcept;
+ inline std::string const& getErrorMessage() const noexcept;
+
QPDFTokenizer(QPDFTokenizer const&) = delete;
QPDFTokenizer& operator=(QPDFTokenizer const&) = delete;
@@ -301,4 +309,26 @@ class QPDFTokenizer
int digit_count;
};
+inline QPDFTokenizer::token_type_e
+QPDFTokenizer::getType() const noexcept
+{
+ return this->type;
+}
+inline std::string const&
+QPDFTokenizer::getValue() const noexcept
+{
+ return (this->type == tt_name || this->type == tt_string) ? this->val
+ : this->raw_val;
+}
+inline std::string const&
+QPDFTokenizer::getRawValue() const noexcept
+{
+ return this->raw_val;
+}
+inline std::string const&
+QPDFTokenizer::getErrorMessage() const noexcept
+{
+ return this->error_message;
+}
+
#endif // QPDFTOKENIZER_HH