]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_formats: dump_format_ns implementation
authorAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Wed, 27 Aug 2014 10:41:53 +0000 (16:11 +0530)
committerAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Fri, 5 Sep 2014 03:34:48 +0000 (09:04 +0530)
Since the base formatter was extended with a dump_format_ns class,
implementing this here. For now, this is exactly same as dump_format, as
the concept of ns in json is not used.

Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@ril.com>
src/rgw/rgw_formats.cc
src/rgw/rgw_formats.h

index b69415195a5f7c4b880f4baa0b129822ec45ad24..6008f7f4ed930885a27a5abb40ac8d2ca2a8bfd2 100644 (file)
@@ -150,6 +150,36 @@ void RGWFormatter_Plain::dump_format(const char *name, const char *fmt, ...)
   write_data(format, buf);
 }
 
+void RGWFormatter_Plain::dump_format_ns(const char *name, const char *fmt, const char *ns, ...)
+{
+  // ignore the namespace for now
+  char buf[LARGE_SIZE];
+  va_list ap;
+  const char *format;
+
+  struct plain_stack_entry& entry = stack.back();
+
+  if (!min_stack_level)
+    min_stack_level = stack.size();
+
+  bool should_print = (stack.size() == min_stack_level && !entry.size);
+
+  entry.size++;
+
+  if (!should_print)
+    return;
+
+  va_start(ap, fmt);
+  vsnprintf(buf, LARGE_SIZE, fmt, ap);
+  va_end(ap);
+  if (len)
+    format = "\n%s";
+  else
+    format = "%s";
+
+  write_data(format, buf);
+}
+
 int RGWFormatter_Plain::get_len() const
 {
   // don't include null termination in length
index 017be090cd20bece0fc5d3cb41a6401809f7a50d..aff53dc5345300d71f030ee78e924f6e68c9ee34 100644 (file)
@@ -42,6 +42,7 @@ public:
   virtual void dump_format_unquoted(const char *name, const char *fmt, ...) {
     assert(0 == "not implemented");
   }
+  virtual void dump_format_ns(const char *name, const char *ns, const char *fmt, ...);
   virtual int get_len() const;
   virtual void write_raw_data(const char *data);