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 writePadding(size_t len, Sink & sink);
|
||||||
void writeString(const unsigned char * buf, size_t len, Sink & sink);
|
void writeString(const unsigned char * buf, size_t len, Sink & sink);
|
||||||
|
|
||||||
|
|
|
@ -168,21 +168,6 @@ struct RetrieveRegularNARSink : ParseSink
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVersion,
|
static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVersion,
|
||||||
Source & from, Sink & to, unsigned int op)
|
Source & from, Sink & to, unsigned int op)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue