rgw_formats: dump_format_ns implementation

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>
This commit is contained in:
Abhishek Lekshmanan 2014-08-27 16:11:53 +05:30
parent 2fb51b2b58
commit eaa2bb0aab
2 changed files with 31 additions and 0 deletions

View 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

View 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);