Skip to content

Commit

Permalink
Make sinks public
Browse files Browse the repository at this point in the history
  • Loading branch information
meditans committed Jun 17, 2020
1 parent 270005f commit 5d51680
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct TunnelLogger : public Logger
}
};

struct TunnelSink : Sink
struct TunnelSink : public Sink
{
Sink & to;
TunnelSink(Sink & to) : to(to) { }
Expand Down Expand Up @@ -175,7 +175,7 @@ struct TunnelSource : BufferedSource

/* If the NAR archive contains a single file at top-level, then save
the contents of the file to `s'. Otherwise barf. */
struct RetrieveRegularNARSink : ParseSink
struct RetrieveRegularNARSink : public ParseSink
{
bool regular;
string s;
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/export-import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace nix {

struct HashAndWriteSink : Sink
struct HashAndWriteSink : public Sink
{
Sink & writeSink;
HashSink hashSink;
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/references.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void search(const unsigned char * s, size_t len,
}


struct RefScanSink : Sink
struct RefScanSink : public Sink
{
HashSink hashSink;
StringSet hashes;
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void parseDump(ParseSink & sink, Source & source)
}


struct RestoreSink : ParseSink
struct RestoreSink : public ParseSink
{
Path dstPath;
AutoCloseFD fd;
Expand Down
18 changes: 9 additions & 9 deletions src/libutil/compression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace nix {

// Don't feed brotli too much at once.
struct ChunkedCompressionSink : CompressionSink
struct ChunkedCompressionSink : public CompressionSink
{
uint8_t outbuf[32 * 1024];

Expand All @@ -36,15 +36,15 @@ struct ChunkedCompressionSink : CompressionSink
virtual void writeInternal(const unsigned char * data, size_t len) = 0;
};

struct NoneSink : CompressionSink
struct NoneSink : public CompressionSink
{
Sink & nextSink;
NoneSink(Sink & nextSink) : nextSink(nextSink) { }
void finish() override { flush(); }
void write(const unsigned char * data, size_t len) override { nextSink(data, len); }
};

struct GzipDecompressionSink : CompressionSink
struct GzipDecompressionSink : public CompressionSink
{
Sink & nextSink;
z_stream strm;
Expand Down Expand Up @@ -104,7 +104,7 @@ struct GzipDecompressionSink : CompressionSink
}
};

struct XzDecompressionSink : CompressionSink
struct XzDecompressionSink : public CompressionSink
{
Sink & nextSink;
uint8_t outbuf[BUFSIZ];
Expand Down Expand Up @@ -156,7 +156,7 @@ struct XzDecompressionSink : CompressionSink
}
};

struct BzipDecompressionSink : ChunkedCompressionSink
struct BzipDecompressionSink : public ChunkedCompressionSink
{
Sink & nextSink;
bz_stream strm;
Expand Down Expand Up @@ -209,7 +209,7 @@ struct BzipDecompressionSink : ChunkedCompressionSink
}
};

struct BrotliDecompressionSink : ChunkedCompressionSink
struct BrotliDecompressionSink : public ChunkedCompressionSink
{
Sink & nextSink;
BrotliDecoderState * state;
Expand Down Expand Up @@ -285,7 +285,7 @@ ref<CompressionSink> makeDecompressionSink(const std::string & method, Sink & ne
throw UnknownCompressionMethod("unknown compression method '%s'", method);
}

struct XzCompressionSink : CompressionSink
struct XzCompressionSink : public CompressionSink
{
Sink & nextSink;
uint8_t outbuf[BUFSIZ];
Expand Down Expand Up @@ -364,7 +364,7 @@ struct XzCompressionSink : CompressionSink
}
};

struct BzipCompressionSink : ChunkedCompressionSink
struct BzipCompressionSink : public ChunkedCompressionSink
{
Sink & nextSink;
bz_stream strm;
Expand Down Expand Up @@ -417,7 +417,7 @@ struct BzipCompressionSink : ChunkedCompressionSink
}
};

struct BrotliCompressionSink : ChunkedCompressionSink
struct BrotliCompressionSink : public ChunkedCompressionSink
{
Sink & nextSink;
uint8_t outbuf[BUFSIZ];
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/compression.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace nix {

struct CompressionSink : BufferedSink
struct CompressionSink : public BufferedSink
{
virtual void finish() = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/hash.hh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ string printHashType(HashType ht);

union Ctx;

struct AbstractHashSink : virtual Sink
struct AbstractHashSink : public virtual Sink
{
virtual HashResult finish() = 0;
};
Expand Down
11 changes: 6 additions & 5 deletions src/libutil/serialise.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Sink


/* A buffered abstract sink. */
struct BufferedSink : virtual Sink
struct BufferedSink : public virtual Sink
{
size_t bufSize, bufPos;
std::unique_ptr<unsigned char[]> buffer;
Expand Down Expand Up @@ -86,7 +86,7 @@ protected:


/* A sink that writes data to a file descriptor. */
struct FdSink : BufferedSink
struct FdSink : public BufferedSink
{
int fd;
bool warn = false;
Expand Down Expand Up @@ -144,7 +144,7 @@ private:


/* A sink that writes data to a string. */
struct StringSink : Sink
struct StringSink : public Sink
{
ref<std::string> s;
StringSink() : s(make_ref<std::string>()) { };
Expand Down Expand Up @@ -181,10 +181,11 @@ struct TeeSource : Source
}
};

struct TeeSink : Sink
struct TeeSink : public Sink
{
Sink & orig;
ref<std::string> data;
TeeSink(TeeSink &&) = default;
TeeSink(Sink & orig)
: orig(orig), data(make_ref<std::string>()) { }
void operator () (const unsigned char * data, size_t len) {
Expand Down Expand Up @@ -231,7 +232,7 @@ struct SizedSource : Source
};

/* Convert a function into a sink. */
struct LambdaSink : Sink
struct LambdaSink : public Sink
{
typedef std::function<void(const unsigned char *, size_t)> lambda_t;

Expand Down

0 comments on commit 5d51680

Please sign in to comment.