mirror of
https://github.com/NixOS/nix
synced 2025-06-26 20:01:15 +02:00
Move SavingSourceAdapter to serialise.hh
This commit is contained in:
parent
ce4d8e3ef8
commit
ddb5577f2e
2 changed files with 15 additions and 15 deletions
|
@ -139,6 +139,21 @@ struct StringSource : Source
|
|||
};
|
||||
|
||||
|
||||
/* Adapter class of a Source that saves all data read to `s'. */
|
||||
struct SavingSourceAdapter : Source
|
||||
{
|
||||
Source & orig;
|
||||
string s;
|
||||
SavingSourceAdapter(Source & orig) : orig(orig) { }
|
||||
size_t read(unsigned char * data, size_t len)
|
||||
{
|
||||
size_t n = orig.read(data, len);
|
||||
s.append((const char *) data, n);
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void writePadding(size_t len, Sink & sink);
|
||||
void writeString(const unsigned char * buf, size_t len, Sink & sink);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue