File: Pl_String.cc

package info (click to toggle)
qpdf 12.3.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 72,644 kB
  • sloc: cpp: 59,031; perl: 12,172; ansic: 6,809; sh: 1,231; python: 1,041; xml: 43; makefile: 42
file content (45 lines) | stat: -rw-r--r-- 796 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
#include <qpdf/Pl_String.hh>

#include <stdexcept>

class Pl_String::Members
{
  public:
    Members(std::string& s) :
        s(s)
    {
    }
    Members(Members const&) = delete;
    ~Members() = default;

    std::string& s;
};

Pl_String::Pl_String(char const* identifier, Pipeline* next, std::string& s) :
    Pipeline(identifier, next),
    m(std::make_unique<Members>(s))
{
}

// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
Pl_String::~Pl_String() = default;

void
Pl_String::write(unsigned char const* buf, size_t len)
{
    if (!len) {
        return;
    }
    m->s.append(reinterpret_cast<char const*>(buf), len);
    if (next()) {
        next()->write(buf, len);
    }
}

void
Pl_String::finish()
{
    if (next()) {
        next()->finish();
    }
}