Commit 4181ec92ad64fbbc3070a3b57c759c1bcdeb5f23
1 parent
6a0d6fe1
Refactor null object handling across helpers to use the `Null` class for consist…
…ent and simplified temporary null management. Clean up unused test coverage markers.
Showing
2 changed files
with
35 additions
and
0 deletions
libqpdf/QPDFObjectHandle.cc
libqpdf/qpdf/QPDFObjectHandle_private.hh
| @@ -468,6 +468,39 @@ namespace qpdf | @@ -468,6 +468,39 @@ namespace qpdf | ||
| 468 | } | 468 | } |
| 469 | }; | 469 | }; |
| 470 | 470 | ||
| 471 | + class Null final: public BaseHandle | ||
| 472 | + { | ||
| 473 | + public: | ||
| 474 | + // Unlike other types, the Null default constructor creates a valid null object. | ||
| 475 | + Null() : | ||
| 476 | + BaseHandle(QPDFObject::create<QPDF_Null>()) | ||
| 477 | + { | ||
| 478 | + } | ||
| 479 | + | ||
| 480 | + Null(Null const&) = default; | ||
| 481 | + Null(Null&&) = default; | ||
| 482 | + Null& operator=(Null const&) = default; | ||
| 483 | + Null& operator=(Null&&) = default; | ||
| 484 | + ~Null() = default; | ||
| 485 | + | ||
| 486 | + // For legacy support, return a Null object to be used as a temporary return value. | ||
| 487 | + static QPDFObjectHandle | ||
| 488 | + temp() | ||
| 489 | + { | ||
| 490 | + return temp_.oh(); | ||
| 491 | + } | ||
| 492 | + | ||
| 493 | + // For legacy support, return an explicit temporary Null object if oh is null. | ||
| 494 | + static QPDFObjectHandle | ||
| 495 | + if_null(QPDFObjectHandle oh) | ||
| 496 | + { | ||
| 497 | + return oh ? std::move(oh) : Null::temp(); | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + private: | ||
| 501 | + static const Null temp_; | ||
| 502 | + }; // class Null | ||
| 503 | + | ||
| 471 | class Stream final: public BaseHandle | 504 | class Stream final: public BaseHandle |
| 472 | { | 505 | { |
| 473 | public: | 506 | public: |