forked from lix-project/lix
libutil: allow draining Generator<Bytes> into sinks
Change-Id: I442d03a5399096d4baca9a2618b4c4b64db36c4b
This commit is contained in:
parent
4857feb910
commit
b252b3c6e3
|
@ -65,5 +65,6 @@ if cxx.get_linker_id() in ['ld.bfd', 'ld.gold']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libstore = dependency('lixstore', 'lix-store', required : true)
|
libstore = dependency('lixstore', 'lix-store', required : true)
|
||||||
|
libutil = dependency('lixutil', 'lix-util', required : true)
|
||||||
|
|
||||||
subdir('lib/Nix')
|
subdir('lib/Nix')
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
|
#include <concepts>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "generator.hh"
|
||||||
#include "strings.hh"
|
#include "strings.hh"
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include "file-descriptor.hh"
|
#include "file-descriptor.hh"
|
||||||
|
@ -340,6 +342,13 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun);
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun);
|
std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun);
|
||||||
|
|
||||||
|
inline Sink & operator<<(Sink & sink, Generator<Bytes> && g)
|
||||||
|
{
|
||||||
|
while (auto buffer = g.next()) {
|
||||||
|
sink(std::string_view(buffer->data(), buffer->size()));
|
||||||
|
}
|
||||||
|
return sink;
|
||||||
|
}
|
||||||
|
|
||||||
void writePadding(size_t len, Sink & sink);
|
void writePadding(size_t len, Sink & sink);
|
||||||
void writeString(std::string_view s, Sink & sink);
|
void writeString(std::string_view s, Sink & sink);
|
||||||
|
|
Loading…
Reference in a new issue