mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-23 03:18:59 +00:00
Refactor QPDF_Array in preparation for using SparseOHArray
This commit is contained in:
parent
e83f3308fb
commit
a89d8a0677
@ -722,7 +722,7 @@ QPDFObjectHandle::getArrayAsVector()
|
|||||||
std::vector<QPDFObjectHandle> result;
|
std::vector<QPDFObjectHandle> result;
|
||||||
if (isArray())
|
if (isArray())
|
||||||
{
|
{
|
||||||
result = dynamic_cast<QPDF_Array*>(m->obj.getPointer())->getAsVector();
|
dynamic_cast<QPDF_Array*>(m->obj.getPointer())->getAsVector(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <qpdf/QIntC.hh>
|
#include <qpdf/QIntC.hh>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& items) :
|
QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& v)
|
||||||
items(items)
|
|
||||||
{
|
{
|
||||||
|
setFromVector(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDF_Array::~QPDF_Array()
|
QPDF_Array::~QPDF_Array()
|
||||||
@ -26,10 +26,10 @@ std::string
|
|||||||
QPDF_Array::unparse()
|
QPDF_Array::unparse()
|
||||||
{
|
{
|
||||||
std::string result = "[ ";
|
std::string result = "[ ";
|
||||||
for (std::vector<QPDFObjectHandle>::iterator iter = this->items.begin();
|
size_t size = this->items.size();
|
||||||
iter != this->items.end(); ++iter)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
result += (*iter).unparse();
|
result += this->items.at(i).unparse();
|
||||||
result += " ";
|
result += " ";
|
||||||
}
|
}
|
||||||
result += "]";
|
result += "]";
|
||||||
@ -40,10 +40,10 @@ JSON
|
|||||||
QPDF_Array::getJSON()
|
QPDF_Array::getJSON()
|
||||||
{
|
{
|
||||||
JSON j = JSON::makeArray();
|
JSON j = JSON::makeArray();
|
||||||
for (std::vector<QPDFObjectHandle>::iterator iter = this->items.begin();
|
size_t size = this->items.size();
|
||||||
iter != this->items.end(); ++iter)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
j.addArrayElement((*iter).getJSON());
|
j.addArrayElement(this->items.at(i).getJSON());
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
@ -85,10 +85,14 @@ QPDF_Array::getItem(int n) const
|
|||||||
return this->items.at(QIntC::to_size(n));
|
return this->items.at(QIntC::to_size(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<QPDFObjectHandle> const&
|
void
|
||||||
QPDF_Array::getAsVector() const
|
QPDF_Array::getAsVector(std::vector<QPDFObjectHandle>& v) const
|
||||||
{
|
{
|
||||||
return this->items;
|
size_t size = this->items.size();
|
||||||
|
for (size_t i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
v.push_back(this->items.at(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -100,9 +104,14 @@ QPDF_Array::setItem(int n, QPDFObjectHandle const& oh)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDF_Array::setFromVector(std::vector<QPDFObjectHandle> const& items)
|
QPDF_Array::setFromVector(std::vector<QPDFObjectHandle> const& v)
|
||||||
{
|
{
|
||||||
this->items = items;
|
this->items.clear();
|
||||||
|
for (std::vector<QPDFObjectHandle>::const_iterator iter = v.begin();
|
||||||
|
iter != v.end(); ++iter)
|
||||||
|
{
|
||||||
|
this->items.push_back(*iter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -19,7 +19,7 @@ class QPDF_Array: public QPDFObject
|
|||||||
|
|
||||||
int getNItems() const;
|
int getNItems() const;
|
||||||
QPDFObjectHandle getItem(int n) const;
|
QPDFObjectHandle getItem(int n) const;
|
||||||
std::vector<QPDFObjectHandle> const& getAsVector() const;
|
void getAsVector(std::vector<QPDFObjectHandle>&) const;
|
||||||
|
|
||||||
void setItem(int, QPDFObjectHandle const&);
|
void setItem(int, QPDFObjectHandle const&);
|
||||||
void setFromVector(std::vector<QPDFObjectHandle> const& items);
|
void setFromVector(std::vector<QPDFObjectHandle> const& items);
|
||||||
|
Loading…
Reference in New Issue
Block a user