}
}
+void decode_json_obj(ceph::real_time& val, JSONObj *obj)
+{
+ const std::string& s = obj->get_data();
+ uint64_t epoch;
+ uint64_t nsec;
+ int r = utime_t::parse_date(s, &epoch, &nsec);
+ if (r == 0) {
+ using namespace std::chrono;
+ val = real_time{seconds(epoch) + nanoseconds(nsec)};
+ } else {
+ throw JSONDecoder::err("failed to decode real_time");
+ }
+}
+
+void decode_json_obj(ceph::coarse_real_time& val, JSONObj *obj)
+{
+ const std::string& s = obj->get_data();
+ uint64_t epoch;
+ uint64_t nsec;
+ int r = utime_t::parse_date(s, &epoch, &nsec);
+ if (r == 0) {
+ using namespace std::chrono;
+ val = coarse_real_time{seconds(epoch) + nanoseconds(nsec)};
+ } else {
+ throw JSONDecoder::err("failed to decode coarse_real_time");
+ }
+}
+
void decode_json_obj(ceph_dir_layout& i, JSONObj *obj){
unsigned tmp;
val.gmtime(f->dump_stream(name));
}
+void encode_json(const char *name, const ceph::real_time& val, Formatter *f)
+{
+ encode_json(name, utime_t{val}, f);
+}
+
+void encode_json(const char *name, const ceph::coarse_real_time& val, Formatter *f)
+{
+ encode_json(name, utime_t{val}, f);
+}
+
void encode_json(const char *name, const bufferlist& bl, Formatter *f)
{
/* need to copy data from bl, as it is const bufferlist */
#include <include/types.h>
#include <boost/container/flat_map.hpp>
#include <include/ceph_fs.h>
+#include "common/ceph_time.h"
#include "json_spirit/json_spirit.h"
void decode_json_obj(utime_t& val, JSONObj *obj);
void decode_json_obj(ceph_dir_layout& i, JSONObj *obj);
+void decode_json_obj(ceph::real_time& val, JSONObj *obj);
+void decode_json_obj(ceph::coarse_real_time& val, JSONObj *obj);
+
template<class T>
void decode_json_obj(std::list<T>& l, JSONObj *obj)
{
void encode_json(const char *name, const ceph::buffer::list& bl, ceph::Formatter *f);
void encode_json(const char *name, long long unsigned val, ceph::Formatter *f);
+void encode_json(const char *name, const ceph::real_time& val, ceph::Formatter *f);
+void encode_json(const char *name, const ceph::coarse_real_time& val, ceph::Formatter *f);
+
template<class T>
static void encode_json(const char *name, const std::list<T>& l, ceph::Formatter *f)
{