aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_Function.cc
blob: 32fcccf189022087f2b2bfea2173f3f7b994ec43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <qpdf/Pl_Function.hh>

#include <qpdf/QUtil.hh>
#include <errno.h>
#include <stdexcept>

Pl_Function::Members::Members(writer_t fn) :
    fn(fn)
{
}

Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) :
    Pipeline(identifier, next),
    m(new Members(fn))
{
}

Pl_Function::~Pl_Function()
{
    // Must be explicit and not inline -- see QPDF_DLL_CLASS in
    // README-maintainer
}

void
Pl_Function::write(unsigned char const* buf, size_t len)
{
    this->m->fn(buf, len);
    if (getNext(true)) {
        getNext()->write(buf, len);
    }
}

void
Pl_Function::finish()
{
    if (getNext(true)) {
        getNext()->finish();
    }
}