aboutsummaryrefslogtreecommitdiffstats
path: root/include/qpdf/Buffer.hh
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-06-22 03:32:47 +0200
committerJay Berkenbilt <ejb@ql.org>2019-06-22 16:13:27 +0200
commit79f6b4823b95b65290a045a59fdd4a8d9b302708 (patch)
treeb94d273dd51e64a7144b669cf5ed91d826cc1387 /include/qpdf/Buffer.hh
parent864a546af6e1c17e0de2dc2be6da105f454b6e54 (diff)
downloadqpdf-79f6b4823b95b65290a045a59fdd4a8d9b302708.tar.zst
Convert remaining public classes to use Members pattern
Have classes contain only a single private member of type PointerHolder<Members>. This makes it safe to change the structure of the Members class without breaking binary compatibility. Many of the classes already follow this pattern quite successfully. This brings in the rest of the class that are part of the public API.
Diffstat (limited to 'include/qpdf/Buffer.hh')
-rw-r--r--include/qpdf/Buffer.hh28
1 files changed, 20 insertions, 8 deletions
diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh
index bb9a3eb9..8145f41a 100644
--- a/include/qpdf/Buffer.hh
+++ b/include/qpdf/Buffer.hh
@@ -23,7 +23,8 @@
#define BUFFER_HH
#include <qpdf/DLL.h>
-#include <cstring> // for size_t
+#include <qpdf/PointerHolder.hh>
+#include <stddef.h>
class Buffer
{
@@ -46,8 +47,6 @@ class Buffer
QPDF_DLL
Buffer& operator=(Buffer const&);
QPDF_DLL
- ~Buffer();
- QPDF_DLL
size_t getSize() const;
QPDF_DLL
unsigned char const* getBuffer() const;
@@ -55,13 +54,26 @@ class Buffer
unsigned char* getBuffer();
private:
- void init(size_t size, unsigned char* buf, bool own_memory);
+ class Members
+ {
+ friend class Buffer;
+
+ public:
+ QPDF_DLL
+ ~Members();
+
+ private:
+ Members(size_t size, unsigned char* buf, bool own_memory);
+ Members(Members const&);
+
+ bool own_memory;
+ size_t size;
+ unsigned char* buf;
+ };
+
void copy(Buffer const&);
- void destroy();
- bool own_memory;
- size_t size;
- unsigned char* buf;
+ PointerHolder<Members> m;
};
#endif // BUFFER_HH