mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
5334c9c792
To be consistent with CLI, nix API and many other references. As part of this, we also converted it to a scoped enum. https://github.com/NixOS/nix/issues/8876
56 lines
1 KiB
C++
56 lines
1 KiB
C++
#pragma once
|
|
///@file
|
|
|
|
#include "hash.hh"
|
|
|
|
namespace nix {
|
|
|
|
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;
|
|
};
|
|
|
|
struct RewritingSink : Sink
|
|
{
|
|
const StringMap rewrites;
|
|
std::string::size_type maxRewriteSize;
|
|
std::string prev;
|
|
Sink & nextSink;
|
|
uint64_t pos = 0;
|
|
|
|
std::vector<uint64_t> matches;
|
|
|
|
RewritingSink(const std::string & from, const std::string & to, Sink & nextSink);
|
|
RewritingSink(const StringMap & rewrites, Sink & nextSink);
|
|
|
|
void operator () (std::string_view data) override;
|
|
|
|
void flush();
|
|
};
|
|
|
|
struct HashModuloSink : AbstractHashSink
|
|
{
|
|
HashSink hashSink;
|
|
RewritingSink rewritingSink;
|
|
|
|
HashModuloSink(HashAlgorithm ha, const std::string & modulus);
|
|
|
|
void operator () (std::string_view data) override;
|
|
|
|
HashResult finish() override;
|
|
};
|
|
|
|
}
|