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 21 #define QPDFOBJGEN_HH
22 22  
23 23 #include <qpdf/DLL.h>
  24 +
24 25 #include <iostream>
25 26 #include <set>
  27 +#include <string>
26 28  
27 29 class QPDFObjectHandle;
28 30 class QPDFObjectHelper;
... ... @@ -33,13 +35,10 @@ class QPDFObjectHelper;
33 35 class QPDFObjGen
34 36 {
35 37 public:
36   - // ABI: change to default.
37 38 QPDF_DLL
38   - QPDFObjGen()
39   - {
40   - }
  39 + QPDFObjGen() = default;
41 40 QPDF_DLL
42   - explicit QPDFObjGen(int obj, int gen) :
  41 + QPDFObjGen(int obj, int gen) :
43 42 obj(obj),
44 43 gen(gen)
45 44 {
... ... @@ -48,19 +47,19 @@ class QPDFObjGen
48 47 bool
49 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 52 QPDF_DLL
54 53 bool
55 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 58 QPDF_DLL
60 59 bool
61 60 operator!=(QPDFObjGen const& rhs) const
62 61 {
63   - return (obj != rhs.obj) || (gen != rhs.gen);
  62 + return !(*this == rhs);
64 63 }
65 64 QPDF_DLL
66 65 int
... ... @@ -81,9 +80,18 @@ class QPDFObjGen
81 80 return obj != 0;
82 81 }
83 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 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 96 // Convenience class for loop detection when processing objects.
89 97 //
... ...
libqpdf/QPDFObjGen.cc
... ... @@ -6,21 +6,6 @@
6 6  
7 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 9 bool
25 10 QPDFObjGen::set::add(QPDFObjectHandle const& oh)
26 11 {
... ...