]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hobject_t: decode json
authorSage Weil <sage.weil@dreamhost.com>
Fri, 24 Feb 2012 14:07:40 +0000 (06:07 -0800)
committerSage Weil <sage@newdream.net>
Fri, 24 Feb 2012 19:24:44 +0000 (11:24 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/os/hobject.cc
src/os/hobject.h

index dabdb0ce6a047e9e07dcc1e0018e0e763c642bf0..77d576870bc64e53576e21d74c41ec9dfb062470 100644 (file)
@@ -29,6 +29,25 @@ void hobject_t::decode(bufferlist::iterator& bl)
   DECODE_FINISH(bl);
 }
 
+void hobject_t::decode(json_spirit::Value& v)
+{
+  using namespace json_spirit;
+  Object& o = v.get_obj();
+  for (Object::size_type i=0; i<o.size(); i++) {
+    Pair& p = o[i];
+    if (p.name_ == "oid")
+      oid.name = p.value_.get_str();
+    else if (p.name_ == "key")
+      key = p.value_.get_str();
+    else if (p.name_ == "snapid")
+      snap = p.value_.get_uint64();
+    else if (p.name_ == "hash")
+      hash = p.value_.get_int();
+    else if (p.name_ == "max")
+      max = p.value_.get_int();
+  }
+}
+
 void hobject_t::dump(Formatter *f) const
 {
   f->dump_string("oid", oid.name);
index 180ebcf3d44b82788561a6dba4ae7705e40f6adb..ee50f5b1d907c2a08a4df3630772c1084b8180c1 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "include/object.h"
 #include "include/cmp.h"
+#include "json_spirit/json_spirit_value.h"
 
 typedef uint64_t filestore_hobject_key_t;
 
@@ -102,6 +103,7 @@ public:
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& bl);
+  void decode(json_spirit::Value& v);
   void dump(Formatter *f) const;
   static void generate_test_instances(list<hobject_t*>& o);
 };