mirror of
https://github.com/qpdf/qpdf.git
synced 2024-05-29 08:20:53 +00:00
PointerHolder: deprecate getPointer() and getRefcount()
Use get() and use_count() instead. Add #define NO_POINTERHOLDER_DEPRECATION to remove deprecation markers for these only. This commit also removes all deprecated PointerHolder API calls from qpdf's code except in PointerHolder's test suite, which must continue to test the deprecated APIs.
This commit is contained in:
parent
f727bc9443
commit
9044a24097
|
@ -1,5 +1,10 @@
|
||||||
2022-02-04 Jay Berkenbilt <ejb@ql.org>
|
2022-02-04 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* PointerHolder: deprecate getPointer() and getRefcount(). If you
|
||||||
|
don't want to disable deprecation warnings in general but are not
|
||||||
|
ready to tackle this change yet, you can define
|
||||||
|
NO_POINTERHOLDER_DEPRECATION to suppress those.
|
||||||
|
|
||||||
* PointerHolder: add a get() method and a use_count() method for
|
* PointerHolder: add a get() method and a use_count() method for
|
||||||
compatibility with std::shared_ptr. In qpdf 11, qpdf's APIs will
|
compatibility with std::shared_ptr. In qpdf 11, qpdf's APIs will
|
||||||
switch to using std::shared_ptr instead of PointerHolder, though
|
switch to using std::shared_ptr instead of PointerHolder, though
|
||||||
|
|
|
@ -12,7 +12,7 @@ int main(int argc, char **argv)
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
QUtil::read_file_into_memory(argv[i], file_buf, size);
|
QUtil::read_file_into_memory(argv[i], file_buf, size);
|
||||||
LLVMFuzzerTestOneInput(
|
LLVMFuzzerTestOneInput(
|
||||||
reinterpret_cast<unsigned char*>(file_buf.getPointer()), size);
|
reinterpret_cast<unsigned char*>(file_buf.get()), size);
|
||||||
std::cout << argv[i] << " successful" << std::endl;
|
std::cout << argv[i] << " successful" << std::endl;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -135,14 +135,23 @@ class PointerHolder
|
||||||
|
|
||||||
// NOTE: The pointer returned by getPointer turns into a pumpkin
|
// NOTE: The pointer returned by getPointer turns into a pumpkin
|
||||||
// when the last PointerHolder that contains it disappears.
|
// when the last PointerHolder that contains it disappears.
|
||||||
|
#ifndef NO_POINTERHOLDER_DEPRECATION
|
||||||
|
[[deprecated("use PointerHolder<T>::get() instead of getPointer()")]]
|
||||||
|
#endif
|
||||||
T* getPointer()
|
T* getPointer()
|
||||||
{
|
{
|
||||||
return this->data->pointer;
|
return this->data->pointer;
|
||||||
}
|
}
|
||||||
|
#ifndef NO_POINTERHOLDER_DEPRECATION
|
||||||
|
[[deprecated("use PointerHolder<T>::get() instead of getPointer()")]]
|
||||||
|
#endif
|
||||||
T const* getPointer() const
|
T const* getPointer() const
|
||||||
{
|
{
|
||||||
return this->data->pointer;
|
return this->data->pointer;
|
||||||
}
|
}
|
||||||
|
#ifndef NO_POINTERHOLDER_DEPRECATION
|
||||||
|
[[deprecated("use use_count() instead of getRefcount()")]]
|
||||||
|
#endif
|
||||||
int getRefcount() const
|
int getRefcount() const
|
||||||
{
|
{
|
||||||
return this->data->refcount;
|
return this->data->refcount;
|
||||||
|
|
|
@ -24,7 +24,7 @@ ClosedFileInputSource::~ClosedFileInputSource()
|
||||||
void
|
void
|
||||||
ClosedFileInputSource::before()
|
ClosedFileInputSource::before()
|
||||||
{
|
{
|
||||||
if (0 == this->m->fis.getPointer())
|
if (0 == this->m->fis.get())
|
||||||
{
|
{
|
||||||
this->m->fis = new FileInputSource();
|
this->m->fis = new FileInputSource();
|
||||||
this->m->fis->setFilename(this->m->filename.c_str());
|
this->m->fis->setFilename(this->m->filename.c_str());
|
||||||
|
@ -81,7 +81,7 @@ void
|
||||||
ClosedFileInputSource::rewind()
|
ClosedFileInputSource::rewind()
|
||||||
{
|
{
|
||||||
this->m->offset = 0;
|
this->m->offset = 0;
|
||||||
if (this->m->fis.getPointer())
|
if (this->m->fis.get())
|
||||||
{
|
{
|
||||||
this->m->fis->rewind();
|
this->m->fis->rewind();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ void
|
||||||
ClosedFileInputSource::stayOpen(bool val)
|
ClosedFileInputSource::stayOpen(bool val)
|
||||||
{
|
{
|
||||||
this->m->stay_open = val;
|
this->m->stay_open = val;
|
||||||
if ((! val) && this->m->fis.getPointer())
|
if ((! val) && this->m->fis.get())
|
||||||
{
|
{
|
||||||
after();
|
after();
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ std::string JSON::JSON_null::unparse(size_t) const
|
||||||
std::string
|
std::string
|
||||||
JSON::unparse() const
|
JSON::unparse() const
|
||||||
{
|
{
|
||||||
if (0 == this->m->value.getPointer())
|
if (0 == this->m->value.get())
|
||||||
{
|
{
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
@ -219,13 +219,13 @@ JSON
|
||||||
JSON::addDictionaryMember(std::string const& key, JSON const& val)
|
JSON::addDictionaryMember(std::string const& key, JSON const& val)
|
||||||
{
|
{
|
||||||
JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(
|
JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(
|
||||||
this->m->value.getPointer());
|
this->m->value.get());
|
||||||
if (0 == obj)
|
if (0 == obj)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"JSON::addDictionaryMember called on non-dictionary");
|
"JSON::addDictionaryMember called on non-dictionary");
|
||||||
}
|
}
|
||||||
if (val.m->value.getPointer())
|
if (val.m->value.get())
|
||||||
{
|
{
|
||||||
obj->members[encode_string(key)] = val.m->value;
|
obj->members[encode_string(key)] = val.m->value;
|
||||||
}
|
}
|
||||||
|
@ -246,12 +246,12 @@ JSON
|
||||||
JSON::addArrayElement(JSON const& val)
|
JSON::addArrayElement(JSON const& val)
|
||||||
{
|
{
|
||||||
JSON_array* arr = dynamic_cast<JSON_array*>(
|
JSON_array* arr = dynamic_cast<JSON_array*>(
|
||||||
this->m->value.getPointer());
|
this->m->value.get());
|
||||||
if (0 == arr)
|
if (0 == arr)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("JSON::addArrayElement called on non-array");
|
throw std::runtime_error("JSON::addArrayElement called on non-array");
|
||||||
}
|
}
|
||||||
if (val.m->value.getPointer())
|
if (val.m->value.get())
|
||||||
{
|
{
|
||||||
arr->elements.push_back(val.m->value);
|
arr->elements.push_back(val.m->value);
|
||||||
}
|
}
|
||||||
|
@ -302,20 +302,20 @@ bool
|
||||||
JSON::isArray() const
|
JSON::isArray() const
|
||||||
{
|
{
|
||||||
return nullptr != dynamic_cast<JSON_array const*>(
|
return nullptr != dynamic_cast<JSON_array const*>(
|
||||||
this->m->value.getPointer());
|
this->m->value.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JSON::isDictionary() const
|
JSON::isDictionary() const
|
||||||
{
|
{
|
||||||
return nullptr != dynamic_cast<JSON_dictionary const*>(
|
return nullptr != dynamic_cast<JSON_dictionary const*>(
|
||||||
this->m->value.getPointer());
|
this->m->value.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JSON::getString(std::string& utf8) const
|
JSON::getString(std::string& utf8) const
|
||||||
{
|
{
|
||||||
auto v = dynamic_cast<JSON_string const*>(this->m->value.getPointer());
|
auto v = dynamic_cast<JSON_string const*>(this->m->value.get());
|
||||||
if (v == nullptr)
|
if (v == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -327,7 +327,7 @@ JSON::getString(std::string& utf8) const
|
||||||
bool
|
bool
|
||||||
JSON::getNumber(std::string& value) const
|
JSON::getNumber(std::string& value) const
|
||||||
{
|
{
|
||||||
auto v = dynamic_cast<JSON_number const*>(this->m->value.getPointer());
|
auto v = dynamic_cast<JSON_number const*>(this->m->value.get());
|
||||||
if (v == nullptr)
|
if (v == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -339,7 +339,7 @@ JSON::getNumber(std::string& value) const
|
||||||
bool
|
bool
|
||||||
JSON::getBool(bool& value) const
|
JSON::getBool(bool& value) const
|
||||||
{
|
{
|
||||||
auto v = dynamic_cast<JSON_bool const*>(this->m->value.getPointer());
|
auto v = dynamic_cast<JSON_bool const*>(this->m->value.get());
|
||||||
if (v == nullptr)
|
if (v == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -351,7 +351,7 @@ JSON::getBool(bool& value) const
|
||||||
bool
|
bool
|
||||||
JSON::isNull() const
|
JSON::isNull() const
|
||||||
{
|
{
|
||||||
if (dynamic_cast<JSON_null const*>(this->m->value.getPointer()))
|
if (dynamic_cast<JSON_null const*>(this->m->value.get()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ bool
|
||||||
JSON::forEachDictItem(
|
JSON::forEachDictItem(
|
||||||
std::function<void(std::string const& key, JSON value)> fn) const
|
std::function<void(std::string const& key, JSON value)> fn) const
|
||||||
{
|
{
|
||||||
auto v = dynamic_cast<JSON_dictionary const*>(this->m->value.getPointer());
|
auto v = dynamic_cast<JSON_dictionary const*>(this->m->value.get());
|
||||||
if (v == nullptr)
|
if (v == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -377,7 +377,7 @@ JSON::forEachDictItem(
|
||||||
bool
|
bool
|
||||||
JSON::forEachArrayItem(std::function<void(JSON value)> fn) const
|
JSON::forEachArrayItem(std::function<void(JSON value)> fn) const
|
||||||
{
|
{
|
||||||
auto v = dynamic_cast<JSON_array const*>(this->m->value.getPointer());
|
auto v = dynamic_cast<JSON_array const*>(this->m->value.get());
|
||||||
if (v == nullptr)
|
if (v == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -392,8 +392,8 @@ JSON::forEachArrayItem(std::function<void(JSON value)> fn) const
|
||||||
bool
|
bool
|
||||||
JSON::checkSchema(JSON schema, std::list<std::string>& errors)
|
JSON::checkSchema(JSON schema, std::list<std::string>& errors)
|
||||||
{
|
{
|
||||||
return checkSchemaInternal(this->m->value.getPointer(),
|
return checkSchemaInternal(this->m->value.get(),
|
||||||
schema.m->value.getPointer(),
|
schema.m->value.get(),
|
||||||
0, errors, "");
|
0, errors, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +401,8 @@ bool
|
||||||
JSON::checkSchema(JSON schema, unsigned long flags,
|
JSON::checkSchema(JSON schema, unsigned long flags,
|
||||||
std::list<std::string>& errors)
|
std::list<std::string>& errors)
|
||||||
{
|
{
|
||||||
return checkSchemaInternal(this->m->value.getPointer(),
|
return checkSchemaInternal(this->m->value.get(),
|
||||||
schema.m->value.getPointer(),
|
schema.m->value.get(),
|
||||||
flags, errors, "");
|
flags, errors, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,12 +452,12 @@ JSON::checkSchemaInternal(JSON_value* this_v, JSON_value* sch_v,
|
||||||
|
|
||||||
if (sch_dict && (! pattern_key.empty()))
|
if (sch_dict && (! pattern_key.empty()))
|
||||||
{
|
{
|
||||||
auto pattern_schema = sch_dict->members[pattern_key].getPointer();
|
auto pattern_schema = sch_dict->members[pattern_key].get();
|
||||||
for (auto const& iter: this_dict->members)
|
for (auto const& iter: this_dict->members)
|
||||||
{
|
{
|
||||||
std::string const& key = iter.first;
|
std::string const& key = iter.first;
|
||||||
checkSchemaInternal(
|
checkSchemaInternal(
|
||||||
this_dict->members[key].getPointer(), pattern_schema,
|
this_dict->members[key].get(), pattern_schema,
|
||||||
flags, errors, prefix + "." + key);
|
flags, errors, prefix + "." + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,8 +469,8 @@ JSON::checkSchemaInternal(JSON_value* this_v, JSON_value* sch_v,
|
||||||
if (this_dict->members.count(key))
|
if (this_dict->members.count(key))
|
||||||
{
|
{
|
||||||
checkSchemaInternal(
|
checkSchemaInternal(
|
||||||
this_dict->members[key].getPointer(),
|
this_dict->members[key].get(),
|
||||||
iter.second.getPointer(),
|
iter.second.get(),
|
||||||
flags, errors, prefix + "." + key);
|
flags, errors, prefix + "." + key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -523,8 +523,8 @@ JSON::checkSchemaInternal(JSON_value* this_v, JSON_value* sch_v,
|
||||||
iter != this_arr->elements.end(); ++iter, ++i)
|
iter != this_arr->elements.end(); ++iter, ++i)
|
||||||
{
|
{
|
||||||
checkSchemaInternal(
|
checkSchemaInternal(
|
||||||
(*iter).getPointer(),
|
(*iter).get(),
|
||||||
sch_arr->elements.at(0).getPointer(),
|
sch_arr->elements.at(0).get(),
|
||||||
flags, errors, prefix + "." + QUtil::int_to_string(i));
|
flags, errors, prefix + "." + QUtil::int_to_string(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1067,7 @@ JSONParser::handleToken()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((item.getPointer() == nullptr) == (delimiter == '\0'))
|
if ((item.get() == nullptr) == (delimiter == '\0'))
|
||||||
{
|
{
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"JSONParser::handleToken: logic error: exactly one of item"
|
"JSONParser::handleToken: logic error: exactly one of item"
|
||||||
|
@ -1076,7 +1076,7 @@ JSONParser::handleToken()
|
||||||
|
|
||||||
// See whether what we have is allowed at this point.
|
// See whether what we have is allowed at this point.
|
||||||
|
|
||||||
if (item.getPointer())
|
if (item.get())
|
||||||
{
|
{
|
||||||
switch (parser_state)
|
switch (parser_state)
|
||||||
{
|
{
|
||||||
|
@ -1213,7 +1213,7 @@ JSONParser::handleToken()
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"JSONParser::handleToken: unexpected delimiter in transition");
|
"JSONParser::handleToken: unexpected delimiter in transition");
|
||||||
}
|
}
|
||||||
else if (item.getPointer())
|
else if (item.get())
|
||||||
{
|
{
|
||||||
PointerHolder<JSON> tos;
|
PointerHolder<JSON> tos;
|
||||||
if (! stack.empty())
|
if (! stack.empty())
|
||||||
|
@ -1259,7 +1259,7 @@ JSONParser::handleToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for next token
|
// Prepare for next token
|
||||||
if (item.getPointer())
|
if (item.get())
|
||||||
{
|
{
|
||||||
if (item->isDictionary())
|
if (item->isDictionary())
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ Pl_Buffer::~Pl_Buffer()
|
||||||
void
|
void
|
||||||
Pl_Buffer::write(unsigned char* buf, size_t len)
|
Pl_Buffer::write(unsigned char* buf, size_t len)
|
||||||
{
|
{
|
||||||
if (this->m->data.getPointer() == 0)
|
if (this->m->data.get() == 0)
|
||||||
{
|
{
|
||||||
this->m->data = new Buffer(len);
|
this->m->data = new Buffer(len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
|
||||||
static int const BUF_SIZE = 65536;
|
static int const BUF_SIZE = 65536;
|
||||||
PointerHolder<unsigned char> outbuffer_ph(
|
PointerHolder<unsigned char> outbuffer_ph(
|
||||||
true, new unsigned char[BUF_SIZE]);
|
true, new unsigned char[BUF_SIZE]);
|
||||||
unsigned char* outbuffer = outbuffer_ph.getPointer();
|
unsigned char* outbuffer = outbuffer_ph.get();
|
||||||
jpeg_pipeline_dest(cinfo, outbuffer, BUF_SIZE, this->getNext());
|
jpeg_pipeline_dest(cinfo, outbuffer, BUF_SIZE, this->getNext());
|
||||||
|
|
||||||
cinfo->image_width = this->m->image_width;
|
cinfo->image_width = this->m->image_width;
|
||||||
|
|
|
@ -37,7 +37,7 @@ Pl_Flate::Members::Members(size_t out_bufsize,
|
||||||
zstream.opaque = 0;
|
zstream.opaque = 0;
|
||||||
zstream.next_in = 0;
|
zstream.next_in = 0;
|
||||||
zstream.avail_in = 0;
|
zstream.avail_in = 0;
|
||||||
zstream.next_out = this->outbuf.getPointer();
|
zstream.next_out = this->outbuf.get();
|
||||||
zstream.avail_out = QIntC::to_uint(out_bufsize);
|
zstream.avail_out = QIntC::to_uint(out_bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ Pl_Flate::warn(char const* msg, int code)
|
||||||
void
|
void
|
||||||
Pl_Flate::write(unsigned char* data, size_t len)
|
Pl_Flate::write(unsigned char* data, size_t len)
|
||||||
{
|
{
|
||||||
if (this->m->outbuf.getPointer() == 0)
|
if (this->m->outbuf.get() == 0)
|
||||||
{
|
{
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
this->identifier +
|
this->identifier +
|
||||||
|
@ -208,8 +208,8 @@ Pl_Flate::handleData(unsigned char* data, size_t len, int flush)
|
||||||
QIntC::to_ulong(this->m->out_bufsize - zstream.avail_out);
|
QIntC::to_ulong(this->m->out_bufsize - zstream.avail_out);
|
||||||
if (ready > 0)
|
if (ready > 0)
|
||||||
{
|
{
|
||||||
this->getNext()->write(this->m->outbuf.getPointer(), ready);
|
this->getNext()->write(this->m->outbuf.get(), ready);
|
||||||
zstream.next_out = this->m->outbuf.getPointer();
|
zstream.next_out = this->m->outbuf.get();
|
||||||
zstream.avail_out = QIntC::to_uint(this->m->out_bufsize);
|
zstream.avail_out = QIntC::to_uint(this->m->out_bufsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ Pl_Flate::finish()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (this->m->outbuf.getPointer())
|
if (this->m->outbuf.get())
|
||||||
{
|
{
|
||||||
if (this->m->initialized)
|
if (this->m->initialized)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,10 +49,10 @@ Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next,
|
||||||
true, new unsigned char[this->bytes_per_row + 1]);
|
true, new unsigned char[this->bytes_per_row + 1]);
|
||||||
this->buf2 = PointerHolder<unsigned char>(
|
this->buf2 = PointerHolder<unsigned char>(
|
||||||
true, new unsigned char[this->bytes_per_row + 1]);
|
true, new unsigned char[this->bytes_per_row + 1]);
|
||||||
memset(this->buf1.getPointer(), 0, this->bytes_per_row + 1);
|
memset(this->buf1.get(), 0, this->bytes_per_row + 1);
|
||||||
memset(this->buf2.getPointer(), 0, this->bytes_per_row + 1);
|
memset(this->buf2.get(), 0, this->bytes_per_row + 1);
|
||||||
this->cur_row = this->buf1.getPointer();
|
this->cur_row = this->buf1.get();
|
||||||
this->prev_row = this->buf2.getPointer();
|
this->prev_row = this->buf2.get();
|
||||||
|
|
||||||
// number of bytes per incoming row
|
// number of bytes per incoming row
|
||||||
this->incoming = (action == a_encode ?
|
this->incoming = (action == a_encode ?
|
||||||
|
@ -81,7 +81,7 @@ Pl_PNGFilter::write(unsigned char* data, size_t len)
|
||||||
// Swap rows
|
// Swap rows
|
||||||
unsigned char* t = this->prev_row;
|
unsigned char* t = this->prev_row;
|
||||||
this->prev_row = this->cur_row;
|
this->prev_row = this->cur_row;
|
||||||
this->cur_row = t ? t : this->buf2.getPointer();
|
this->cur_row = t ? t : this->buf2.get();
|
||||||
memset(this->cur_row, 0, this->bytes_per_row + 1);
|
memset(this->cur_row, 0, this->bytes_per_row + 1);
|
||||||
left = this->incoming;
|
left = this->incoming;
|
||||||
this->pos = 0;
|
this->pos = 0;
|
||||||
|
@ -269,7 +269,7 @@ Pl_PNGFilter::finish()
|
||||||
processRow();
|
processRow();
|
||||||
}
|
}
|
||||||
this->prev_row = 0;
|
this->prev_row = 0;
|
||||||
this->cur_row = buf1.getPointer();
|
this->cur_row = buf1.get();
|
||||||
this->pos = 0;
|
this->pos = 0;
|
||||||
memset(this->cur_row, 0, this->bytes_per_row + 1);
|
memset(this->cur_row, 0, this->bytes_per_row + 1);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ Pl_RC4::~Pl_RC4()
|
||||||
void
|
void
|
||||||
Pl_RC4::write(unsigned char* data, size_t len)
|
Pl_RC4::write(unsigned char* data, size_t len)
|
||||||
{
|
{
|
||||||
if (this->outbuf.getPointer() == 0)
|
if (this->outbuf.get() == 0)
|
||||||
{
|
{
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
this->identifier +
|
this->identifier +
|
||||||
|
@ -35,9 +35,9 @@ Pl_RC4::write(unsigned char* data, size_t len)
|
||||||
(bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
|
(bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
|
||||||
bytes_left -= bytes;
|
bytes_left -= bytes;
|
||||||
// lgtm[cpp/weak-cryptographic-algorithm]
|
// lgtm[cpp/weak-cryptographic-algorithm]
|
||||||
rc4.process(p, bytes, outbuf.getPointer());
|
rc4.process(p, bytes, outbuf.get());
|
||||||
p += bytes;
|
p += bytes;
|
||||||
getNext()->write(outbuf.getPointer(), bytes);
|
getNext()->write(outbuf.get(), bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(char const* identifier, Pipeline* next,
|
||||||
this->bytes_per_row = bpr & UINT_MAX;
|
this->bytes_per_row = bpr & UINT_MAX;
|
||||||
this->cur_row = PointerHolder<unsigned char>(
|
this->cur_row = PointerHolder<unsigned char>(
|
||||||
true, new unsigned char[this->bytes_per_row]);
|
true, new unsigned char[this->bytes_per_row]);
|
||||||
memset(this->cur_row.getPointer(), 0, this->bytes_per_row);
|
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pl_TIFFPredictor::~Pl_TIFFPredictor()
|
Pl_TIFFPredictor::~Pl_TIFFPredictor()
|
||||||
|
@ -54,20 +54,20 @@ Pl_TIFFPredictor::write(unsigned char* data, size_t len)
|
||||||
while (len >= left)
|
while (len >= left)
|
||||||
{
|
{
|
||||||
// finish off current row
|
// finish off current row
|
||||||
memcpy(this->cur_row.getPointer() + this->pos, data + offset, left);
|
memcpy(this->cur_row.get() + this->pos, data + offset, left);
|
||||||
offset += left;
|
offset += left;
|
||||||
len -= left;
|
len -= left;
|
||||||
|
|
||||||
processRow();
|
processRow();
|
||||||
|
|
||||||
// Prepare for next row
|
// Prepare for next row
|
||||||
memset(this->cur_row.getPointer(), 0, this->bytes_per_row);
|
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
||||||
left = this->bytes_per_row;
|
left = this->bytes_per_row;
|
||||||
this->pos = 0;
|
this->pos = 0;
|
||||||
}
|
}
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
memcpy(this->cur_row.getPointer() + this->pos, data + offset, len);
|
memcpy(this->cur_row.get() + this->pos, data + offset, len);
|
||||||
}
|
}
|
||||||
this->pos += len;
|
this->pos += len;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ Pl_TIFFPredictor::processRow()
|
||||||
QTC::TC("libtests", "Pl_TIFFPredictor processRow",
|
QTC::TC("libtests", "Pl_TIFFPredictor processRow",
|
||||||
(action == a_decode ? 0 : 1));
|
(action == a_decode ? 0 : 1));
|
||||||
BitWriter bw(this->getNext());
|
BitWriter bw(this->getNext());
|
||||||
BitStream in(this->cur_row.getPointer(), this->bytes_per_row);
|
BitStream in(this->cur_row.get(), this->bytes_per_row);
|
||||||
std::vector<long long> prev;
|
std::vector<long long> prev;
|
||||||
for (unsigned int i = 0; i < this->samples_per_pixel; ++i)
|
for (unsigned int i = 0; i < this->samples_per_pixel; ++i)
|
||||||
{
|
{
|
||||||
|
@ -117,6 +117,6 @@ Pl_TIFFPredictor::finish()
|
||||||
processRow();
|
processRow();
|
||||||
}
|
}
|
||||||
this->pos = 0;
|
this->pos = 0;
|
||||||
memset(this->cur_row.getPointer(), 0, this->bytes_per_row);
|
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
||||||
getNext()->finish();
|
getNext()->finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ QPDF::CopiedStreamDataProvider::provideStreamData(
|
||||||
PointerHolder<ForeignStreamData> foreign_data =
|
PointerHolder<ForeignStreamData> foreign_data =
|
||||||
this->foreign_stream_data[QPDFObjGen(objid, generation)];
|
this->foreign_stream_data[QPDFObjGen(objid, generation)];
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (foreign_data.getPointer())
|
if (foreign_data.get())
|
||||||
{
|
{
|
||||||
result = destination_qpdf.pipeForeignStreamData(
|
result = destination_qpdf.pipeForeignStreamData(
|
||||||
foreign_data, pipeline, suppress_warnings, will_retry);
|
foreign_data, pipeline, suppress_warnings, will_retry);
|
||||||
|
@ -256,7 +256,7 @@ QPDF::~QPDF()
|
||||||
iter != this->m->obj_cache.end(); ++iter)
|
iter != this->m->obj_cache.end(); ++iter)
|
||||||
{
|
{
|
||||||
QPDFObject::ObjAccessor::releaseResolved(
|
QPDFObject::ObjAccessor::releaseResolved(
|
||||||
(*iter).second.object.getPointer());
|
(*iter).second.object.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,7 +1507,7 @@ QPDF::fixDanglingReferences(bool force)
|
||||||
{
|
{
|
||||||
QPDF_Array* arr =
|
QPDF_Array* arr =
|
||||||
dynamic_cast<QPDF_Array*>(
|
dynamic_cast<QPDF_Array*>(
|
||||||
QPDFObjectHandle::ObjAccessor::getObject(obj).getPointer());
|
QPDFObjectHandle::ObjAccessor::getObject(obj).get());
|
||||||
arr->addExplicitElementsToList(to_check);
|
arr->addExplicitElementsToList(to_check);
|
||||||
}
|
}
|
||||||
for (std::list<QPDFObjectHandle>::iterator iter = to_check.begin();
|
for (std::list<QPDFObjectHandle>::iterator iter = to_check.begin();
|
||||||
|
@ -1604,7 +1604,7 @@ QPDF::readObject(PointerHolder<InputSource> input,
|
||||||
if (this->m->encp->encrypted && (! in_object_stream))
|
if (this->m->encp->encrypted && (! in_object_stream))
|
||||||
{
|
{
|
||||||
decrypter_ph = new StringDecrypter(this, objid, generation);
|
decrypter_ph = new StringDecrypter(this, objid, generation);
|
||||||
decrypter = decrypter_ph.getPointer();
|
decrypter = decrypter_ph.get();
|
||||||
}
|
}
|
||||||
QPDFObjectHandle object = QPDFObjectHandle::parse(
|
QPDFObjectHandle object = QPDFObjectHandle::parse(
|
||||||
input, this->m->last_object_description,
|
input, this->m->last_object_description,
|
||||||
|
@ -2080,7 +2080,7 @@ QPDF::objectChanged(QPDFObjGen const& og, PointerHolder<QPDFObject>& oph)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (c->second.object.getPointer() != oph.getPointer());
|
return (c->second.object.get() != oph.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerHolder<QPDFObject>
|
PointerHolder<QPDFObject>
|
||||||
|
@ -2230,7 +2230,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
||||||
PointerHolder<InputSource> input = new BufferInputSource(
|
PointerHolder<InputSource> input = new BufferInputSource(
|
||||||
this->m->file->getName() +
|
this->m->file->getName() +
|
||||||
" object stream " + QUtil::int_to_string(obj_stream_number),
|
" object stream " + QUtil::int_to_string(obj_stream_number),
|
||||||
bp.getPointer());
|
bp.get());
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
|
@ -2640,7 +2640,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||||
QPDF_Stream* stream =
|
QPDF_Stream* stream =
|
||||||
dynamic_cast<QPDF_Stream*>(
|
dynamic_cast<QPDF_Stream*>(
|
||||||
QPDFObjectHandle::ObjAccessor::getObject(
|
QPDFObjectHandle::ObjAccessor::getObject(
|
||||||
foreign).getPointer());
|
foreign).get());
|
||||||
if (! stream)
|
if (! stream)
|
||||||
{
|
{
|
||||||
throw std::logic_error("unable to retrieve underlying"
|
throw std::logic_error("unable to retrieve underlying"
|
||||||
|
@ -2649,7 +2649,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||||
PointerHolder<Buffer> stream_buffer =
|
PointerHolder<Buffer> stream_buffer =
|
||||||
stream->getStreamDataBuffer();
|
stream->getStreamDataBuffer();
|
||||||
if ((foreign_stream_qpdf->m->immediate_copy_from) &&
|
if ((foreign_stream_qpdf->m->immediate_copy_from) &&
|
||||||
(stream_buffer.getPointer() == 0))
|
(stream_buffer.get() == 0))
|
||||||
{
|
{
|
||||||
// Pull the stream data into a buffer before attempting
|
// Pull the stream data into a buffer before attempting
|
||||||
// the copy operation. Do it on the source stream so that
|
// the copy operation. Do it on the source stream so that
|
||||||
|
@ -2663,14 +2663,14 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
|
||||||
}
|
}
|
||||||
PointerHolder<QPDFObjectHandle::StreamDataProvider> stream_provider =
|
PointerHolder<QPDFObjectHandle::StreamDataProvider> stream_provider =
|
||||||
stream->getStreamDataProvider();
|
stream->getStreamDataProvider();
|
||||||
if (stream_buffer.getPointer())
|
if (stream_buffer.get())
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDF copy foreign stream with buffer");
|
QTC::TC("qpdf", "QPDF copy foreign stream with buffer");
|
||||||
result.replaceStreamData(stream_buffer,
|
result.replaceStreamData(stream_buffer,
|
||||||
dict.getKey("/Filter"),
|
dict.getKey("/Filter"),
|
||||||
dict.getKey("/DecodeParms"));
|
dict.getKey("/DecodeParms"));
|
||||||
}
|
}
|
||||||
else if (stream_provider.getPointer())
|
else if (stream_provider.get())
|
||||||
{
|
{
|
||||||
// In this case, the remote stream's QPDF must stay in scope.
|
// In this case, the remote stream's QPDF must stay in scope.
|
||||||
QTC::TC("qpdf", "QPDF copy foreign stream with provider");
|
QTC::TC("qpdf", "QPDF copy foreign stream with provider");
|
||||||
|
|
|
@ -903,7 +903,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||||
else if ((from_qpdf != &this->qpdf) && (! from_afdh))
|
else if ((from_qpdf != &this->qpdf) && (! from_afdh))
|
||||||
{
|
{
|
||||||
afdhph = new QPDFAcroFormDocumentHelper(*from_qpdf);
|
afdhph = new QPDFAcroFormDocumentHelper(*from_qpdf);
|
||||||
from_afdh = afdhph.getPointer();
|
from_afdh = afdhph.get();
|
||||||
}
|
}
|
||||||
bool foreign = (from_qpdf != &this->qpdf);
|
bool foreign = (from_qpdf != &this->qpdf);
|
||||||
|
|
||||||
|
|
|
@ -756,7 +756,7 @@ QPDFJob::Config::jobJsonFile(std::string const& parameter)
|
||||||
QUtil::read_file_into_memory(parameter.c_str(), file_buf, size);
|
QUtil::read_file_into_memory(parameter.c_str(), file_buf, size);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
o.initializeFromJson(std::string(file_buf.getPointer(), size), true);
|
o.initializeFromJson(std::string(file_buf.get(), size), true);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -241,14 +241,14 @@ QPDFObjectHandle::releaseResolved()
|
||||||
// destruction. See comments in QPDF::~QPDF().
|
// destruction. See comments in QPDF::~QPDF().
|
||||||
if (isIndirect())
|
if (isIndirect())
|
||||||
{
|
{
|
||||||
if (this->obj.getPointer())
|
if (this->obj.get())
|
||||||
{
|
{
|
||||||
this->obj = 0;
|
this->obj = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPDFObject::ObjAccessor::releaseResolved(this->obj.getPointer());
|
QPDFObject::ObjAccessor::releaseResolved(this->obj.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ QPDFObjectHandle::isBool()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Bool>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Bool>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -329,7 +329,7 @@ QPDFObjectHandle::isDirectNull() const
|
||||||
// Don't call dereference() -- this is a const method, and we know
|
// Don't call dereference() -- this is a const method, and we know
|
||||||
// objid == 0, so there's nothing to resolve.
|
// objid == 0, so there's nothing to resolve.
|
||||||
return (this->initialized && (this->objid == 0) &&
|
return (this->initialized && (this->objid == 0) &&
|
||||||
QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer()));
|
QPDFObjectTypeAccessor<QPDF_Null>::check(obj.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -340,7 +340,7 @@ QPDFObjectHandle::isNull()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Null>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -351,7 +351,7 @@ QPDFObjectHandle::isInteger()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Integer>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Integer>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -362,7 +362,7 @@ QPDFObjectHandle::isReal()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Real>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Real>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -399,7 +399,7 @@ QPDFObjectHandle::isName()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Name>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Name>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -410,7 +410,7 @@ QPDFObjectHandle::isString()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_String>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_String>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -421,7 +421,7 @@ QPDFObjectHandle::isOperator()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Operator>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Operator>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -432,7 +432,7 @@ QPDFObjectHandle::isInlineImage()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_InlineImage>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_InlineImage>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -443,7 +443,7 @@ QPDFObjectHandle::isArray()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Array>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Array>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -454,7 +454,7 @@ QPDFObjectHandle::isDictionary()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Dictionary>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Dictionary>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -465,7 +465,7 @@ QPDFObjectHandle::isStream()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dereference();
|
dereference();
|
||||||
return QPDFObjectTypeAccessor<QPDF_Stream>::check(obj.getPointer());
|
return QPDFObjectTypeAccessor<QPDF_Stream>::check(obj.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -526,7 +526,7 @@ QPDFObjectHandle::getBoolValue()
|
||||||
{
|
{
|
||||||
if (isBool())
|
if (isBool())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Bool*>(obj.getPointer())->getVal();
|
return dynamic_cast<QPDF_Bool*>(obj.get())->getVal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -543,7 +543,7 @@ QPDFObjectHandle::getIntValue()
|
||||||
{
|
{
|
||||||
if (isInteger())
|
if (isInteger())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Integer*>(obj.getPointer())->getVal();
|
return dynamic_cast<QPDF_Integer*>(obj.get())->getVal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -636,7 +636,7 @@ QPDFObjectHandle::getRealValue()
|
||||||
{
|
{
|
||||||
if (isReal())
|
if (isReal())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Real*>(obj.getPointer())->getVal();
|
return dynamic_cast<QPDF_Real*>(obj.get())->getVal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -653,7 +653,7 @@ QPDFObjectHandle::getName()
|
||||||
{
|
{
|
||||||
if (isName())
|
if (isName())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Name*>(obj.getPointer())->getName();
|
return dynamic_cast<QPDF_Name*>(obj.get())->getName();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -670,7 +670,7 @@ QPDFObjectHandle::getStringValue()
|
||||||
{
|
{
|
||||||
if (isString())
|
if (isString())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_String*>(obj.getPointer())->getVal();
|
return dynamic_cast<QPDF_String*>(obj.get())->getVal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -685,7 +685,7 @@ QPDFObjectHandle::getUTF8Value()
|
||||||
{
|
{
|
||||||
if (isString())
|
if (isString())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_String*>(obj.getPointer())->getUTF8Val();
|
return dynamic_cast<QPDF_String*>(obj.get())->getUTF8Val();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -702,7 +702,7 @@ QPDFObjectHandle::getOperatorValue()
|
||||||
{
|
{
|
||||||
if (isOperator())
|
if (isOperator())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Operator*>(obj.getPointer())->getVal();
|
return dynamic_cast<QPDF_Operator*>(obj.get())->getVal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -717,7 +717,7 @@ QPDFObjectHandle::getInlineImageValue()
|
||||||
{
|
{
|
||||||
if (isInlineImage())
|
if (isInlineImage())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_InlineImage*>(obj.getPointer())->getVal();
|
return dynamic_cast<QPDF_InlineImage*>(obj.get())->getVal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -740,7 +740,7 @@ QPDFObjectHandle::getArrayNItems()
|
||||||
{
|
{
|
||||||
if (isArray())
|
if (isArray())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Array*>(obj.getPointer())->getNItems();
|
return dynamic_cast<QPDF_Array*>(obj.get())->getNItems();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -756,7 +756,7 @@ QPDFObjectHandle::getArrayItem(int n)
|
||||||
QPDFObjectHandle result;
|
QPDFObjectHandle result;
|
||||||
if (isArray() && (n < getArrayNItems()) && (n >= 0))
|
if (isArray() && (n < getArrayNItems()) && (n >= 0))
|
||||||
{
|
{
|
||||||
result = dynamic_cast<QPDF_Array*>(obj.getPointer())->getItem(n);
|
result = dynamic_cast<QPDF_Array*>(obj.get())->getItem(n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -869,7 +869,7 @@ QPDFObjectHandle::getArrayAsVector()
|
||||||
std::vector<QPDFObjectHandle> result;
|
std::vector<QPDFObjectHandle> result;
|
||||||
if (isArray())
|
if (isArray())
|
||||||
{
|
{
|
||||||
dynamic_cast<QPDF_Array*>(obj.getPointer())->getAsVector(result);
|
dynamic_cast<QPDF_Array*>(obj.get())->getAsVector(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -887,7 +887,7 @@ QPDFObjectHandle::setArrayItem(int n, QPDFObjectHandle const& item)
|
||||||
if (isArray())
|
if (isArray())
|
||||||
{
|
{
|
||||||
checkOwnership(item);
|
checkOwnership(item);
|
||||||
dynamic_cast<QPDF_Array*>(obj.getPointer())->setItem(n, item);
|
dynamic_cast<QPDF_Array*>(obj.get())->setItem(n, item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -905,7 +905,7 @@ QPDFObjectHandle::setArrayFromVector(std::vector<QPDFObjectHandle> const& items)
|
||||||
{
|
{
|
||||||
checkOwnership(item);
|
checkOwnership(item);
|
||||||
}
|
}
|
||||||
dynamic_cast<QPDF_Array*>(obj.getPointer())->setFromVector(items);
|
dynamic_cast<QPDF_Array*>(obj.get())->setFromVector(items);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -919,7 +919,7 @@ QPDFObjectHandle::insertItem(int at, QPDFObjectHandle const& item)
|
||||||
{
|
{
|
||||||
if (isArray())
|
if (isArray())
|
||||||
{
|
{
|
||||||
dynamic_cast<QPDF_Array*>(obj.getPointer())->insertItem(at, item);
|
dynamic_cast<QPDF_Array*>(obj.get())->insertItem(at, item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -934,7 +934,7 @@ QPDFObjectHandle::appendItem(QPDFObjectHandle const& item)
|
||||||
if (isArray())
|
if (isArray())
|
||||||
{
|
{
|
||||||
checkOwnership(item);
|
checkOwnership(item);
|
||||||
dynamic_cast<QPDF_Array*>(obj.getPointer())->appendItem(item);
|
dynamic_cast<QPDF_Array*>(obj.get())->appendItem(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -948,7 +948,7 @@ QPDFObjectHandle::eraseItem(int at)
|
||||||
{
|
{
|
||||||
if (isArray() && (at < getArrayNItems()) && (at >= 0))
|
if (isArray() && (at < getArrayNItems()) && (at >= 0))
|
||||||
{
|
{
|
||||||
dynamic_cast<QPDF_Array*>(obj.getPointer())->eraseItem(at);
|
dynamic_cast<QPDF_Array*>(obj.get())->eraseItem(at);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -978,7 +978,7 @@ QPDFObjectHandle::hasKey(std::string const& key)
|
||||||
{
|
{
|
||||||
if (isDictionary())
|
if (isDictionary())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_Dictionary*>(obj.getPointer())->hasKey(key);
|
return dynamic_cast<QPDF_Dictionary*>(obj.get())->hasKey(key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -996,7 +996,7 @@ QPDFObjectHandle::getKey(std::string const& key)
|
||||||
if (isDictionary())
|
if (isDictionary())
|
||||||
{
|
{
|
||||||
result = dynamic_cast<QPDF_Dictionary*>(
|
result = dynamic_cast<QPDF_Dictionary*>(
|
||||||
obj.getPointer())->getKey(key);
|
obj.get())->getKey(key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1024,7 +1024,7 @@ QPDFObjectHandle::getKeys()
|
||||||
std::set<std::string> result;
|
std::set<std::string> result;
|
||||||
if (isDictionary())
|
if (isDictionary())
|
||||||
{
|
{
|
||||||
result = dynamic_cast<QPDF_Dictionary*>(obj.getPointer())->getKeys();
|
result = dynamic_cast<QPDF_Dictionary*>(obj.get())->getKeys();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1041,7 +1041,7 @@ QPDFObjectHandle::getDictAsMap()
|
||||||
if (isDictionary())
|
if (isDictionary())
|
||||||
{
|
{
|
||||||
result = dynamic_cast<QPDF_Dictionary*>(
|
result = dynamic_cast<QPDF_Dictionary*>(
|
||||||
obj.getPointer())->getAsMap();
|
obj.get())->getAsMap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1311,7 +1311,7 @@ QPDFObjectHandle::replaceKey(std::string const& key,
|
||||||
{
|
{
|
||||||
checkOwnership(value);
|
checkOwnership(value);
|
||||||
dynamic_cast<QPDF_Dictionary*>(
|
dynamic_cast<QPDF_Dictionary*>(
|
||||||
obj.getPointer())->replaceKey(key, value);
|
obj.get())->replaceKey(key, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1325,7 +1325,7 @@ QPDFObjectHandle::removeKey(std::string const& key)
|
||||||
{
|
{
|
||||||
if (isDictionary())
|
if (isDictionary())
|
||||||
{
|
{
|
||||||
dynamic_cast<QPDF_Dictionary*>(obj.getPointer())->removeKey(key);
|
dynamic_cast<QPDF_Dictionary*>(obj.get())->removeKey(key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1342,7 +1342,7 @@ QPDFObjectHandle::replaceOrRemoveKey(std::string const& key,
|
||||||
{
|
{
|
||||||
checkOwnership(value);
|
checkOwnership(value);
|
||||||
dynamic_cast<QPDF_Dictionary*>(
|
dynamic_cast<QPDF_Dictionary*>(
|
||||||
obj.getPointer())->replaceOrRemoveKey(key, value);
|
obj.get())->replaceOrRemoveKey(key, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1356,35 +1356,35 @@ QPDFObjectHandle
|
||||||
QPDFObjectHandle::getDict()
|
QPDFObjectHandle::getDict()
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getDict();
|
return dynamic_cast<QPDF_Stream*>(obj.get())->getDict();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFObjectHandle::setFilterOnWrite(bool val)
|
QPDFObjectHandle::setFilterOnWrite(bool val)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->setFilterOnWrite(val);
|
dynamic_cast<QPDF_Stream*>(obj.get())->setFilterOnWrite(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
QPDFObjectHandle::getFilterOnWrite()
|
QPDFObjectHandle::getFilterOnWrite()
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getFilterOnWrite();
|
return dynamic_cast<QPDF_Stream*>(obj.get())->getFilterOnWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
QPDFObjectHandle::isDataModified()
|
QPDFObjectHandle::isDataModified()
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->isDataModified();
|
return dynamic_cast<QPDF_Stream*>(obj.get())->isDataModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict)
|
QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceDict(new_dict);
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceDict(new_dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerHolder<Buffer>
|
PointerHolder<Buffer>
|
||||||
|
@ -1392,14 +1392,14 @@ QPDFObjectHandle::getStreamData(qpdf_stream_decode_level_e level)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(
|
return dynamic_cast<QPDF_Stream*>(
|
||||||
obj.getPointer())->getStreamData(level);
|
obj.get())->getStreamData(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerHolder<Buffer>
|
PointerHolder<Buffer>
|
||||||
QPDFObjectHandle::getRawStreamData()
|
QPDFObjectHandle::getRawStreamData()
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getRawStreamData();
|
return dynamic_cast<QPDF_Stream*>(obj.get())->getRawStreamData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -1409,7 +1409,7 @@ QPDFObjectHandle::pipeStreamData(Pipeline* p, bool* filtering_attempted,
|
||||||
bool suppress_warnings, bool will_retry)
|
bool suppress_warnings, bool will_retry)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(obj.getPointer())->pipeStreamData(
|
return dynamic_cast<QPDF_Stream*>(obj.get())->pipeStreamData(
|
||||||
p, filtering_attempted, encode_flags, decode_level,
|
p, filtering_attempted, encode_flags, decode_level,
|
||||||
suppress_warnings, will_retry);
|
suppress_warnings, will_retry);
|
||||||
}
|
}
|
||||||
|
@ -1422,7 +1422,7 @@ QPDFObjectHandle::pipeStreamData(Pipeline* p,
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
bool filtering_attempted;
|
bool filtering_attempted;
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->pipeStreamData(
|
dynamic_cast<QPDF_Stream*>(obj.get())->pipeStreamData(
|
||||||
p, &filtering_attempted, encode_flags, decode_level,
|
p, &filtering_attempted, encode_flags, decode_level,
|
||||||
suppress_warnings, will_retry);
|
suppress_warnings, will_retry);
|
||||||
return filtering_attempted;
|
return filtering_attempted;
|
||||||
|
@ -1455,7 +1455,7 @@ QPDFObjectHandle::replaceStreamData(PointerHolder<Buffer> data,
|
||||||
QPDFObjectHandle const& decode_parms)
|
QPDFObjectHandle const& decode_parms)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||||
data, filter, decode_parms);
|
data, filter, decode_parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ QPDFObjectHandle::replaceStreamData(std::string const& data,
|
||||||
PointerHolder<Buffer> b = new Buffer(data.length());
|
PointerHolder<Buffer> b = new Buffer(data.length());
|
||||||
unsigned char* bp = b->getBuffer();
|
unsigned char* bp = b->getBuffer();
|
||||||
memcpy(bp, data.c_str(), data.length());
|
memcpy(bp, data.c_str(), data.length());
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||||
b, filter, decode_parms);
|
b, filter, decode_parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1478,7 +1478,7 @@ QPDFObjectHandle::replaceStreamData(PointerHolder<StreamDataProvider> provider,
|
||||||
QPDFObjectHandle const& decode_parms)
|
QPDFObjectHandle const& decode_parms)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||||
provider, filter, decode_parms);
|
provider, filter, decode_parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,7 +1522,7 @@ QPDFObjectHandle::replaceStreamData(std::function<void(Pipeline*)> provider,
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
PointerHolder<StreamDataProvider> sdp = new FunctionProvider(provider);
|
PointerHolder<StreamDataProvider> sdp = new FunctionProvider(provider);
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||||
sdp, filter, decode_parms);
|
sdp, filter, decode_parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1534,7 +1534,7 @@ QPDFObjectHandle::replaceStreamData(
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
PointerHolder<StreamDataProvider> sdp = new FunctionProvider(provider);
|
PointerHolder<StreamDataProvider> sdp = new FunctionProvider(provider);
|
||||||
dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||||
sdp, filter, decode_parms);
|
sdp, filter, decode_parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1787,7 +1787,7 @@ QPDFObjectHandle::unparseBinary()
|
||||||
if (this->isString())
|
if (this->isString())
|
||||||
{
|
{
|
||||||
return dynamic_cast<QPDF_String*>(
|
return dynamic_cast<QPDF_String*>(
|
||||||
this->obj.getPointer())->unparse(true);
|
this->obj.get())->unparse(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1988,7 +1988,7 @@ QPDFObjectHandle::parseContentStream_data(
|
||||||
{
|
{
|
||||||
size_t stream_length = stream_data->getSize();
|
size_t stream_length = stream_data->getSize();
|
||||||
PointerHolder<InputSource> input =
|
PointerHolder<InputSource> input =
|
||||||
new BufferInputSource(description, stream_data.getPointer());
|
new BufferInputSource(description, stream_data.get());
|
||||||
QPDFTokenizer tokenizer;
|
QPDFTokenizer tokenizer;
|
||||||
tokenizer.allowEOF();
|
tokenizer.allowEOF();
|
||||||
bool empty = false;
|
bool empty = false;
|
||||||
|
@ -2055,7 +2055,7 @@ QPDFObjectHandle::addTokenFilter(PointerHolder<TokenFilter> filter)
|
||||||
{
|
{
|
||||||
assertStream();
|
assertStream();
|
||||||
return dynamic_cast<QPDF_Stream*>(
|
return dynamic_cast<QPDF_Stream*>(
|
||||||
obj.getPointer())->addTokenFilter(filter);
|
obj.get())->addTokenFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
|
@ -2575,7 +2575,7 @@ QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset)
|
||||||
{
|
{
|
||||||
// This is called during parsing on newly created direct objects,
|
// This is called during parsing on newly created direct objects,
|
||||||
// so we can't call dereference() here.
|
// so we can't call dereference() here.
|
||||||
if (this->obj.getPointer())
|
if (this->obj.get())
|
||||||
{
|
{
|
||||||
this->obj->setParsedOffset(offset);
|
this->obj->setParsedOffset(offset);
|
||||||
}
|
}
|
||||||
|
@ -2777,7 +2777,7 @@ QPDFObjectHandle::newStream(QPDF* qpdf)
|
||||||
new QPDF_Stream(qpdf, 0, 0, stream_dict, 0, 0)));
|
new QPDF_Stream(qpdf, 0, 0, stream_dict, 0, 0)));
|
||||||
result.dereference();
|
result.dereference();
|
||||||
QPDF_Stream* stream =
|
QPDF_Stream* stream =
|
||||||
dynamic_cast<QPDF_Stream*>(result.obj.getPointer());
|
dynamic_cast<QPDF_Stream*>(result.obj.get());
|
||||||
stream->setObjGen(result.getObjectID(), result.getGeneration());
|
stream->setObjGen(result.getObjectID(), result.getGeneration());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2819,7 +2819,7 @@ QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf,
|
||||||
{
|
{
|
||||||
// This is called during parsing on newly created direct objects,
|
// This is called during parsing on newly created direct objects,
|
||||||
// so we can't call dereference() here.
|
// so we can't call dereference() here.
|
||||||
if (isInitialized() && this->obj.getPointer())
|
if (isInitialized() && this->obj.get())
|
||||||
{
|
{
|
||||||
this->obj->setDescription(owning_qpdf, object_description);
|
this->obj->setDescription(owning_qpdf, object_description);
|
||||||
}
|
}
|
||||||
|
@ -2831,7 +2831,7 @@ QPDFObjectHandle::hasObjectDescription()
|
||||||
if (isInitialized())
|
if (isInitialized())
|
||||||
{
|
{
|
||||||
dereference();
|
dereference();
|
||||||
if (this->obj.getPointer())
|
if (this->obj.get())
|
||||||
{
|
{
|
||||||
return this->obj->hasDescription();
|
return this->obj->hasDescription();
|
||||||
}
|
}
|
||||||
|
@ -2872,7 +2872,7 @@ QPDFObjectHandle::shallowCopyInternal(QPDFObjectHandle& new_obj,
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDFObjectHandle shallow copy array");
|
QTC::TC("qpdf", "QPDFObjectHandle shallow copy array");
|
||||||
// No newArray for shallow copying the sparse array
|
// No newArray for shallow copying the sparse array
|
||||||
QPDF_Array* arr = dynamic_cast<QPDF_Array*>(obj.getPointer());
|
QPDF_Array* arr = dynamic_cast<QPDF_Array*>(obj.get());
|
||||||
new_obj = QPDFObjectHandle(
|
new_obj = QPDFObjectHandle(
|
||||||
new QPDF_Array(arr->getElementsForShallowCopy()));
|
new QPDF_Array(arr->getElementsForShallowCopy()));
|
||||||
}
|
}
|
||||||
|
@ -3309,23 +3309,23 @@ QPDFObjectHandle::dereference()
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"attempted to dereference an uninitialized QPDFObjectHandle");
|
"attempted to dereference an uninitialized QPDFObjectHandle");
|
||||||
}
|
}
|
||||||
if (this->obj.getPointer() && this->objid &&
|
if (this->obj.get() && this->objid &&
|
||||||
QPDF::Resolver::objectChanged(
|
QPDF::Resolver::objectChanged(
|
||||||
this->qpdf, QPDFObjGen(this->objid, this->generation), this->obj))
|
this->qpdf, QPDFObjGen(this->objid, this->generation), this->obj))
|
||||||
{
|
{
|
||||||
this->obj = nullptr;
|
this->obj = nullptr;
|
||||||
}
|
}
|
||||||
if (this->obj.getPointer() == 0)
|
if (this->obj.get() == 0)
|
||||||
{
|
{
|
||||||
PointerHolder<QPDFObject> obj = QPDF::Resolver::resolve(
|
PointerHolder<QPDFObject> obj = QPDF::Resolver::resolve(
|
||||||
this->qpdf, this->objid, this->generation);
|
this->qpdf, this->objid, this->generation);
|
||||||
if (obj.getPointer() == 0)
|
if (obj.get() == 0)
|
||||||
{
|
{
|
||||||
// QPDF::resolve never returns an uninitialized object, but
|
// QPDF::resolve never returns an uninitialized object, but
|
||||||
// check just in case.
|
// check just in case.
|
||||||
this->obj = new QPDF_Null();
|
this->obj = new QPDF_Null();
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<QPDF_Reserved*>(obj.getPointer()))
|
else if (dynamic_cast<QPDF_Reserved*>(obj.get()))
|
||||||
{
|
{
|
||||||
// Do not resolve
|
// Do not resolve
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
|
||||||
}
|
}
|
||||||
else if (name.isString())
|
else if (name.isString())
|
||||||
{
|
{
|
||||||
if (0 == this->m->names_dest.getPointer())
|
if (0 == this->m->names_dest.get())
|
||||||
{
|
{
|
||||||
QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names");
|
QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names");
|
||||||
if (names.isDictionary())
|
if (names.isDictionary())
|
||||||
|
@ -117,7 +117,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->m->names_dest.getPointer())
|
if (this->m->names_dest.get())
|
||||||
{
|
{
|
||||||
if (this->m->names_dest->findObject(name.getUTF8Value(), result))
|
if (this->m->names_dest->findObject(name.getUTF8Value(), result))
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ QPDFPageLabelDocumentHelper::QPDFPageLabelDocumentHelper(QPDF& qpdf) :
|
||||||
bool
|
bool
|
||||||
QPDFPageLabelDocumentHelper::hasPageLabels()
|
QPDFPageLabelDocumentHelper::hasPageLabels()
|
||||||
{
|
{
|
||||||
return 0 != this->m->labels.getPointer();
|
return 0 != this->m->labels.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
|
|
|
@ -1222,7 +1222,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
|
||||||
if (! afdh)
|
if (! afdh)
|
||||||
{
|
{
|
||||||
afdhph = new QPDFAcroFormDocumentHelper(*qpdf);
|
afdhph = new QPDFAcroFormDocumentHelper(*qpdf);
|
||||||
afdh = afdhph.getPointer();
|
afdh = afdhph.get();
|
||||||
}
|
}
|
||||||
afdh->transformAnnotations(
|
afdh->transformAnnotations(
|
||||||
annots, new_annots, new_fields, old_fields, cm);
|
annots, new_annots, new_fields, old_fields, cm);
|
||||||
|
@ -1270,7 +1270,7 @@ QPDFPageObjectHelper::copyAnnotations(
|
||||||
if (! afdh)
|
if (! afdh)
|
||||||
{
|
{
|
||||||
afdhph = new QPDFAcroFormDocumentHelper(*this_qpdf);
|
afdhph = new QPDFAcroFormDocumentHelper(*this_qpdf);
|
||||||
afdh = afdhph.getPointer();
|
afdh = afdhph.get();
|
||||||
}
|
}
|
||||||
if (this_qpdf == from_qpdf)
|
if (this_qpdf == from_qpdf)
|
||||||
{
|
{
|
||||||
|
@ -1288,7 +1288,7 @@ QPDFPageObjectHelper::copyAnnotations(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
from_afdhph = new QPDFAcroFormDocumentHelper(*from_qpdf);
|
from_afdhph = new QPDFAcroFormDocumentHelper(*from_qpdf);
|
||||||
from_afdh = from_afdhph.getPointer();
|
from_afdh = from_afdhph.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
afdh->transformAnnotations(
|
afdh->transformAnnotations(
|
||||||
|
|
|
@ -652,7 +652,7 @@ QPDFTokenizer::expectInlineImage(PointerHolder<InputSource> input)
|
||||||
void
|
void
|
||||||
QPDFTokenizer::findEI(PointerHolder<InputSource> input)
|
QPDFTokenizer::findEI(PointerHolder<InputSource> input)
|
||||||
{
|
{
|
||||||
if (! input.getPointer())
|
if (! input.get())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3581,7 +3581,7 @@ QPDFWriter::indicateProgress(bool decrement, bool finished)
|
||||||
|
|
||||||
++this->m->events_seen;
|
++this->m->events_seen;
|
||||||
|
|
||||||
if (! this->m->progress_reporter.getPointer())
|
if (! this->m->progress_reporter.get())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,7 +479,7 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
|
||||||
{
|
{
|
||||||
normalizer = new ContentNormalizer();
|
normalizer = new ContentNormalizer();
|
||||||
pipeline = new Pl_QPDFTokenizer(
|
pipeline = new Pl_QPDFTokenizer(
|
||||||
"normalizer", normalizer.getPointer(), pipeline);
|
"normalizer", normalizer.get(), pipeline);
|
||||||
to_delete.push_back(pipeline);
|
to_delete.push_back(pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
|
||||||
iter != this->token_filters.rend(); ++iter)
|
iter != this->token_filters.rend(); ++iter)
|
||||||
{
|
{
|
||||||
pipeline = new Pl_QPDFTokenizer(
|
pipeline = new Pl_QPDFTokenizer(
|
||||||
"token filter", (*iter).getPointer(), pipeline);
|
"token filter", (*iter).get(), pipeline);
|
||||||
to_delete.push_back(pipeline);
|
to_delete.push_back(pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,14 +512,14 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->stream_data.getPointer())
|
if (this->stream_data.get())
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDF_Stream pipe replaced stream data");
|
QTC::TC("qpdf", "QPDF_Stream pipe replaced stream data");
|
||||||
pipeline->write(this->stream_data->getBuffer(),
|
pipeline->write(this->stream_data->getBuffer(),
|
||||||
this->stream_data->getSize());
|
this->stream_data->getSize());
|
||||||
pipeline->finish();
|
pipeline->finish();
|
||||||
}
|
}
|
||||||
else if (this->stream_provider.getPointer())
|
else if (this->stream_provider.get())
|
||||||
{
|
{
|
||||||
Pl_Count count("stream provider count", pipeline);
|
Pl_Count count("stream provider count", pipeline);
|
||||||
if (this->stream_provider->supportsRetry())
|
if (this->stream_provider->supportsRetry())
|
||||||
|
@ -590,7 +590,7 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
|
||||||
|
|
||||||
if (filter &&
|
if (filter &&
|
||||||
(! suppress_warnings) &&
|
(! suppress_warnings) &&
|
||||||
normalizer.getPointer() &&
|
normalizer.get() &&
|
||||||
normalizer->anyBadTokens())
|
normalizer->anyBadTokens())
|
||||||
{
|
{
|
||||||
warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
|
warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
|
||||||
|
|
|
@ -206,7 +206,7 @@ iterate_rc4(unsigned char* data, size_t data_len,
|
||||||
{
|
{
|
||||||
PointerHolder<unsigned char> key_ph = PointerHolder<unsigned char>(
|
PointerHolder<unsigned char> key_ph = PointerHolder<unsigned char>(
|
||||||
true, new unsigned char[QIntC::to_size(key_len)]);
|
true, new unsigned char[QIntC::to_size(key_len)]);
|
||||||
unsigned char* key = key_ph.getPointer();
|
unsigned char* key = key_ph.get();
|
||||||
for (int i = 0; i < iterations; ++i)
|
for (int i = 0; i < iterations; ++i)
|
||||||
{
|
{
|
||||||
int const xor_value = (reverse ? iterations - 1 - i : i);
|
int const xor_value = (reverse ? iterations - 1 - i : i);
|
||||||
|
|
|
@ -314,7 +314,7 @@ QPDF::readLinearizationData()
|
||||||
QPDFObjectHandle HO = H0.getKey("/O"); // outline
|
QPDFObjectHandle HO = H0.getKey("/O"); // outline
|
||||||
|
|
||||||
PointerHolder<Buffer> hbp = pb.getBuffer();
|
PointerHolder<Buffer> hbp = pb.getBuffer();
|
||||||
Buffer* hb = hbp.getPointer();
|
Buffer* hb = hbp.get();
|
||||||
unsigned char const* h_buf = hb->getBuffer();
|
unsigned char const* h_buf = hb->getBuffer();
|
||||||
size_t h_size = hb->getSize();
|
size_t h_size = hb->getSize();
|
||||||
|
|
||||||
|
|
|
@ -470,7 +470,7 @@ win_convert_filename(char const* filename)
|
||||||
size_t len = u16.length();
|
size_t len = u16.length();
|
||||||
size_t wlen = (len / 2) - 1;
|
size_t wlen = (len / 2) - 1;
|
||||||
PointerHolder<wchar_t> wfilenamep(true, new wchar_t[wlen + 1]);
|
PointerHolder<wchar_t> wfilenamep(true, new wchar_t[wlen + 1]);
|
||||||
wchar_t* wfilename = wfilenamep.getPointer();
|
wchar_t* wfilename = wfilenamep.get();
|
||||||
wfilename[wlen] = 0;
|
wfilename[wlen] = 0;
|
||||||
for (unsigned int i = 2; i < len; i += 2)
|
for (unsigned int i = 2; i < len; i += 2)
|
||||||
{
|
{
|
||||||
|
@ -489,9 +489,9 @@ QUtil::safe_fopen(char const* filename, char const* mode)
|
||||||
FILE* f = 0;
|
FILE* f = 0;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PointerHolder<wchar_t> wfilenamep = win_convert_filename(filename);
|
PointerHolder<wchar_t> wfilenamep = win_convert_filename(filename);
|
||||||
wchar_t* wfilename = wfilenamep.getPointer();
|
wchar_t* wfilename = wfilenamep.get();
|
||||||
PointerHolder<wchar_t> wmodep(true, new wchar_t[strlen(mode) + 1]);
|
PointerHolder<wchar_t> wmodep(true, new wchar_t[strlen(mode) + 1]);
|
||||||
wchar_t* wmode = wmodep.getPointer();
|
wchar_t* wmode = wmodep.get();
|
||||||
wmode[strlen(mode)] = 0;
|
wmode[strlen(mode)] = 0;
|
||||||
for (size_t i = 0; i < strlen(mode); ++i)
|
for (size_t i = 0; i < strlen(mode); ++i)
|
||||||
{
|
{
|
||||||
|
@ -633,7 +633,7 @@ QUtil::remove_file(char const* path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PointerHolder<wchar_t> wpath = win_convert_filename(path);
|
PointerHolder<wchar_t> wpath = win_convert_filename(path);
|
||||||
os_wrapper(std::string("remove ") + path, _wunlink(wpath.getPointer()));
|
os_wrapper(std::string("remove ") + path, _wunlink(wpath.get()));
|
||||||
#else
|
#else
|
||||||
os_wrapper(std::string("remove ") + path, unlink(path));
|
os_wrapper(std::string("remove ") + path, unlink(path));
|
||||||
#endif
|
#endif
|
||||||
|
@ -654,7 +654,7 @@ QUtil::rename_file(char const* oldname, char const* newname)
|
||||||
PointerHolder<wchar_t> wold = win_convert_filename(oldname);
|
PointerHolder<wchar_t> wold = win_convert_filename(oldname);
|
||||||
PointerHolder<wchar_t> wnew = win_convert_filename(newname);
|
PointerHolder<wchar_t> wnew = win_convert_filename(newname);
|
||||||
os_wrapper(std::string("rename ") + oldname + " " + newname,
|
os_wrapper(std::string("rename ") + oldname + " " + newname,
|
||||||
_wrename(wold.getPointer(), wnew.getPointer()));
|
_wrename(wold.get(), wnew.get()));
|
||||||
#else
|
#else
|
||||||
os_wrapper(std::string("rename ") + oldname + " " + newname,
|
os_wrapper(std::string("rename ") + oldname + " " + newname,
|
||||||
rename(oldname, newname));
|
rename(oldname, newname));
|
||||||
|
@ -867,8 +867,8 @@ QUtil::get_env(std::string const& var, std::string* value)
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
PointerHolder<char> t = PointerHolder<char>(true, new char[len + 1]);
|
PointerHolder<char> t = PointerHolder<char>(true, new char[len + 1]);
|
||||||
::GetEnvironmentVariable(var.c_str(), t.getPointer(), len);
|
::GetEnvironmentVariable(var.c_str(), t.get(), len);
|
||||||
*value = t.getPointer();
|
*value = t.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1261,7 +1261,7 @@ QUtil::read_file_into_memory(
|
||||||
size = QIntC::to_size(QUtil::tell(f));
|
size = QIntC::to_size(QUtil::tell(f));
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
file_buf = PointerHolder<char>(true, new char[size]);
|
file_buf = PointerHolder<char>(true, new char[size]);
|
||||||
char* buf_p = file_buf.getPointer();
|
char* buf_p = file_buf.get();
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
while ((len = fread(buf_p + bytes_read, 1, size - bytes_read, f)) > 0)
|
while ((len = fread(buf_p + bytes_read, 1, size - bytes_read, f)) > 0)
|
||||||
|
|
|
@ -175,7 +175,7 @@ void qpdf_cleanup(qpdf_data* qpdf)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "qpdf-c called qpdf_cleanup");
|
QTC::TC("qpdf", "qpdf-c called qpdf_cleanup");
|
||||||
qpdf_oh_release_all(*qpdf);
|
qpdf_oh_release_all(*qpdf);
|
||||||
if ((*qpdf)->error.getPointer())
|
if ((*qpdf)->error.get())
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "qpdf-c cleanup warned about unhandled error");
|
QTC::TC("qpdf", "qpdf-c cleanup warned about unhandled error");
|
||||||
std::cerr << "WARNING: application did not handle error: "
|
std::cerr << "WARNING: application did not handle error: "
|
||||||
|
@ -216,12 +216,12 @@ QPDF_BOOL qpdf_more_warnings(qpdf_data qpdf)
|
||||||
QPDF_BOOL qpdf_has_error(qpdf_data qpdf)
|
QPDF_BOOL qpdf_has_error(qpdf_data qpdf)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "qpdf-c called qpdf_has_error");
|
QTC::TC("qpdf", "qpdf-c called qpdf_has_error");
|
||||||
return (qpdf->error.getPointer() ? QPDF_TRUE : QPDF_FALSE);
|
return (qpdf->error.get() ? QPDF_TRUE : QPDF_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
qpdf_error qpdf_get_error(qpdf_data qpdf)
|
qpdf_error qpdf_get_error(qpdf_data qpdf)
|
||||||
{
|
{
|
||||||
if (qpdf->error.getPointer())
|
if (qpdf->error.get())
|
||||||
{
|
{
|
||||||
qpdf->tmp_error.exc = qpdf->error;
|
qpdf->tmp_error.exc = qpdf->error;
|
||||||
qpdf->error = 0;
|
qpdf->error = 0;
|
||||||
|
@ -498,11 +498,11 @@ QPDF_BOOL qpdf_allow_modify_all(qpdf_data qpdf)
|
||||||
|
|
||||||
static void qpdf_init_write_internal(qpdf_data qpdf)
|
static void qpdf_init_write_internal(qpdf_data qpdf)
|
||||||
{
|
{
|
||||||
if (qpdf->qpdf_writer.getPointer())
|
if (qpdf->qpdf_writer.get())
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "qpdf-c called qpdf_init_write multiple times");
|
QTC::TC("qpdf", "qpdf-c called qpdf_init_write multiple times");
|
||||||
qpdf->qpdf_writer = 0;
|
qpdf->qpdf_writer = 0;
|
||||||
if (qpdf->output_buffer.getPointer())
|
if (qpdf->output_buffer.get())
|
||||||
{
|
{
|
||||||
qpdf->output_buffer = 0;
|
qpdf->output_buffer = 0;
|
||||||
qpdf->write_memory = false;
|
qpdf->write_memory = false;
|
||||||
|
@ -541,7 +541,7 @@ size_t qpdf_get_buffer_length(qpdf_data qpdf)
|
||||||
{
|
{
|
||||||
qpdf_get_buffer_internal(qpdf);
|
qpdf_get_buffer_internal(qpdf);
|
||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
if (qpdf->output_buffer.getPointer())
|
if (qpdf->output_buffer.get())
|
||||||
{
|
{
|
||||||
result = qpdf->output_buffer->getSize();
|
result = qpdf->output_buffer->getSize();
|
||||||
}
|
}
|
||||||
|
@ -552,7 +552,7 @@ unsigned char const* qpdf_get_buffer(qpdf_data qpdf)
|
||||||
{
|
{
|
||||||
unsigned char const* result = 0;
|
unsigned char const* result = 0;
|
||||||
qpdf_get_buffer_internal(qpdf);
|
qpdf_get_buffer_internal(qpdf);
|
||||||
if (qpdf->output_buffer.getPointer())
|
if (qpdf->output_buffer.get())
|
||||||
{
|
{
|
||||||
result = qpdf->output_buffer->getBuffer();
|
result = qpdf->output_buffer->getBuffer();
|
||||||
}
|
}
|
||||||
|
@ -978,7 +978,7 @@ static RET do_with_oh(
|
||||||
qpdf, fallback, [fn, oh](qpdf_data q) {
|
qpdf, fallback, [fn, oh](qpdf_data q) {
|
||||||
auto i = q->oh_cache.find(oh);
|
auto i = q->oh_cache.find(oh);
|
||||||
bool result = ((i != q->oh_cache.end()) &&
|
bool result = ((i != q->oh_cache.end()) &&
|
||||||
(i->second).getPointer());
|
(i->second).get());
|
||||||
if (! result)
|
if (! result)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "qpdf-c invalid object handle");
|
QTC::TC("qpdf", "qpdf-c invalid object handle");
|
||||||
|
@ -1506,7 +1506,7 @@ qpdf_oh qpdf_oh_new_stream(qpdf_data qpdf)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "qpdf-c called qpdf_oh_new_stream");
|
QTC::TC("qpdf", "qpdf-c called qpdf_oh_new_stream");
|
||||||
return new_object(
|
return new_object(
|
||||||
qpdf, QPDFObjectHandle::newStream(qpdf->qpdf.getPointer()));
|
qpdf, QPDFObjectHandle::newStream(qpdf->qpdf.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void qpdf_oh_make_direct(qpdf_data qpdf, qpdf_oh oh)
|
void qpdf_oh_make_direct(qpdf_data qpdf, qpdf_oh oh)
|
||||||
|
|
|
@ -66,7 +66,7 @@ int main()
|
||||||
// of the next match
|
// of the next match
|
||||||
memcpy(b + 2037, "potato potato salad ", 20);
|
memcpy(b + 2037, "potato potato salad ", 20);
|
||||||
PointerHolder<InputSource> is =
|
PointerHolder<InputSource> is =
|
||||||
new BufferInputSource("test buffer input source", b1.getPointer());
|
new BufferInputSource("test buffer input source", b1.get());
|
||||||
Finder f1(is, "salad");
|
Finder f1(is, "salad");
|
||||||
check("find potato salad", true,
|
check("find potato salad", true,
|
||||||
is->findFirst("potato", 0, 0, f1));
|
is->findFirst("potato", 0, 0, f1));
|
||||||
|
|
|
@ -15,7 +15,7 @@ int main(int argc, char* argv[])
|
||||||
PointerHolder<char> buf;
|
PointerHolder<char> buf;
|
||||||
size_t size;
|
size_t size;
|
||||||
QUtil::read_file_into_memory(filename, buf, size);
|
QUtil::read_file_into_memory(filename, buf, size);
|
||||||
std::string s(buf.getPointer(), size);
|
std::string s(buf.get(), size);
|
||||||
std::cout << JSON::parse(s).unparse() << std::endl;
|
std::cout << JSON::parse(s).unparse() << std::endl;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#define NO_POINTERHOLDER_DEPRECATION // we need to test the deprecated API
|
||||||
#include <qpdf/PointerHolder.hh>
|
#include <qpdf/PointerHolder.hh>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
@ -528,7 +528,7 @@ void read_from_file_test()
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
QUtil::read_file_into_memory("other-file", buf, size);
|
QUtil::read_file_into_memory("other-file", buf, size);
|
||||||
std::cout << "read " << size << " bytes" << std::endl;
|
std::cout << "read " << size << " bytes" << std::endl;
|
||||||
char const* p = buf.getPointer();
|
char const* p = buf.get();
|
||||||
assert(size == 24652);
|
assert(size == 24652);
|
||||||
assert(memcmp(p, "This file is used for qutil testing.", 36) == 0);
|
assert(memcmp(p, "This file is used for qutil testing.", 36) == 0);
|
||||||
assert(p[59] == static_cast<char>(13));
|
assert(p[59] == static_cast<char>(13));
|
||||||
|
@ -609,11 +609,11 @@ void rename_delete_test()
|
||||||
fprintf(f1, "one");
|
fprintf(f1, "one");
|
||||||
fclose(f1);
|
fclose(f1);
|
||||||
QUtil::read_file_into_memory("old\xcf\x80", buf, size);
|
QUtil::read_file_into_memory("old\xcf\x80", buf, size);
|
||||||
assert(memcmp(buf.getPointer(), "one", 3) == 0);
|
assert(memcmp(buf.get(), "one", 3) == 0);
|
||||||
std::cout << "rename file" << std::endl;;
|
std::cout << "rename file" << std::endl;;
|
||||||
QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp");
|
QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp");
|
||||||
QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size);
|
QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size);
|
||||||
assert(memcmp(buf.getPointer(), "one", 3) == 0);
|
assert(memcmp(buf.get(), "one", 3) == 0);
|
||||||
assert_no_file("old\xcf\x80");
|
assert_no_file("old\xcf\x80");
|
||||||
std::cout << "create file" << std::endl;;
|
std::cout << "create file" << std::endl;;
|
||||||
f1 = QUtil::safe_fopen("old\xcf\x80", "w");
|
f1 = QUtil::safe_fopen("old\xcf\x80", "w");
|
||||||
|
@ -622,7 +622,7 @@ void rename_delete_test()
|
||||||
std::cout << "rename over existing" << std::endl;;
|
std::cout << "rename over existing" << std::endl;;
|
||||||
QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp");
|
QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp");
|
||||||
QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size);
|
QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size);
|
||||||
assert(memcmp(buf.getPointer(), "two", 3) == 0);
|
assert(memcmp(buf.get(), "two", 3) == 0);
|
||||||
assert_no_file("old\xcf\x80");
|
assert_no_file("old\xcf\x80");
|
||||||
std::cout << "delete file" << std::endl;;
|
std::cout << "delete file" << std::endl;;
|
||||||
QUtil::remove_file("old\xcf\x80.~tmp");
|
QUtil::remove_file("old\xcf\x80.~tmp");
|
||||||
|
|
|
@ -295,7 +295,7 @@ static void test_0_1(QPDF& pdf, char const* arg2)
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
QUtil::binary_stdout();
|
QUtil::binary_stdout();
|
||||||
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("raw", stdout);
|
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("raw", stdout);
|
||||||
qtest.pipeStreamData(out.getPointer(), 0, qpdf_dl_none);
|
qtest.pipeStreamData(out.get(), 0, qpdf_dl_none);
|
||||||
|
|
||||||
std::cout << std::endl << "Uncompressed stream data:" << std::endl;
|
std::cout << std::endl << "Uncompressed stream data:" << std::endl;
|
||||||
if (qtest.pipeStreamData(0, 0, qpdf_dl_all))
|
if (qtest.pipeStreamData(0, 0, qpdf_dl_all))
|
||||||
|
@ -303,7 +303,7 @@ static void test_0_1(QPDF& pdf, char const* arg2)
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
QUtil::binary_stdout();
|
QUtil::binary_stdout();
|
||||||
out = new Pl_StdioFile("filtered", stdout);
|
out = new Pl_StdioFile("filtered", stdout);
|
||||||
qtest.pipeStreamData(out.getPointer(), 0, qpdf_dl_all);
|
qtest.pipeStreamData(out.get(), 0, qpdf_dl_all);
|
||||||
std::cout << std::endl << "End of stream data" << std::endl;
|
std::cout << std::endl << "End of stream data" << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -344,7 +344,7 @@ static void test_2(QPDF& pdf, char const* arg2)
|
||||||
QPDFObjectHandle contents = page.getKey("/Contents");
|
QPDFObjectHandle contents = page.getKey("/Contents");
|
||||||
QUtil::binary_stdout();
|
QUtil::binary_stdout();
|
||||||
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("filtered", stdout);
|
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("filtered", stdout);
|
||||||
contents.pipeStreamData(out.getPointer(), 0, qpdf_dl_generalized);
|
contents.pipeStreamData(out.get(), 0, qpdf_dl_generalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_3(QPDF& pdf, char const* arg2)
|
static void test_3(QPDF& pdf, char const* arg2)
|
||||||
|
@ -358,7 +358,7 @@ static void test_3(QPDF& pdf, char const* arg2)
|
||||||
QUtil::binary_stdout();
|
QUtil::binary_stdout();
|
||||||
PointerHolder<Pl_StdioFile> out =
|
PointerHolder<Pl_StdioFile> out =
|
||||||
new Pl_StdioFile("tokenized stream", stdout);
|
new Pl_StdioFile("tokenized stream", stdout);
|
||||||
stream.pipeStreamData(out.getPointer(),
|
stream.pipeStreamData(out.get(),
|
||||||
qpdf_ef_normalize, qpdf_dl_generalized);
|
qpdf_ef_normalize, qpdf_dl_generalized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3154,7 +3154,7 @@ static void test_83(QPDF& pdf, char const* arg2)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::cout << "calling initializeFromJson" << std::endl;
|
std::cout << "calling initializeFromJson" << std::endl;
|
||||||
j.initializeFromJson(std::string(file_buf.getPointer(), size));
|
j.initializeFromJson(std::string(file_buf.get(), size));
|
||||||
std::cout << "called initializeFromJson" << std::endl;
|
std::cout << "called initializeFromJson" << std::endl;
|
||||||
}
|
}
|
||||||
catch (QPDFUsage& e)
|
catch (QPDFUsage& e)
|
||||||
|
@ -3278,7 +3278,7 @@ void runtest(int n, char const* filename1, char const* arg2)
|
||||||
std::string filename(std::string(filename1) + ".obfuscated");
|
std::string filename(std::string(filename1) + ".obfuscated");
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
QUtil::read_file_into_memory(filename.c_str(), file_buf, size);
|
QUtil::read_file_into_memory(filename.c_str(), file_buf, size);
|
||||||
char* p = file_buf.getPointer();
|
char* p = file_buf.get();
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
p[i] = static_cast<char>(p[i] ^ 0xcc);
|
p[i] = static_cast<char>(p[i] ^ 0xcc);
|
||||||
|
@ -3309,7 +3309,7 @@ void runtest(int n, char const* filename1, char const* arg2)
|
||||||
QTC::TC("qpdf", "exercise processMemoryFile");
|
QTC::TC("qpdf", "exercise processMemoryFile");
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
QUtil::read_file_into_memory(filename1, file_buf, size);
|
QUtil::read_file_into_memory(filename1, file_buf, size);
|
||||||
pdf.processMemoryFile(filename1, file_buf.getPointer(), size);
|
pdf.processMemoryFile(filename1, file_buf.get(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, void (*)(QPDF&, char const*)> test_functions = {
|
std::map<int, void (*)(QPDF&, char const*)> test_functions = {
|
||||||
|
|
|
@ -222,7 +222,7 @@ static void process(char const* filename, bool include_ignorable,
|
||||||
(*iter).pipeContents(&plb);
|
(*iter).pipeContents(&plb);
|
||||||
PointerHolder<Buffer> content_data = plb.getBuffer();
|
PointerHolder<Buffer> content_data = plb.getBuffer();
|
||||||
BufferInputSource* bis = new BufferInputSource(
|
BufferInputSource* bis = new BufferInputSource(
|
||||||
"content data", content_data.getPointer());
|
"content data", content_data.get());
|
||||||
is = bis;
|
is = bis;
|
||||||
dump_tokens(is, "PAGE " + QUtil::int_to_string(pageno),
|
dump_tokens(is, "PAGE " + QUtil::int_to_string(pageno),
|
||||||
max_len, include_ignorable, false, true);
|
max_len, include_ignorable, false, true);
|
||||||
|
@ -240,7 +240,7 @@ static void process(char const* filename, bool include_ignorable,
|
||||||
PointerHolder<Buffer> b =
|
PointerHolder<Buffer> b =
|
||||||
(*iter).getStreamData(qpdf_dl_specialized);
|
(*iter).getStreamData(qpdf_dl_specialized);
|
||||||
BufferInputSource* bis = new BufferInputSource(
|
BufferInputSource* bis = new BufferInputSource(
|
||||||
"object stream data", b.getPointer());
|
"object stream data", b.get());
|
||||||
is = bis;
|
is = bis;
|
||||||
dump_tokens(is, "OBJECT STREAM " +
|
dump_tokens(is, "OBJECT STREAM " +
|
||||||
QUtil::int_to_string((*iter).getObjectID()),
|
QUtil::int_to_string((*iter).getObjectID()),
|
||||||
|
|
|
@ -77,7 +77,7 @@ int main(int argc, char* argv[])
|
||||||
QUtil::binary_stdin();
|
QUtil::binary_stdin();
|
||||||
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("stdout", stdout);
|
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("stdout", stdout);
|
||||||
PointerHolder<Pl_Flate> flate =
|
PointerHolder<Pl_Flate> flate =
|
||||||
new Pl_Flate("flate", out.getPointer(), action);
|
new Pl_Flate("flate", out.get(), action);
|
||||||
bool warn = false;
|
bool warn = false;
|
||||||
flate->setWarnCallback([&warn](char const* msg, int code) {
|
flate->setWarnCallback([&warn](char const* msg, int code) {
|
||||||
warn = true;
|
warn = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user