Commit b252e70cb6c1637d1e50f1cf5cbccb5726ba06f0
Committed by
Jay Berkenbilt
1 parent
f689769c
Add new methods QPDFTokenizer::getType, getValue, getRawValue and getErrorMessage
Showing
1 changed file
with
31 additions
and
1 deletions
include/qpdf/QPDFTokenizer.hh
| @@ -219,7 +219,15 @@ class QPDFTokenizer | @@ -219,7 +219,15 @@ class QPDFTokenizer | ||
| 219 | bool nextToken( | 219 | bool nextToken( |
| 220 | InputSource& input, std::string const& context, size_t max_len = 0); | 220 | InputSource& input, std::string const& context, size_t max_len = 0); |
| 221 | 221 | ||
| 222 | - private: | 222 | + // The following methods are only valid after nextToken has been called |
| 223 | + // and until another QPDFTokenizer method is called. They allow the results | ||
| 224 | + // of calling nextToken to be accessed without creating a Token, thus | ||
| 225 | + // avoiding copying information that may not be needed. | ||
| 226 | + inline token_type_e getType() const noexcept; | ||
| 227 | + inline std::string const& getValue() const noexcept; | ||
| 228 | + inline std::string const& getRawValue() const noexcept; | ||
| 229 | + inline std::string const& getErrorMessage() const noexcept; | ||
| 230 | + | ||
| 223 | QPDFTokenizer(QPDFTokenizer const&) = delete; | 231 | QPDFTokenizer(QPDFTokenizer const&) = delete; |
| 224 | QPDFTokenizer& operator=(QPDFTokenizer const&) = delete; | 232 | QPDFTokenizer& operator=(QPDFTokenizer const&) = delete; |
| 225 | 233 | ||
| @@ -301,4 +309,26 @@ class QPDFTokenizer | @@ -301,4 +309,26 @@ class QPDFTokenizer | ||
| 301 | int digit_count; | 309 | int digit_count; |
| 302 | }; | 310 | }; |
| 303 | 311 | ||
| 312 | +inline QPDFTokenizer::token_type_e | ||
| 313 | +QPDFTokenizer::getType() const noexcept | ||
| 314 | +{ | ||
| 315 | + return this->type; | ||
| 316 | +} | ||
| 317 | +inline std::string const& | ||
| 318 | +QPDFTokenizer::getValue() const noexcept | ||
| 319 | +{ | ||
| 320 | + return (this->type == tt_name || this->type == tt_string) ? this->val | ||
| 321 | + : this->raw_val; | ||
| 322 | +} | ||
| 323 | +inline std::string const& | ||
| 324 | +QPDFTokenizer::getRawValue() const noexcept | ||
| 325 | +{ | ||
| 326 | + return this->raw_val; | ||
| 327 | +} | ||
| 328 | +inline std::string const& | ||
| 329 | +QPDFTokenizer::getErrorMessage() const noexcept | ||
| 330 | +{ | ||
| 331 | + return this->error_message; | ||
| 332 | +} | ||
| 333 | + | ||
| 304 | #endif // QPDFTOKENIZER_HH | 334 | #endif // QPDFTOKENIZER_HH |