diff options
author | Sage Weil <sage.weil@dreamhost.com> | 2012-02-24 06:07:40 -0800 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2012-02-24 11:24:44 -0800 |
commit | 6c257c4d1244f0c246712bfa401abd559f4d7a8c (patch) | |
tree | dae325c43d128557493860d371922b39e5005eaf | |
parent | 2677c72fde7e3a3357c2edf50288737d7ff3c736 (diff) | |
download | ceph-6c257c4d1244f0c246712bfa401abd559f4d7a8c.tar.gz |
hobject_t: decode json
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
-rw-r--r-- | src/os/hobject.cc | 19 | ||||
-rw-r--r-- | src/os/hobject.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/os/hobject.cc b/src/os/hobject.cc index dabdb0ce6a0..77d576870bc 100644 --- a/src/os/hobject.cc +++ b/src/os/hobject.cc @@ -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); diff --git a/src/os/hobject.h b/src/os/hobject.h index 180ebcf3d44..ee50f5b1d90 100644 --- a/src/os/hobject.h +++ b/src/os/hobject.h @@ -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); }; |