about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-12-16T22·31+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-12-16T22·31+0000
commit273b288a7e862ac1918064537ff130cc751fa9fd (patch)
tree06494346db77ff96da1f68dbb271e9c3a2e64e12 /src/libutil
parent8d3dfa2c1782e955d2b7796d19dc0d0381596b98 (diff)
* importPath() -> importPaths(). Because of buffering of the input
  stream it's now necessary for the daemon to process the entire
  sequence of exported paths, rather than letting the client do it.

Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/serialise.cc16
-rw-r--r--src/libutil/serialise.hh4
2 files changed, 13 insertions, 7 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index ba549c214f10..c4563ffd1212 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -163,13 +163,16 @@ void writeString(const string & s, Sink & sink)
 }
 
 
-void writeStringSet(const StringSet & ss, Sink & sink)
+template<class T> void writeStrings(const T & ss, Sink & sink)
 {
     writeInt(ss.size(), sink);
-    for (StringSet::iterator i = ss.begin(); i != ss.end(); ++i)
+    foreach (typename T::const_iterator, i, ss)
         writeString(*i, sink);
 }
 
+template void writeStrings(const Paths & ss, Sink & sink);
+template void writeStrings(const PathSet & ss, Sink & sink);
+
 
 void readPadding(size_t len, Source & source)
 {
@@ -234,14 +237,17 @@ string readString(Source & source)
 }
 
  
-StringSet readStringSet(Source & source)
+template<class T> T readStrings(Source & source)
 {
     unsigned int count = readInt(source);
-    StringSet ss;
+    T ss;
     while (count--)
-        ss.insert(readString(source));
+        ss.insert(ss.end(), readString(source));
     return ss;
 }
 
+template Paths readStrings(Source & source);
+template PathSet readStrings(Source & source);
+
 
 }
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index efd8e2a060eb..ded4b12a046e 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -116,14 +116,14 @@ void writeInt(unsigned int n, Sink & sink);
 void writeLongLong(unsigned long long n, Sink & sink);
 void writeString(const unsigned char * buf, size_t len, Sink & sink);
 void writeString(const string & s, Sink & sink);
-void writeStringSet(const StringSet & ss, Sink & sink);
+template<class T> void writeStrings(const T & ss, Sink & sink);
 
 void readPadding(size_t len, Source & source);
 unsigned int readInt(Source & source);
 unsigned long long readLongLong(Source & source);
 size_t readString(unsigned char * buf, size_t max, Source & source);
 string readString(Source & source);
-StringSet readStringSet(Source & source);
+template<class T> T readStrings(Source & source);
 
 
 MakeError(SerialisationError, Error)