]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_json: add deque encode/decode
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 19 Nov 2015 18:59:30 +0000 (10:59 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:36 +0000 (16:13 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/common/ceph_json.h

index 35b6dae405041714a57957968c61dd306d01d3d3..a812d7af1a267d25d49af92386144cab00357f54 100644 (file)
@@ -164,6 +164,21 @@ void decode_json_obj(list<T>& l, JSONObj *obj)
   }
 }
 
+template<class T>
+void decode_json_obj(deque<T>& l, JSONObj *obj)
+{
+  l.clear();
+
+  JSONObjIter iter = obj->find_first();
+
+  for (; !iter.end(); ++iter) {
+    T val;
+    JSONObj *o = *iter;
+    decode_json_obj(val, o);
+    l.push_back(val);
+  }
+}
+
 template<class T>
 void decode_json_obj(set<T>& l, JSONObj *obj)
 {
@@ -342,6 +357,14 @@ static void encode_json(const char *name, const std::list<T>& l, ceph::Formatter
   f->close_section();
 }
 template<class T>
+static void encode_json(const char *name, const std::deque<T>& l, ceph::Formatter *f)
+{
+  f->open_array_section(name);
+  for (typename std::deque<T>::const_iterator iter = l.begin(); iter != l.end(); ++iter) {
+    encode_json("obj", *iter, f);
+  }
+  f->close_section();
+}template<class T>
 static void encode_json(const char *name, const std::set<T>& l, ceph::Formatter *f)
 {
   f->open_array_section(name);