Commit ef6d9e34 authored by Albert Astals Cid's avatar Albert Astals Cid

Array: introduce get variant that returns also the Ref it is one

Similar to the new one in Dict
parent 11d6103d
......@@ -77,6 +77,20 @@ Object Array::get(int i, int recursion) const {
return elems[i].fetch(xref, recursion);
}
Object Array::get(int i, Ref *returnRef, int recursion) const
{
if (i < 0 || std::size_t(i) >= elems.size()) {
*returnRef = { 0, 0 };
return Object(objNull);
}
if (elems[i].getType() == objRef) {
*returnRef = elems[i].getRef();
} else {
*returnRef = { 0, 0 };
}
return elems[i].fetch(xref, recursion);
}
const Object &Array::getNF(int i) const {
if (i < 0 || std::size_t(i) >= elems.size()) {
static Object nullObj(objNull);
......
......@@ -68,6 +68,7 @@ public:
// Accessors.
Object get(int i, int recursion = 0) const;
Object get(int i, Ref *returnRef, int recursion = 0) const;
const Object &getNF(int i) const;
bool getString(int i, GooString *string) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment