aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2010-10-01 12:20:38 +0200
committerJay Berkenbilt <ejb@ql.org>2010-10-01 12:20:38 +0200
commit9f444ffef3c11201d0a460b14b6234d3319ce861 (patch)
treee9d89e8e9bc440b0ea2df3963833158d6dfdf866 /include
parent359999a59cc1befdc94115d3cd17cb95a0ebdb49 (diff)
downloadqpdf-9f444ffef3c11201d0a460b14b6234d3319ce861.tar.zst
add QPDF::processMemoryFile and API additions to support it
git-svn-id: svn+q:///qpdf/trunk@1034 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/Buffer.hh12
-rw-r--r--include/qpdf/QPDF.hh15
2 files changed, 24 insertions, 3 deletions
diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh
index a5ad22cb..09d86996 100644
--- a/include/qpdf/Buffer.hh
+++ b/include/qpdf/Buffer.hh
@@ -15,8 +15,17 @@ class Buffer
public:
QPDF_DLL
Buffer();
+
+ // Create a Buffer object whose memory is owned by the class and
+ // will be freed when the Buffer object is destroyed.
QPDF_DLL
Buffer(unsigned long size);
+
+ // Create a Buffer object whose memory is owned by the caller and
+ // will not be freed when the Buffer is destroyed.
+ QPDF_DLL
+ Buffer(unsigned char* buf, unsigned long size);
+
QPDF_DLL
Buffer(Buffer const&);
QPDF_DLL
@@ -31,10 +40,11 @@ class Buffer
unsigned char* getBuffer();
private:
- void init(unsigned long size);
+ void init(unsigned long size, unsigned char* buf, bool own_memory);
void copy(Buffer const&);
void destroy();
+ bool own_memory;
unsigned long size;
unsigned char* buf;
};
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh
index 71e8590e..241a45de 100644
--- a/include/qpdf/QPDF.hh
+++ b/include/qpdf/QPDF.hh
@@ -50,6 +50,15 @@ class QPDF
QPDF_DLL
void processFile(char const* filename, char const* password = 0);
+ // Parse a PDF file loaded into a memory buffer. This works
+ // exactly like processFile except that the PDF file is in memory
+ // instead of on disk. The description appears in any warning or
+ // error message in place of the file name.
+ QPDF_DLL
+ void processMemoryFile(char const* description,
+ char const* buf, size_t length,
+ char const* password = 0);
+
// Parameter settings
// If true, ignore any cross-reference streams in a hybrid file
@@ -362,7 +371,8 @@ class QPDF
class BufferInputSource: public InputSource
{
public:
- BufferInputSource(std::string const& description, Buffer* buf);
+ BufferInputSource(std::string const& description, Buffer* buf,
+ bool own_memory = false);
virtual ~BufferInputSource();
virtual std::string const& getName() const;
virtual off_t tell();
@@ -372,6 +382,7 @@ class QPDF
virtual void unreadCh(char ch);
private:
+ bool own_memory;
std::string description;
Buffer* buf;
off_t cur_offset;
@@ -410,7 +421,7 @@ class QPDF
off_t end_after_space;
};
- void parse();
+ void parse(char const* password);
void warn(QPDFExc const& e);
void setTrailer(QPDFObjectHandle obj);
void read_xref(off_t offset);