Commit 567dd10abec38aa7bee0b2934e6ce36c7623699b

Authored by m-holger
1 parent 51b9e419

Inline various QPDFObjGen method and remove 'explicit' from constructor

include/qpdf/QPDFObjGen.hh
@@ -21,8 +21,10 @@ @@ -21,8 +21,10 @@
21 #define QPDFOBJGEN_HH 21 #define QPDFOBJGEN_HH
22 22
23 #include <qpdf/DLL.h> 23 #include <qpdf/DLL.h>
  24 +
24 #include <iostream> 25 #include <iostream>
25 #include <set> 26 #include <set>
  27 +#include <string>
26 28
27 class QPDFObjectHandle; 29 class QPDFObjectHandle;
28 class QPDFObjectHelper; 30 class QPDFObjectHelper;
@@ -33,13 +35,10 @@ class QPDFObjectHelper; @@ -33,13 +35,10 @@ class QPDFObjectHelper;
33 class QPDFObjGen 35 class QPDFObjGen
34 { 36 {
35 public: 37 public:
36 - // ABI: change to default.  
37 QPDF_DLL 38 QPDF_DLL
38 - QPDFObjGen()  
39 - {  
40 - } 39 + QPDFObjGen() = default;
41 QPDF_DLL 40 QPDF_DLL
42 - explicit QPDFObjGen(int obj, int gen) : 41 + QPDFObjGen(int obj, int gen) :
43 obj(obj), 42 obj(obj),
44 gen(gen) 43 gen(gen)
45 { 44 {
@@ -48,19 +47,19 @@ class QPDFObjGen @@ -48,19 +47,19 @@ class QPDFObjGen
48 bool 47 bool
49 operator<(QPDFObjGen const& rhs) const 48 operator<(QPDFObjGen const& rhs) const
50 { 49 {
51 - return (obj < rhs.obj) || ((obj == rhs.obj) && (gen < rhs.gen)); 50 + return (obj < rhs.obj) || (obj == rhs.obj && gen < rhs.gen);
52 } 51 }
53 QPDF_DLL 52 QPDF_DLL
54 bool 53 bool
55 operator==(QPDFObjGen const& rhs) const 54 operator==(QPDFObjGen const& rhs) const
56 { 55 {
57 - return (obj == rhs.obj) && (gen == rhs.gen); 56 + return obj == rhs.obj && gen == rhs.gen;
58 } 57 }
59 QPDF_DLL 58 QPDF_DLL
60 bool 59 bool
61 operator!=(QPDFObjGen const& rhs) const 60 operator!=(QPDFObjGen const& rhs) const
62 { 61 {
63 - return (obj != rhs.obj) || (gen != rhs.gen); 62 + return !(*this == rhs);
64 } 63 }
65 QPDF_DLL 64 QPDF_DLL
66 int 65 int
@@ -81,9 +80,18 @@ class QPDFObjGen @@ -81,9 +80,18 @@ class QPDFObjGen
81 return obj != 0; 80 return obj != 0;
82 } 81 }
83 QPDF_DLL 82 QPDF_DLL
84 - std::string unparse(char separator = ',') const; 83 + std::string
  84 + unparse(char separator = ',') const
  85 + {
  86 + return std::to_string(obj) + separator + std::to_string(gen);
  87 + }
85 QPDF_DLL 88 QPDF_DLL
86 - friend std::ostream& operator<<(std::ostream& os, const QPDFObjGen& og); 89 + friend std::ostream&
  90 + operator<<(std::ostream& os, QPDFObjGen og)
  91 + {
  92 + os << og.obj << "," << og.gen;
  93 + return os;
  94 + }
87 95
88 // Convenience class for loop detection when processing objects. 96 // Convenience class for loop detection when processing objects.
89 // 97 //
libqpdf/QPDFObjGen.cc
@@ -6,21 +6,6 @@ @@ -6,21 +6,6 @@
6 6
7 #include <stdexcept> 7 #include <stdexcept>
8 8
9 -// ABI: inline and pass og by value  
10 -std::ostream&  
11 -operator<<(std::ostream& os, const QPDFObjGen& og)  
12 -{  
13 - os << og.obj << "," << og.gen;  
14 - return os;  
15 -}  
16 -  
17 -// ABI: inline  
18 -std::string  
19 -QPDFObjGen::unparse(char separator) const  
20 -{  
21 - return std::to_string(obj) + separator + std::to_string(gen);  
22 -}  
23 -  
24 bool 9 bool
25 QPDFObjGen::set::add(QPDFObjectHandle const& oh) 10 QPDFObjGen::set::add(QPDFObjectHandle const& oh)
26 { 11 {