Commit 3f9191a34456e79ec6d98bfe46546d9df9abdcba

Authored by Jay Berkenbilt
1 parent 858c7b89

Add ostream << for QPDFObjGen

ChangeLog
  1 +2020-12-26 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Add ostream << for QPDFObjGen. (Don't ask why it took 7.5 years
  4 + for me to decide to do this.)
  5 +
1 6 2020-12-25 Jay Berkenbilt <ejb@ql.org>
2 7  
3 8 * Refactor write code to eliminate an extra full traversal of
... ...
include/qpdf/QPDFObjGen.hh
... ... @@ -23,6 +23,7 @@
23 23 #define QPDFOBJGEN_HH
24 24  
25 25 #include <qpdf/DLL.h>
  26 +#include <iostream>
26 27  
27 28 // This class represents an object ID and generation pair. It is
28 29 // suitable to use as a key in a map or set.
... ... @@ -43,6 +44,9 @@ class QPDFObjGen
43 44 QPDF_DLL
44 45 int getGen() const;
45 46  
  47 + QPDF_DLL
  48 + friend std::ostream& operator<<(std::ostream&, const QPDFObjGen&);
  49 +
46 50 private:
47 51 // This class does not use the Members pattern to avoid a memory
48 52 // allocation for every one of these. A lot of these get created
... ...
libqpdf/QPDFObjGen.cc
... ... @@ -36,3 +36,9 @@ QPDFObjGen::getGen() const
36 36 {
37 37 return this->gen;
38 38 }
  39 +
  40 +std::ostream& operator<<(std::ostream& os, const QPDFObjGen& og)
  41 +{
  42 + os << og.obj << "," << og.gen;
  43 + return os;
  44 +}
... ...