2022-02-08 15:50:55 +00:00
|
|
|
#include <qpdf/PDFVersion.hh>
|
|
|
|
|
|
|
|
#include <qpdf/QUtil.hh>
|
|
|
|
|
|
|
|
PDFVersion::PDFVersion() :
|
|
|
|
PDFVersion(0, 0, 0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
PDFVersion::PDFVersion(
|
|
|
|
int major_version, int minor_version, int extension_level) :
|
2022-02-08 16:07:37 +00:00
|
|
|
major_version(major_version),
|
|
|
|
minor_version(minor_version),
|
|
|
|
extension_level(extension_level)
|
2022-02-08 15:50:55 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PDFVersion::operator<(PDFVersion const& rhs) const
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
return (
|
|
|
|
(this->major_version < rhs.major_version) ? true
|
|
|
|
: (this->major_version > rhs.major_version) ? false
|
|
|
|
: (this->minor_version < rhs.minor_version) ? true
|
|
|
|
: (this->minor_version > rhs.minor_version) ? false
|
|
|
|
: (this->extension_level < rhs.extension_level) ? true
|
|
|
|
: false);
|
2022-02-08 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PDFVersion::operator==(PDFVersion const& rhs) const
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
return (
|
|
|
|
(this->major_version == rhs.major_version) &&
|
|
|
|
(this->minor_version == rhs.minor_version) &&
|
|
|
|
(this->extension_level == rhs.extension_level));
|
2022-02-08 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PDFVersion::updateIfGreater(PDFVersion const& other)
|
|
|
|
{
|
2022-04-02 21:14:10 +00:00
|
|
|
if (*this < other) {
|
2022-02-08 15:50:55 +00:00
|
|
|
*this = other;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PDFVersion::getVersion(std::string& version, int& extension_level) const
|
|
|
|
{
|
2022-02-08 16:07:37 +00:00
|
|
|
extension_level = this->extension_level;
|
2022-09-21 16:49:21 +00:00
|
|
|
version = std::to_string(this->major_version) + "." +
|
|
|
|
std::to_string(this->minor_version);
|
2022-02-08 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PDFVersion::getMajor() const
|
|
|
|
{
|
2022-02-08 16:07:37 +00:00
|
|
|
return this->major_version;
|
2022-02-08 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PDFVersion::getMinor() const
|
|
|
|
{
|
2022-02-08 16:07:37 +00:00
|
|
|
return this->minor_version;
|
2022-02-08 15:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PDFVersion::getExtensionLevel() const
|
|
|
|
{
|
2022-02-08 16:07:37 +00:00
|
|
|
return this->extension_level;
|
2022-02-08 15:50:55 +00:00
|
|
|
}
|