aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/references.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/references.hh')
-rw-r--r--src/libutil/references.hh21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libutil/references.hh b/src/libutil/references.hh
index 3fefd824b..f0f467190 100644
--- a/src/libutil/references.hh
+++ b/src/libutil/references.hh
@@ -23,19 +23,24 @@ public:
void operator () (std::string_view data) override;
};
-struct RewritingSink : Sink
+struct RewritingSource : Source
{
+ const std::string::size_type maxRewriteSize;
+ const std::string initials;
const StringMap rewrites;
- std::string::size_type maxRewriteSize;
- std::string prev;
- Sink & nextSink;
+ std::string rewritten, buffered;
+ std::string_view unreturned;
+ Source * inner;
- RewritingSink(const std::string & from, const std::string & to, Sink & nextSink);
- RewritingSink(const StringMap & rewrites, Sink & nextSink);
+ static constexpr struct may_change_size_t {
+ explicit may_change_size_t() = default;
+ } may_change_size{};
- void operator () (std::string_view data) override;
+ RewritingSource(const std::string & from, const std::string & to, Source & inner);
+ RewritingSource(StringMap rewrites, Source & inner);
+ RewritingSource(may_change_size_t, StringMap rewrites, Source & inner);
- void flush();
+ size_t read(char * data, size_t len) override;
};
HashResult computeHashModulo(HashType ht, const std::string & modulus, Source & source);