aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_Array.cc
diff options
context:
space:
mode:
authorTobias Hoffmann <thobi@worker>2012-06-18 22:38:59 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-20 21:29:44 +0200
commitdb7474e0facd82577edfc1cc4883bce3fa588584 (patch)
treeb1f472ddadab0c95747b3963d84682f9d5b17b06 /libqpdf/QPDF_Array.cc
parentb2e681893503d7f51679b96a3b7be580bb6d362b (diff)
downloadqpdf-db7474e0facd82577edfc1cc4883bce3fa588584.tar.zst
Added additional array mutators
Added methods to append to arrays, insert items into arrays, and replace array contents with a vector of items.
Diffstat (limited to 'libqpdf/QPDF_Array.cc')
-rw-r--r--libqpdf/QPDF_Array.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc
index 91e34eec..9f720287 100644
--- a/libqpdf/QPDF_Array.cc
+++ b/libqpdf/QPDF_Array.cc
@@ -64,3 +64,35 @@ QPDF_Array::setItem(int n, QPDFObjectHandle const& oh)
(void) getItem(n);
this->items[n] = oh;
}
+
+void
+QPDF_Array::setFromVector(std::vector<QPDFObjectHandle> const& items)
+{
+ this->items = items;
+}
+
+void
+QPDF_Array::insertItem(int at, QPDFObjectHandle const& item)
+{
+ // As special case, also allow insert beyond the end
+ if ((at < 0) || (at > (int)this->items.size()))
+ {
+ throw std::logic_error(
+ "INTERNAL ERROR: bounds error accessing QPDF_Array element");
+ }
+ this->items.insert(this->items.begin() + at, item);
+}
+
+void
+QPDF_Array::appendItem(QPDFObjectHandle const& item)
+{
+ this->items.push_back(item);
+}
+
+void
+QPDF_Array::eraseItem(int at)
+{
+ // Call getItem for bounds checking
+ (void) getItem(at);
+ this->items.erase(this->items.begin() + at);
+}