2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-23 11:28:56 +00:00
qpdf/libqpdf/Pipeline.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

115 lines
1.8 KiB
C++
Raw Normal View History

#include <qpdf/Pipeline.hh>
#include <cstring>
#include <stdexcept>
Pipeline::Pipeline(char const* identifier, Pipeline* next) :
identifier(identifier),
next_(next)
{
}
Pipeline*
Pipeline::getNext(bool allow_null)
{
if (!next_ && !allow_null) {
throw std::logic_error(
this->identifier + ": Pipeline::getNext() called on pipeline with no next");
}
return next_;
}
std::string
Pipeline::getIdentifier() const
{
return this->identifier;
}
2022-05-03 21:58:58 +00:00
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(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(int i)
{
this->writeString(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(long i)
{
this->writeString(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(long long i)
{
this->writeString(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(unsigned short i)
{
this->writeString(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(unsigned int i)
{
this->writeString(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(unsigned long i)
{
this->writeString(std::to_string(i));
return *this;
}
Pipeline&
Pipeline::operator<<(unsigned long long i)
{
this->writeString(std::to_string(i));
return *this;
}
2022-05-03 21:58:58 +00:00
void
Pipeline::write(char const* data, size_t len)
{
this->write(reinterpret_cast<unsigned char const*>(data), len);
}