From 041397fdabde66574824db7582a26ef1e3fbfc65 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 23 Sep 2012 17:42:26 -0400 Subject: Allow reading from InputSource and writing to Pipeline Allowing users to subclass InputSource and Pipeline to read and write from/to arbitrary sources provides the maximum flexibility for users who want to read and write from other than files or memory. --- libqpdf/QPDF.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'libqpdf/QPDF.cc') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 472e0c13..678f773e 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -138,9 +138,8 @@ void QPDF::processFile(char const* filename, char const* password) { FileInputSource* fi = new FileInputSource(); - this->file = fi; fi->setFilename(filename); - parse(password); + processInputSource(fi, password); } void @@ -148,9 +147,8 @@ QPDF::processFile(char const* description, FILE* filep, bool close_file, char const* password) { FileInputSource* fi = new FileInputSource(); - this->file = fi; fi->setFile(description, filep, close_file); - parse(password); + processInputSource(fi, password); } void @@ -158,10 +156,18 @@ QPDF::processMemoryFile(char const* description, char const* buf, size_t length, char const* password) { - this->file = + processInputSource( new BufferInputSource(description, new Buffer((unsigned char*)buf, length), - true); + true), + password); +} + +void +QPDF::processInputSource(PointerHolder source, + char const* password) +{ + this->file = source; parse(password); } -- cgit v1.2.3-54-g00ecf