2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDF_Array.hh>
|
2009-09-26 18:36:04 +00:00
|
|
|
#include <stdexcept>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& items) :
|
|
|
|
items(items)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QPDF_Array::~QPDF_Array()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-06 13:32:08 +00:00
|
|
|
void
|
|
|
|
QPDF_Array::releaseResolved()
|
|
|
|
{
|
|
|
|
for (std::vector<QPDFObjectHandle>::iterator iter = this->items.begin();
|
|
|
|
iter != this->items.end(); ++iter)
|
|
|
|
{
|
|
|
|
QPDFObjectHandle::ReleaseResolver::releaseResolved(*iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
std::string
|
|
|
|
QPDF_Array::unparse()
|
|
|
|
{
|
|
|
|
std::string result = "[ ";
|
|
|
|
for (std::vector<QPDFObjectHandle>::iterator iter = this->items.begin();
|
|
|
|
iter != this->items.end(); ++iter)
|
|
|
|
{
|
|
|
|
result += (*iter).unparse();
|
|
|
|
result += " ";
|
|
|
|
}
|
|
|
|
result += "]";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDF_Array::getNItems() const
|
|
|
|
{
|
|
|
|
return this->items.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPDFObjectHandle
|
|
|
|
QPDF_Array::getItem(int n) const
|
|
|
|
{
|
|
|
|
if ((n < 0) || (n >= (int)this->items.size()))
|
|
|
|
{
|
2009-09-26 18:36:04 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"INTERNAL ERROR: bounds array accessing QPDF_Array element");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
return this->items[n];
|
|
|
|
}
|
|
|
|
|
2011-08-10 17:33:58 +00:00
|
|
|
std::vector<QPDFObjectHandle> const&
|
|
|
|
QPDF_Array::getAsVector() const
|
|
|
|
{
|
|
|
|
return this->items;
|
|
|
|
}
|
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
void
|
|
|
|
QPDF_Array::setItem(int n, QPDFObjectHandle const& oh)
|
|
|
|
{
|
|
|
|
// Call getItem for bounds checking
|
|
|
|
(void) getItem(n);
|
|
|
|
this->items[n] = oh;
|
|
|
|
}
|