mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
c916dcf973
Also, tidy pipeline constructors and make subclasses final where possible.
50 lines
853 B
C++
50 lines
853 B
C++
#include <qpdf/Pl_Count.hh>
|
|
|
|
#include <qpdf/QIntC.hh>
|
|
|
|
Pl_Count::Members::Members()
|
|
{
|
|
}
|
|
|
|
Pl_Count::Pl_Count(char const* identifier, Pipeline* next) :
|
|
Pipeline(identifier, next),
|
|
m(new Members())
|
|
{
|
|
if (!next) {
|
|
throw std::logic_error("Attempt to create Pl_Count with nullptr as next");
|
|
}
|
|
}
|
|
|
|
Pl_Count::~Pl_Count() // NOLINT (modernize-use-equals-default)
|
|
{
|
|
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
|
|
}
|
|
|
|
void
|
|
Pl_Count::write(unsigned char const* buf, size_t len)
|
|
{
|
|
if (len) {
|
|
m->count += QIntC::to_offset(len);
|
|
m->last_char = buf[len - 1];
|
|
next()->write(buf, len);
|
|
}
|
|
}
|
|
|
|
void
|
|
Pl_Count::finish()
|
|
{
|
|
next()->finish();
|
|
}
|
|
|
|
qpdf_offset_t
|
|
Pl_Count::getCount() const
|
|
{
|
|
return m->count;
|
|
}
|
|
|
|
unsigned char
|
|
Pl_Count::getLastChar() const
|
|
{
|
|
return m->last_char;
|
|
}
|