Commit 4c6640cb455bc9e8a2e2150be2e48455be341325
Committed by
Jay Berkenbilt
1 parent
a603c1e3
Inline QPDFObjGen methods
ABI breaking change
Showing
3 changed files
with
36 additions
and
65 deletions
include/qpdf/QPDFObjGen.hh
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | #define QPDFOBJGEN_HH |
| 24 | 24 | |
| 25 | 25 | #include <qpdf/DLL.h> |
| 26 | +#include <qpdf/QUtil.hh> | |
| 26 | 27 | #include <iostream> |
| 27 | 28 | |
| 28 | 29 | // This class represents an object ID and generation pair. It is |
| ... | ... | @@ -32,22 +33,48 @@ class QPDFObjGen |
| 32 | 33 | { |
| 33 | 34 | public: |
| 34 | 35 | QPDF_DLL |
| 35 | - QPDFObjGen(); | |
| 36 | + QPDFObjGen() : | |
| 37 | + obj(0), | |
| 38 | + gen(0) | |
| 39 | + { | |
| 40 | + } | |
| 36 | 41 | QPDF_DLL |
| 37 | - QPDFObjGen(int obj, int gen); | |
| 42 | + QPDFObjGen(int obj, int gen) : | |
| 43 | + obj(obj), | |
| 44 | + gen(gen) | |
| 45 | + { | |
| 46 | + } | |
| 38 | 47 | QPDF_DLL |
| 39 | - bool operator<(QPDFObjGen const&) const; | |
| 48 | + bool operator<(QPDFObjGen const& rhs) const | |
| 49 | + { | |
| 50 | + return ((obj < rhs.obj) || ((obj == rhs.obj) && (gen < rhs.gen))); | |
| 51 | + } | |
| 40 | 52 | QPDF_DLL |
| 41 | - bool operator==(QPDFObjGen const&) const; | |
| 53 | + bool operator==(QPDFObjGen const& rhs) const | |
| 54 | + { | |
| 55 | + return ((obj == rhs.obj) && (gen == rhs.gen)); | |
| 56 | + } | |
| 42 | 57 | QPDF_DLL |
| 43 | - int getObj() const; | |
| 58 | + int getObj() const | |
| 59 | + { | |
| 60 | + return obj; | |
| 61 | + } | |
| 44 | 62 | QPDF_DLL |
| 45 | - int getGen() const; | |
| 63 | + int getGen() const | |
| 64 | + { | |
| 65 | + return gen; | |
| 66 | + } | |
| 46 | 67 | QPDF_DLL |
| 47 | - std::string unparse() const; | |
| 48 | - | |
| 68 | + std::string unparse() const | |
| 69 | + { | |
| 70 | + return QUtil::int_to_string(obj) + "," + QUtil::int_to_string(gen); | |
| 71 | + } | |
| 49 | 72 | QPDF_DLL |
| 50 | - friend std::ostream& operator<<(std::ostream&, const QPDFObjGen&); | |
| 73 | + friend std::ostream& operator<<(std::ostream& os, const QPDFObjGen& og) | |
| 74 | + { | |
| 75 | + os << og.obj << "," << og.gen; | |
| 76 | + return os; | |
| 77 | + } | |
| 51 | 78 | |
| 52 | 79 | private: |
| 53 | 80 | // This class does not use the Members pattern to avoid a memory | ... | ... |
libqpdf/CMakeLists.txt
libqpdf/QPDFObjGen.cc deleted
| 1 | -#include <qpdf/QPDFObjGen.hh> | |
| 2 | - | |
| 3 | -#include <qpdf/QUtil.hh> | |
| 4 | - | |
| 5 | -QPDFObjGen::QPDFObjGen() : | |
| 6 | - obj(0), | |
| 7 | - gen(0) | |
| 8 | -{ | |
| 9 | -} | |
| 10 | - | |
| 11 | -QPDFObjGen::QPDFObjGen(int o, int g) : | |
| 12 | - obj(o), | |
| 13 | - gen(g) | |
| 14 | -{ | |
| 15 | -} | |
| 16 | - | |
| 17 | -bool | |
| 18 | -QPDFObjGen::operator<(QPDFObjGen const& rhs) const | |
| 19 | -{ | |
| 20 | - return ( | |
| 21 | - (this->obj < rhs.obj) || | |
| 22 | - ((this->obj == rhs.obj) && (this->gen < rhs.gen))); | |
| 23 | -} | |
| 24 | - | |
| 25 | -bool | |
| 26 | -QPDFObjGen::operator==(QPDFObjGen const& rhs) const | |
| 27 | -{ | |
| 28 | - return ((this->obj == rhs.obj) && (this->gen == rhs.gen)); | |
| 29 | -} | |
| 30 | - | |
| 31 | -int | |
| 32 | -QPDFObjGen::getObj() const | |
| 33 | -{ | |
| 34 | - return this->obj; | |
| 35 | -} | |
| 36 | - | |
| 37 | -int | |
| 38 | -QPDFObjGen::getGen() const | |
| 39 | -{ | |
| 40 | - return this->gen; | |
| 41 | -} | |
| 42 | - | |
| 43 | -std::ostream& | |
| 44 | -operator<<(std::ostream& os, const QPDFObjGen& og) | |
| 45 | -{ | |
| 46 | - os << og.obj << "," << og.gen; | |
| 47 | - return os; | |
| 48 | -} | |
| 49 | - | |
| 50 | -std::string | |
| 51 | -QPDFObjGen::unparse() const | |
| 52 | -{ | |
| 53 | - return QUtil::int_to_string(this->obj) + "," + | |
| 54 | - QUtil::int_to_string(this->gen); | |
| 55 | -} |