diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-07-21 15:00:06 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-07-21 15:06:10 +0200 |
commit | 6bbea4baa0c06b39b1b71f1aa6fc276789296556 (patch) | |
tree | 62198136a609c86029d124323be9e2ea72f88d9a /libqpdf/BufferInputSource.cc | |
parent | f3e267fce28c58039789379ba3488ad12c20a7f6 (diff) | |
download | qpdf-6bbea4baa0c06b39b1b71f1aa6fc276789296556.tar.zst |
Implement QPDFObjectHandle::parse
Move object parsing code from QPDF to QPDFObjectHandle and
parameterize the parts of it that are specific to a QPDF object.
Provide a version that can't handle indirect objects and that can be
called on an arbitrary string.
A side effect of this change is that the offset used when reporting
invalid stream length has changed, but since the new value seems like
a better value than the old one, the test suite has been updated
rather than making the code backward compatible. This only effects
the offset reported for invalid streams that lack /Length or have an
invalid /Length key.
Updated some test code and exmaples to use QPDFObjectHandle::parse.
Supporting changes include adding a BufferInputSource constructor that
takes a string.
Diffstat (limited to 'libqpdf/BufferInputSource.cc')
-rw-r--r-- | libqpdf/BufferInputSource.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libqpdf/BufferInputSource.cc b/libqpdf/BufferInputSource.cc index 6909dce2..03439955 100644 --- a/libqpdf/BufferInputSource.cc +++ b/libqpdf/BufferInputSource.cc @@ -11,6 +11,18 @@ BufferInputSource::BufferInputSource(std::string const& description, { } +BufferInputSource::BufferInputSource(std::string const& description, + std::string const& contents) : + own_memory(true), + description(description), + buf(0), + cur_offset(0) +{ + this->buf = new Buffer(contents.length()); + unsigned char* bp = buf->getBuffer(); + memcpy(bp, (char*)contents.c_str(), contents.length()); +} + BufferInputSource::~BufferInputSource() { if (own_memory) |