From b6bdc0f5950287c1c9e76115bdec230dcf99b964 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 22 Jun 2012 09:46:33 -0400 Subject: Add factory methods for creating empty arrays and dictionaries. Also updated pdf_from_scratch test driver to use the new factories, and made some cosmetic improvements and documentation updates for the emptyPDF() method. --- libqpdf/QPDF.cc | 2 +- libqpdf/QPDFObjectHandle.cc | 12 ++++++++++++ libqpdf/QUtil.cc | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index b0a8741c..5f1ab48c 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -370,7 +370,7 @@ QPDF::processMemoryFile(char const* description, void QPDF::emptyPDF() { - processMemoryFile("empty file", EMPTY_PDF, strlen(EMPTY_PDF)); + processMemoryFile("empty PDF", EMPTY_PDF, strlen(EMPTY_PDF)); } void diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 1c2481f8..d0d911f7 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -615,12 +615,24 @@ QPDFObjectHandle::newString(std::string const& str) return QPDFObjectHandle(new QPDF_String(str)); } +QPDFObjectHandle +QPDFObjectHandle::newArray() +{ + return newArray(std::vector()); +} + QPDFObjectHandle QPDFObjectHandle::newArray(std::vector const& items) { return QPDFObjectHandle(new QPDF_Array(items)); } +QPDFObjectHandle +QPDFObjectHandle::newDictionary() +{ + return newDictionary(std::map()); +} + QPDFObjectHandle QPDFObjectHandle::newDictionary( std::map const& items) diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 3c3bf011..bdb73f54 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -1,5 +1,8 @@ -#include +// Include qpdf-config.h first so off_t is gauaranteed to have the right size. #include + +#include + #include #include #include -- cgit v1.2.3-54-g00ecf