aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pipeline.cc
blob: 6f3f33dbd14be38366c4fb85d1181251d243422c (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <qpdf/Pipeline.hh>

#include <qpdf/QUtil.hh>

#include <cstring>
#include <stdexcept>

Pipeline::Pipeline(char const* identifier, Pipeline* next) :
    identifier(identifier),
    next(next)
{
}

Pipeline*
Pipeline::getNext(bool allow_null)
{
    if ((this->next == nullptr) && (!allow_null)) {
        throw std::logic_error(
            this->identifier +
            ": Pipeline::getNext() called on pipeline with no next");
    }
    return this->next;
}

std::string
Pipeline::getIdentifier() const
{
    return this->identifier;
}

void
Pipeline::writeCStr(char const* cstr)
{
    this->write(cstr, strlen(cstr));
}

void
Pipeline::writeString(std::string const& str)
{
    this->write(str.c_str(), str.length());
}

Pipeline&
Pipeline::operator<<(char const* cstr)
{
    this->writeCStr(cstr);
    return *this;
}

Pipeline&
Pipeline::operator<<(std::string const& str)
{
    this->writeString(str);
    return *this;
}

Pipeline&
Pipeline::operator<<(short i)
{
    this->writeString(QUtil::int_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(int i)
{
    this->writeString(QUtil::int_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(long i)
{
    this->writeString(QUtil::int_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(long long i)
{
    this->writeString(QUtil::int_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(unsigned short i)
{
    this->writeString(QUtil::uint_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(unsigned int i)
{
    this->writeString(QUtil::uint_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(unsigned long i)
{
    this->writeString(QUtil::uint_to_string(i));
    return *this;
}

Pipeline&
Pipeline::operator<<(unsigned long long i)
{
    this->writeString(QUtil::uint_to_string(i));
    return *this;
}

void
Pipeline::write(char const* data, size_t len)
{
    this->write(reinterpret_cast<unsigned char const*>(data), len);
}