Commit f588d74140b2a86026929aa401c9852ec215d4af
1 parent
3fe6a1f5
Add integer types to Pipeline::operator<<
Showing
4 changed files
with
84 additions
and
1 deletions
ChangeLog
| 1 | +2022-06-05 Jay Berkenbilt <ejb@ql.org> | ||
| 2 | + | ||
| 3 | + * Add integer types to pipeline's operator<<: short, int, long, | ||
| 4 | + long long, unsigned short, unsigned int, unsigned long, unsigned | ||
| 5 | + long long. | ||
| 6 | + | ||
| 1 | 2022-05-30 Jay Berkenbilt <ejb@ql.org> | 7 | 2022-05-30 Jay Berkenbilt <ejb@ql.org> |
| 2 | 8 | ||
| 3 | * qpdf JSON is now at version 2. New command-line arguments: | 9 | * qpdf JSON is now at version 2. New command-line arguments: |
include/qpdf/Pipeline.hh
| @@ -86,6 +86,24 @@ class QPDF_DLL_CLASS Pipeline | @@ -86,6 +86,24 @@ class QPDF_DLL_CLASS Pipeline | ||
| 86 | Pipeline& operator<<(char const* cstr); | 86 | Pipeline& operator<<(char const* cstr); |
| 87 | QPDF_DLL | 87 | QPDF_DLL |
| 88 | Pipeline& operator<<(std::string const&); | 88 | Pipeline& operator<<(std::string const&); |
| 89 | + // Calls QUtil::int_to_string | ||
| 90 | + QPDF_DLL | ||
| 91 | + Pipeline& operator<<(short); | ||
| 92 | + QPDF_DLL | ||
| 93 | + Pipeline& operator<<(int); | ||
| 94 | + QPDF_DLL | ||
| 95 | + Pipeline& operator<<(long); | ||
| 96 | + QPDF_DLL | ||
| 97 | + Pipeline& operator<<(long long); | ||
| 98 | + // Calls QUtil::uint_to_string | ||
| 99 | + QPDF_DLL | ||
| 100 | + Pipeline& operator<<(unsigned short); | ||
| 101 | + QPDF_DLL | ||
| 102 | + Pipeline& operator<<(unsigned int); | ||
| 103 | + QPDF_DLL | ||
| 104 | + Pipeline& operator<<(unsigned long); | ||
| 105 | + QPDF_DLL | ||
| 106 | + Pipeline& operator<<(unsigned long long); | ||
| 89 | 107 | ||
| 90 | // Overloaded write to reduce casting | 108 | // Overloaded write to reduce casting |
| 91 | QPDF_DLL | 109 | QPDF_DLL |
libqpdf/Pipeline.cc
| 1 | #include <qpdf/Pipeline.hh> | 1 | #include <qpdf/Pipeline.hh> |
| 2 | 2 | ||
| 3 | +#include <qpdf/QUtil.hh> | ||
| 4 | + | ||
| 3 | #include <cstring> | 5 | #include <cstring> |
| 4 | #include <stdexcept> | 6 | #include <stdexcept> |
| 5 | 7 | ||
| @@ -52,6 +54,62 @@ Pipeline::operator<<(std::string const& str) | @@ -52,6 +54,62 @@ Pipeline::operator<<(std::string const& str) | ||
| 52 | return *this; | 54 | return *this; |
| 53 | } | 55 | } |
| 54 | 56 | ||
| 57 | +Pipeline& | ||
| 58 | +Pipeline::operator<<(short i) | ||
| 59 | +{ | ||
| 60 | + this->writeString(QUtil::int_to_string(i)); | ||
| 61 | + return *this; | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +Pipeline& | ||
| 65 | +Pipeline::operator<<(int i) | ||
| 66 | +{ | ||
| 67 | + this->writeString(QUtil::int_to_string(i)); | ||
| 68 | + return *this; | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +Pipeline& | ||
| 72 | +Pipeline::operator<<(long i) | ||
| 73 | +{ | ||
| 74 | + this->writeString(QUtil::int_to_string(i)); | ||
| 75 | + return *this; | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +Pipeline& | ||
| 79 | +Pipeline::operator<<(long long i) | ||
| 80 | +{ | ||
| 81 | + this->writeString(QUtil::int_to_string(i)); | ||
| 82 | + return *this; | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +Pipeline& | ||
| 86 | +Pipeline::operator<<(unsigned short i) | ||
| 87 | +{ | ||
| 88 | + this->writeString(QUtil::uint_to_string(i)); | ||
| 89 | + return *this; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +Pipeline& | ||
| 93 | +Pipeline::operator<<(unsigned int i) | ||
| 94 | +{ | ||
| 95 | + this->writeString(QUtil::uint_to_string(i)); | ||
| 96 | + return *this; | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +Pipeline& | ||
| 100 | +Pipeline::operator<<(unsigned long i) | ||
| 101 | +{ | ||
| 102 | + this->writeString(QUtil::uint_to_string(i)); | ||
| 103 | + return *this; | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +Pipeline& | ||
| 107 | +Pipeline::operator<<(unsigned long long i) | ||
| 108 | +{ | ||
| 109 | + this->writeString(QUtil::uint_to_string(i)); | ||
| 110 | + return *this; | ||
| 111 | +} | ||
| 112 | + | ||
| 55 | void | 113 | void |
| 56 | Pipeline::write(char const* data, size_t len) | 114 | Pipeline::write(char const* data, size_t len) |
| 57 | { | 115 | { |
manual/release-notes.rst
| @@ -145,7 +145,8 @@ For a detailed list of changes, please see the file | @@ -145,7 +145,8 @@ For a detailed list of changes, please see the file | ||
| 145 | 145 | ||
| 146 | - ``writeString``: writes a std::string | 146 | - ``writeString``: writes a std::string |
| 147 | 147 | ||
| 148 | - - ``operator <<``: for null-terminated C strings and std::strings | 148 | + - ``operator <<``: for null-terminated C strings, std::strings, |
| 149 | + and integer types | ||
| 149 | 150 | ||
| 150 | - Add new ``Pipeline`` type ``Pl_OStream`` to write to a | 151 | - Add new ``Pipeline`` type ``Pl_OStream`` to write to a |
| 151 | ``std::ostream``. | 152 | ``std::ostream``. |