diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-02-08 16:50:55 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-02-08 18:34:14 +0100 |
commit | 8082af09bea1132cecc2d148eeb23bc05e66f6b2 (patch) | |
tree | 5ee5066bdc76c9d3a62edacd9e84def431947ad0 /libqpdf | |
parent | 014dcb02c9bbbf20ea39c01c2aa4d69b3b86fabc (diff) | |
download | qpdf-8082af09bea1132cecc2d148eeb23bc05e66f6b2.tar.zst |
Add PDFVersion class
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/PDFVersion.cc | 69 | ||||
-rw-r--r-- | libqpdf/build.mk | 1 |
2 files changed, 70 insertions, 0 deletions
diff --git a/libqpdf/PDFVersion.cc b/libqpdf/PDFVersion.cc new file mode 100644 index 00000000..c2f28bf8 --- /dev/null +++ b/libqpdf/PDFVersion.cc @@ -0,0 +1,69 @@ +#include <qpdf/PDFVersion.hh> + +#include <qpdf/QUtil.hh> + +PDFVersion::PDFVersion() : + PDFVersion(0, 0, 0) +{ +} + +PDFVersion::PDFVersion(int major, int minor, int extension) : + major(major), + minor(minor), + extension(extension) +{ +} + +bool +PDFVersion::operator<(PDFVersion const& rhs) const +{ + return ((this->major < rhs.major) ? true : + (this->major > rhs.major) ? false : + (this->minor < rhs.minor) ? true : + (this->minor > rhs.minor) ? false : + (this->extension < rhs.minor) ? true : + false); +} + +bool +PDFVersion::operator==(PDFVersion const& rhs) const +{ + return ((this->major == rhs.major) && + (this->minor == rhs.minor) && + (this->extension == rhs.extension)); +} + +void +PDFVersion::updateIfGreater(PDFVersion const& other) +{ + if (*this < other) + { + *this = other; + } +} + +void +PDFVersion::getVersion(std::string& version, int& extension_level) const +{ + extension_level = this->extension; + version = QUtil::int_to_string(this->major) + "." + + QUtil::int_to_string(this->minor); +} + +int +PDFVersion::getMajor() const +{ + return this->major; +} + +int +PDFVersion::getMinor() const +{ + return this->minor; +} + +int +PDFVersion::getExtensionLevel() const +{ + return this->extension; +} diff --git a/libqpdf/build.mk b/libqpdf/build.mk index 3dedfc71..71b32d32 100644 --- a/libqpdf/build.mk +++ b/libqpdf/build.mk @@ -42,6 +42,7 @@ SRCS_libqpdf = \ libqpdf/MD5.cc \ libqpdf/NNTree.cc \ libqpdf/OffsetInputSource.cc \ + libqpdf/PDFVersion.cc \ libqpdf/Pipeline.cc \ libqpdf/Pl_AES_PDF.cc \ libqpdf/Pl_ASCII85Decoder.cc \ |