Commit 4278a55752943c16430c6625c123765e5648892d

Authored by m-holger
1 parent 7b342750

Refactor `QPDFWriter` to replace `pl::Link` with direct use of `Pipeline` for im…

…proved clarity and reduced indirection in pipeline management.
libqpdf/QPDFWriter.cc
@@ -141,20 +141,20 @@ namespace @@ -141,20 +141,20 @@ namespace
141 } 141 }
142 142
143 void 143 void
144 - activate(Popper& pp, std::unique_ptr<Pipeline> link) 144 + activate(Popper& pp, std::unique_ptr<Pipeline> next)
145 { 145 {
146 count_buffer.clear(); 146 count_buffer.clear();
147 - activate(pp, false, &count_buffer, std::move(link)); 147 + activate(pp, false, &count_buffer, std::move(next));
148 } 148 }
149 149
150 Popper 150 Popper
151 activate( 151 activate(
152 bool discard = false, 152 bool discard = false,
153 std::string* str = nullptr, 153 std::string* str = nullptr,
154 - std::unique_ptr<Pipeline> link = nullptr) 154 + std::unique_ptr<Pipeline> next = nullptr)
155 { 155 {
156 Popper pp{*this}; 156 Popper pp{*this};
157 - activate(pp, discard, str, std::move(link)); 157 + activate(pp, discard, str, std::move(next));
158 return pp; 158 return pp;
159 } 159 }
160 160
@@ -163,11 +163,11 @@ namespace @@ -163,11 +163,11 @@ namespace
163 Popper& pp, 163 Popper& pp,
164 bool discard = false, 164 bool discard = false,
165 std::string* str = nullptr, 165 std::string* str = nullptr,
166 - std::unique_ptr<Pipeline> link = nullptr) 166 + std::unique_ptr<Pipeline> next = nullptr)
167 { 167 {
168 std::unique_ptr<pl::Count> c; 168 std::unique_ptr<pl::Count> c;
169 - if (link) {  
170 - c = std::make_unique<pl::Count>(++last_id, count_buffer, std::move(link)); 169 + if (next) {
  170 + c = std::make_unique<pl::Count>(++last_id, count_buffer, std::move(next));
171 } else if (discard) { 171 } else if (discard) {
172 c = std::make_unique<pl::Count>(++last_id, nullptr); 172 c = std::make_unique<pl::Count>(++last_id, nullptr);
173 } else if (!str) { 173 } else if (!str) {
libqpdf/qpdf/Pipeline_private.hh
@@ -54,20 +54,10 @@ namespace qpdf::pl @@ -54,20 +54,10 @@ namespace qpdf::pl
54 { 54 {
55 } 55 }
56 56
57 - // Count the number of characters written. If 'next' is not set, the content written will be  
58 - // discarded.  
59 - Count(unsigned long id, std::unique_ptr<Pipeline> link) :  
60 - Pipeline("", link ? link.get() : nullptr),  
61 - link(std::move(link)),  
62 - id_(id),  
63 - pass_immediately_to_next(link)  
64 - {  
65 - }  
66 -  
67 // Write to 'str'. If 'next' is set, 'str' will be written to 'next' when 'finish' is 57 // Write to 'str'. If 'next' is set, 'str' will be written to 'next' when 'finish' is
68 // called. 58 // called.
69 Count(unsigned long id, std::string& str, std::unique_ptr<Pipeline> link = nullptr) : 59 Count(unsigned long id, std::string& str, std::unique_ptr<Pipeline> link = nullptr) :
70 - Pipeline("", link ? link.get() : nullptr), 60 + Pipeline("", link.get()),
71 str(&str), 61 str(&str),
72 link(std::move(link)), 62 link(std::move(link)),
73 id_(id) 63 id_(id)