2012-07-18 21:59:03 +03:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2003-07-14 13:23:11 +03:00
|
|
|
|
2009-03-28 22:51:33 +02:00
|
|
|
#include "hash.hh"
|
2003-07-14 13:23:11 +03:00
|
|
|
|
2006-09-05 00:06:23 +03:00
|
|
|
namespace nix {
|
2003-07-14 13:23:11 +03:00
|
|
|
|
2021-10-04 15:29:42 +03:00
|
|
|
class RefScanSink : public Sink
|
|
|
|
{
|
|
|
|
StringSet hashes;
|
|
|
|
StringSet seen;
|
|
|
|
|
|
|
|
std::string tail;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
RefScanSink(StringSet && hashes) : hashes(hashes)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
StringSet & getResult()
|
|
|
|
{ return seen; }
|
|
|
|
|
|
|
|
void operator () (std::string_view data) override;
|
|
|
|
};
|
|
|
|
|
2018-03-30 01:56:13 +03:00
|
|
|
struct RewritingSink : Sink
|
|
|
|
{
|
2023-03-17 16:51:08 +02:00
|
|
|
const StringMap rewrites;
|
2023-06-15 22:24:14 +03:00
|
|
|
std::string::size_type maxRewriteSize;
|
2023-03-17 16:51:08 +02:00
|
|
|
std::string prev;
|
2018-03-30 01:56:13 +03:00
|
|
|
Sink & nextSink;
|
|
|
|
uint64_t pos = 0;
|
|
|
|
|
|
|
|
std::vector<uint64_t> matches;
|
|
|
|
|
|
|
|
RewritingSink(const std::string & from, const std::string & to, Sink & nextSink);
|
2023-03-17 16:51:08 +02:00
|
|
|
RewritingSink(const StringMap & rewrites, Sink & nextSink);
|
2018-03-30 01:56:13 +03:00
|
|
|
|
2020-12-02 15:00:43 +02:00
|
|
|
void operator () (std::string_view data) override;
|
2018-03-30 01:56:13 +03:00
|
|
|
|
|
|
|
void flush();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HashModuloSink : AbstractHashSink
|
|
|
|
{
|
|
|
|
HashSink hashSink;
|
|
|
|
RewritingSink rewritingSink;
|
|
|
|
|
|
|
|
HashModuloSink(HashType ht, const std::string & modulus);
|
|
|
|
|
2020-12-02 15:00:43 +02:00
|
|
|
void operator () (std::string_view data) override;
|
2018-03-30 01:56:13 +03:00
|
|
|
|
|
|
|
HashResult finish() override;
|
|
|
|
};
|
|
|
|
|
2006-09-05 00:06:23 +03:00
|
|
|
}
|