aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/PDFVersion.cc
blob: c2f28bf8372d5f4f493df121ae578e602c3bb6ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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;
}