summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-09-23 23:42:26 +0200
committerJay Berkenbilt <ejb@ql.org>2012-09-23 23:42:26 +0200
commit041397fdabde66574824db7582a26ef1e3fbfc65 (patch)
treebb9d46db2082978e8c7fbbe4373e5df8e70e68b1 /libqpdf/QPDF.cc
parent8c99e4a6c0f79c62fb9983404086c72ecf54ac83 (diff)
downloadqpdf-041397fdabde66574824db7582a26ef1e3fbfc65.tar.zst
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.
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc18
1 files changed, 12 insertions, 6 deletions
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<InputSource> source,
+ char const* password)
+{
+ this->file = source;
parse(password);
}