about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/serialise.cc18
-rw-r--r--src/libutil/serialise.hh4
2 files changed, 21 insertions, 1 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index aa11c590af36..969f638ef408 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -48,6 +48,14 @@ void writeString(const string & s, Sink & sink)
 }
 
 
+void writeStringSet(const StringSet & ss, Sink & sink)
+{
+    writeInt(ss.size(), sink);
+    for (StringSet::iterator i = ss.begin(); i != ss.end(); ++i)
+        writeString(*i, sink);
+}
+
+
 void readPadding(unsigned int len, Source & source)
 {
     if (len % 8) {
@@ -84,4 +92,14 @@ string readString(Source & source)
 }
 
  
+StringSet readStringSet(Source & source)
+{
+    unsigned int count = readInt(source);
+    StringSet ss;
+    while (count--)
+        ss.insert(readString(source));
+    return ss;
+}
+
+
 }
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index 6be10b5528db..fe3492235e97 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -69,12 +69,14 @@ struct FdSource : Source
 void writePadding(unsigned int len, Sink & sink);
 void writeInt(unsigned int n, Sink & sink);
 void writeString(const string & s, Sink & sink);
+void writeStringSet(const StringSet & ss, Sink & sink);
 
 void readPadding(unsigned int len, Source & source);
 unsigned int readInt(Source & source);
 string readString(Source & source);
+StringSet readStringSet(Source & source);
+
 
- 
 }