2022-07-16 10:21:11 +00:00
|
|
|
#include <qpdf/QPDFObjGen.hh>
|
|
|
|
|
2023-01-05 11:09:44 +00:00
|
|
|
#include <qpdf/QPDFObjectHandle.hh>
|
|
|
|
#include <qpdf/QPDFObjectHelper.hh>
|
|
|
|
#include <qpdf/QPDFObject_private.hh>
|
2022-07-16 10:21:11 +00:00
|
|
|
|
2023-01-05 11:09:44 +00:00
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
// ABI: inline and pass og by value
|
2022-07-16 10:21:11 +00:00
|
|
|
std::ostream&
|
|
|
|
operator<<(std::ostream& os, const QPDFObjGen& og)
|
|
|
|
{
|
|
|
|
os << og.obj << "," << og.gen;
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2023-01-05 11:09:44 +00:00
|
|
|
// ABI: inline
|
2022-07-16 10:21:11 +00:00
|
|
|
std::string
|
|
|
|
QPDFObjGen::unparse(char separator) const
|
|
|
|
{
|
2023-01-05 11:09:44 +00:00
|
|
|
return std::to_string(obj) + separator + std::to_string(gen);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
QPDFObjGen::set::add(QPDFObjectHandle const& oh)
|
|
|
|
{
|
|
|
|
if (auto* ptr = oh.getObjectPtr()) {
|
|
|
|
return add(ptr->getObjGen());
|
|
|
|
} else {
|
2023-05-27 17:19:52 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"attempt to retrieve QPDFObjGen from uninitialized QPDFObjectHandle");
|
2023-01-05 11:09:44 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
QPDFObjGen::set::add(QPDFObjectHelper const& helper)
|
|
|
|
{
|
|
|
|
if (auto* ptr = helper.getObjectHandle().getObjectPtr()) {
|
|
|
|
return add(ptr->getObjGen());
|
|
|
|
} else {
|
2023-05-27 17:19:52 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"attempt to retrieve QPDFObjGen from uninitialized QPDFObjectHandle");
|
2023-01-05 11:09:44 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
QPDFObjGen::set::erase(QPDFObjectHandle const& oh)
|
|
|
|
{
|
|
|
|
if (auto* ptr = oh.getObjectPtr()) {
|
|
|
|
erase(ptr->getObjGen());
|
|
|
|
} else {
|
2023-05-27 17:19:52 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"attempt to retrieve QPDFObjGen from uninitialized QPDFObjectHandle");
|
2023-01-05 11:09:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
QPDFObjGen::set::erase(QPDFObjectHelper const& helper)
|
|
|
|
{
|
|
|
|
if (auto* ptr = helper.getObjectHandle().getObjectPtr()) {
|
|
|
|
erase(ptr->getObjGen());
|
|
|
|
} else {
|
2023-05-27 17:19:52 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"attempt to retrieve QPDFObjGen from uninitialized QPDFObjectHandle");
|
2023-01-05 11:09:44 +00:00
|
|
|
}
|
2022-07-16 10:21:11 +00:00
|
|
|
}
|