aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-02-28 23:54:20 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-02-28 23:54:20 +0000
commitdc92b01885c0c49d094148b1c4dc871ccdd265ad (patch)
tree9d4426dfe847570906487649c32c5b320697705c /src/libutil/serialise.hh
parent79152e307e7eef667c3de9c21571d017654a7c32 (diff)
parent1c985428c4783568bcfb4692c6ce816eb5c5c31d (diff)
Merge remote-tracking branch 'upstream/master' into auto-uid-allocation
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r--src/libutil/serialise.hh23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index 0fe6e8332..13da26c6a 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -154,12 +154,13 @@ private:
/* A sink that writes data to a string. */
struct StringSink : Sink
{
- ref<std::string> s;
- StringSink() : s(make_ref<std::string>()) { };
- explicit StringSink(const size_t reservedSize) : s(make_ref<std::string>()) {
- s->reserve(reservedSize);
+ std::string s;
+ StringSink() { }
+ explicit StringSink(const size_t reservedSize)
+ {
+ s.reserve(reservedSize);
};
- StringSink(ref<std::string> s) : s(s) { };
+ StringSink(std::string && s) : s(std::move(s)) { };
void operator () (std::string_view data) override;
};
@@ -167,9 +168,9 @@ struct StringSink : Sink
/* A source that reads data from a string. */
struct StringSource : Source
{
- const string & s;
+ std::string_view s;
size_t pos;
- StringSource(const string & _s) : s(_s), pos(0) { }
+ StringSource(std::string_view s) : s(s), pos(0) { }
size_t read(char * data, size_t len) override;
};
@@ -317,10 +318,10 @@ inline Sink & operator << (Sink & sink, uint64_t n)
return sink;
}
-Sink & operator << (Sink & sink, const string & s);
+Sink & operator << (Sink & in, const Error & ex);
+Sink & operator << (Sink & sink, std::string_view s);
Sink & operator << (Sink & sink, const Strings & s);
Sink & operator << (Sink & sink, const StringSet & s);
-Sink & operator << (Sink & in, const Error & ex);
MakeError(SerialisationError, Error);
@@ -363,10 +364,10 @@ inline uint64_t readLongLong(Source & source)
void readPadding(size_t len, Source & source);
size_t readString(char * buf, size_t max, Source & source);
-string readString(Source & source, size_t max = std::numeric_limits<size_t>::max());
+std::string readString(Source & source, size_t max = std::numeric_limits<size_t>::max());
template<class T> T readStrings(Source & source);
-Source & operator >> (Source & in, string & s);
+Source & operator >> (Source & in, std::string & s);
template<typename T>
Source & operator >> (Source & in, T & n)