From a2124f992c7a3c2695b93cf7fe9298c3a862ffc9 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 3 Mar 2021 15:02:38 -0500 Subject: [PATCH] Add QPDFMatrix::operator== --- ChangeLog | 2 ++ include/qpdf/QPDFMatrix.hh | 10 ++++++++++ libqpdf/QPDFMatrix.cc | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1addba33..1a5ddfdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2021-03-03 Jay Berkenbilt + * Add QPDFMatrix::operator== + * Add QPDFObjectHandle::makeResourcesIndirect 2021-03-02 Jay Berkenbilt diff --git a/include/qpdf/QPDFMatrix.hh b/include/qpdf/QPDFMatrix.hh index 9448fb99..1afc15a2 100644 --- a/include/qpdf/QPDFMatrix.hh +++ b/include/qpdf/QPDFMatrix.hh @@ -90,6 +90,16 @@ class QPDFMatrix QPDFObjectHandle::Rectangle transformRectangle( QPDFObjectHandle::Rectangle r); + // operator== tests for exact equality, not considering deltas for + // floating point. + QPDF_DLL + bool operator==(QPDFMatrix const& rhs) const; + QPDF_DLL + bool operator!=(QPDFMatrix const& rhs) const + { + return ! operator==(rhs); + } + double a; double b; double c; diff --git a/libqpdf/QPDFMatrix.cc b/libqpdf/QPDFMatrix.cc index 2b269099..42dfcf5d 100644 --- a/libqpdf/QPDFMatrix.cc +++ b/libqpdf/QPDFMatrix.cc @@ -142,3 +142,14 @@ QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const *std::max_element(tx.begin(), tx.end()), *std::max_element(ty.begin(), ty.end())); } + +bool +QPDFMatrix::operator==(QPDFMatrix const& rhs) const +{ + return ((this->a == rhs.a) && + (this->b == rhs.b) && + (this->c == rhs.c) && + (this->d == rhs.d) && + (this->e == rhs.e) && + (this->f == rhs.f)); +}