]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove split formatter code
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 19 Jan 2016 17:46:32 +0000 (09:46 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 19 Jan 2016 17:46:32 +0000 (09:46 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/common/JSONFormatter.h [deleted file]
src/common/TableFormatter.h [deleted file]
src/common/XMLFormatter.cc [deleted file]
src/common/XMLFormatter.h [deleted file]

diff --git a/src/common/JSONFormatter.h b/src/common/JSONFormatter.h
deleted file mode 100644 (file)
index a6a5092..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-#ifndef CEPH_JSON_FORMATTER_H
-#define CEPH_JSON_FORMATTER_H
-
-#include "include/int_types.h"
-
-#include <deque>
-#include <iosfwd>
-#include <list>
-#include <vector>
-#include <sstream>
-#include <stdarg.h>
-#include <string>
-#include <map>
-
-#include "include/buffer.h"
-#include "Formatter.h"
-
-namespace ceph {
-  class JSONFormatter : public Formatter {
-  public:
-    JSONFormatter(bool p = false);
-
-    virtual void set_status(const char* status, const char* status_name) {};
-    virtual void output_header() {};
-    virtual void output_footer() {};
-    void flush(std::ostream& os);
-    void reset();
-    virtual void open_array_section(const char *name);
-    void open_array_section_in_ns(const char *name, const char *ns);
-    void open_object_section(const char *name);
-    void open_object_section_in_ns(const char *name, const char *ns);
-    void close_section();
-    void dump_unsigned(const char *name, uint64_t u);
-    void dump_int(const char *name, int64_t u);
-    void dump_float(const char *name, double d);
-    void dump_string(const char *name, const std::string& s);
-    std::ostream& dump_stream(const char *name);
-    void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap);
-    int get_len() const;
-    void write_raw_data(const char *data);
-
-  private:
-
-    struct json_formatter_stack_entry_d {
-      int size;
-      bool is_array;
-      json_formatter_stack_entry_d() : size(0), is_array(false) { }
-    };
-
-    bool m_pretty;
-    void open_section(const char *name, bool is_array);
-    void print_quoted_string(const std::string& s);
-    void print_name(const char *name);
-    void print_comma(json_formatter_stack_entry_d& entry);
-    void finish_pending_string();
-
-    std::stringstream m_ss, m_pending_string;
-    std::list<json_formatter_stack_entry_d> m_stack;
-    bool m_is_pending_string;
-  };
-
-}
-
-#endif
diff --git a/src/common/TableFormatter.h b/src/common/TableFormatter.h
deleted file mode 100644 (file)
index ba8f668..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-#ifndef CEPH_TABLE_FORMATTER_H
-#define CEPH_TABLE_FORMATTER_H
-
-#include "include/int_types.h"
-
-#include <deque>
-#include <iosfwd>
-#include <list>
-#include <vector>
-#include <sstream>
-#include <stdarg.h>
-#include <string>
-#include <map>
-
-#include "include/buffer.h"
-#include "Formatter.h"
-
-namespace ceph {
-  class TableFormatter : public Formatter {
-  public:
-    TableFormatter(bool keyval = false);
-
-    virtual void set_status(const char* status, const char* status_name) {};
-    virtual void output_header() {};
-    virtual void output_footer() {};
-    void flush(std::ostream& os);
-    void reset();
-    virtual void open_array_section(const char *name);
-    void open_array_section_in_ns(const char *name, const char *ns);
-    void open_object_section(const char *name);
-    void open_object_section_in_ns(const char *name, const char *ns);
-
-    void open_array_section_with_attrs(const char *name, const FormatterAttrs& attrs);
-    void open_object_section_with_attrs(const char *name, const FormatterAttrs& attrs);
-
-    void close_section();
-    void dump_unsigned(const char *name, uint64_t u);
-    void dump_int(const char *name, int64_t u);
-    void dump_float(const char *name, double d);
-    void dump_string(const char *name, const std::string& s);
-    void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap);
-    void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs);
-    std::ostream& dump_stream(const char *name);
-
-    int get_len() const;
-    void write_raw_data(const char *data);
-    void get_attrs_str(const FormatterAttrs *attrs, std::string& attrs_str);
-
-  private:
-    void open_section_in_ns(const char *name, const char *ns, const FormatterAttrs *attrs);
-    std::vector< std::vector<std::pair<std::string, std::string> > > m_vec;
-    std::stringstream m_ss;
-    size_t m_vec_index(const char* name);
-    std::string get_section_name(const char* name);
-    void finish_pending_string();
-    std::string m_pending_name;
-    bool m_keyval;
-
-    int m_section_open;
-    std::vector< std::string > m_section;
-    std::map<std::string, int> m_section_cnt;
-    std::vector<size_t> m_column_size;
-    std::vector< std::string > m_column_name;
-  };
-
-
-}
-
-#endif
diff --git a/src/common/XMLFormatter.cc b/src/common/XMLFormatter.cc
deleted file mode 100644 (file)
index 084fd40..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2011 New Dream Network
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-#define LARGE_SIZE 1024
-
-#include "include/int_types.h"
-
-#include "assert.h"
-#include "Formatter.h"
-#include "XMLFormatter.h"
-#include "common/escape.h"
-
-#include <iostream>
-#include <sstream>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <vector>
-#include <string>
-#include <set>
-#include <boost/format.hpp>
-
-// -----------------------
-namespace ceph {
-
-const char *XMLFormatter::XML_1_DTD =
-  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-
-XMLFormatter::XMLFormatter(bool pretty)
-: m_pretty(pretty)
-{
-  reset();
-}
-
-void XMLFormatter::flush(std::ostream& os)
-{
-  finish_pending_string();
-  std::string m_ss_str = m_ss.str();
-  os << m_ss_str;
-  /* There is a small catch here. If the rest of the formatter had NO output,
-   * we should NOT output a newline. This primarily triggers on HTTP redirects */
-  if (m_pretty && !m_ss_str.empty())
-    os << "\n";
-  m_ss.clear();
-  m_ss.str("");
-}
-
-void XMLFormatter::reset()
-{
-  m_ss.clear();
-  m_ss.str("");
-  m_pending_string.clear();
-  m_pending_string.str("");
-  m_sections.clear();
-  m_pending_string_name.clear();
-  m_header_done = false;
-}
-
-void XMLFormatter::output_header()
-{
-  if(!m_header_done) {
-    m_header_done = true;
-    write_raw_data(XMLFormatter::XML_1_DTD);;
-    if (m_pretty)
-      m_ss << "\n";
-  }
-}
-
-void XMLFormatter::output_footer()
-{
-  while(!m_sections.empty()) {
-    close_section();
-  }
-}
-
-void XMLFormatter::open_object_section(const char *name)
-{
-  open_section_in_ns(name, NULL, NULL);
-}
-
-void XMLFormatter::open_object_section_with_attrs(const char *name, const FormatterAttrs& attrs)
-{
-  open_section_in_ns(name, NULL, &attrs);
-}
-
-void XMLFormatter::open_object_section_in_ns(const char *name, const char *ns)
-{
-  open_section_in_ns(name, ns, NULL);
-}
-
-void XMLFormatter::open_array_section(const char *name)
-{
-  open_section_in_ns(name, NULL, NULL);
-}
-
-void XMLFormatter::open_array_section_with_attrs(const char *name, const FormatterAttrs& attrs)
-{
-  open_section_in_ns(name, NULL, &attrs);
-}
-
-void XMLFormatter::open_array_section_in_ns(const char *name, const char *ns)
-{
-  open_section_in_ns(name, ns, NULL);
-}
-
-void XMLFormatter::close_section()
-{
-  assert(!m_sections.empty());
-  finish_pending_string();
-
-  std::string section = m_sections.back();
-  m_sections.pop_back();
-  print_spaces();
-  m_ss << "</" << section << ">";
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-void XMLFormatter::dump_unsigned(const char *name, uint64_t u)
-{
-  std::string e(name);
-  print_spaces();
-  m_ss << "<" << e << ">" << u << "</" << e << ">";
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-void XMLFormatter::dump_int(const char *name, int64_t u)
-{
-  std::string e(name);
-  print_spaces();
-  m_ss << "<" << e << ">" << u << "</" << e << ">";
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-void XMLFormatter::dump_float(const char *name, double d)
-{
-  std::string e(name);
-  print_spaces();
-  m_ss << "<" << e << ">" << d << "</" << e << ">";
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-void XMLFormatter::dump_string(const char *name, const std::string& s)
-{
-  std::string e(name);
-  print_spaces();
-  m_ss << "<" << e << ">" << escape_xml_str(s.c_str()) << "</" << e << ">";
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-void XMLFormatter::dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs)
-{
-  std::string e(name);
-  std::string attrs_str;
-  get_attrs_str(&attrs, attrs_str);
-  print_spaces();
-  m_ss << "<" << e << attrs_str << ">" << escape_xml_str(s.c_str()) << "</" << e << ">";
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-std::ostream& XMLFormatter::dump_stream(const char *name)
-{
-  print_spaces();
-  m_pending_string_name = name;
-  m_ss << "<" << m_pending_string_name << ">";
-  return m_pending_string;
-}
-
-void XMLFormatter::dump_format_va(const char* name, const char *ns, bool quoted, const char *fmt, va_list ap)
-{
-  char buf[LARGE_SIZE];
-  vsnprintf(buf, LARGE_SIZE, fmt, ap);
-
-  std::string e(name);
-  print_spaces();
-  if (ns) {
-    m_ss << "<" << e << " xmlns=\"" << ns << "\">" << buf << "</" << e << ">";
-  } else {
-    m_ss << "<" << e << ">" << escape_xml_str(buf) << "</" << e << ">";
-  }
-
-  if (m_pretty)
-    m_ss << "\n";
-}
-
-int XMLFormatter::get_len() const
-{
-  return m_ss.str().size();
-}
-
-void XMLFormatter::write_raw_data(const char *data)
-{
-  m_ss << data;
-}
-
-void XMLFormatter::get_attrs_str(const FormatterAttrs *attrs, std::string& attrs_str)
-{
-  std::stringstream attrs_ss;
-
-  for (std::list<std::pair<std::string, std::string> >::const_iterator iter = attrs->attrs.begin();
-       iter != attrs->attrs.end(); ++iter) {
-    std::pair<std::string, std::string> p = *iter;
-    attrs_ss << " " << p.first << "=" << "\"" << p.second << "\"";
-  }
-
-  attrs_str = attrs_ss.str();
-}
-
-void XMLFormatter::open_section_in_ns(const char *name, const char *ns, const FormatterAttrs *attrs)
-{
-  print_spaces();
-  std::string attrs_str;
-
-  if (attrs) {
-    get_attrs_str(attrs, attrs_str);
-  }
-
-  if (ns) {
-    m_ss << "<" << name << attrs_str << " xmlns=\"" << ns << "\">";
-  } else {
-    m_ss << "<" << name << attrs_str << ">";
-  }
-  if (m_pretty)
-    m_ss << "\n";
-  m_sections.push_back(name);
-}
-
-void XMLFormatter::finish_pending_string()
-{
-  if (!m_pending_string_name.empty()) {
-    m_ss << escape_xml_str(m_pending_string.str().c_str())
-      << "</" << m_pending_string_name << ">";
-    m_pending_string_name.clear();
-    m_pending_string.str(std::string());
-    if (m_pretty) {
-      m_ss << "\n";
-    }
-  }
-}
-
-void XMLFormatter::print_spaces()
-{
-  finish_pending_string();
-  if (m_pretty) {
-    std::string spaces(m_sections.size(), ' ');
-    m_ss << spaces;
-  }
-}
-
-std::string XMLFormatter::escape_xml_str(const char *str)
-{
-  int len = escape_xml_attr_len(str);
-  std::vector<char> escaped(len, '\0');
-  escape_xml_attr(str, &escaped[0]);
-  return std::string(&escaped[0]);
-}
-
-} // namespace ceph
diff --git a/src/common/XMLFormatter.h b/src/common/XMLFormatter.h
deleted file mode 100644 (file)
index f455f5d..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-#ifndef CEPH_XML_FORMATTER_H
-#define CEPH_XML_FORMATTER_H
-
-#include "include/int_types.h"
-
-#include <deque>
-#include <iosfwd>
-#include <list>
-#include <vector>
-#include <sstream>
-#include <stdarg.h>
-#include <string>
-#include <map>
-
-#include "include/buffer.h"
-#include "Formatter.h"
-
-namespace ceph {
-  class XMLFormatter : public Formatter {
-  public:
-    static const char *XML_1_DTD;
-    XMLFormatter(bool pretty = false);
-
-    virtual void set_status(const char* status, const char* status_name) {};
-    virtual void output_header();
-    virtual void output_footer();
-
-    void flush(std::ostream& os);
-    void reset();
-    void open_array_section(const char *name);
-    void open_array_section_in_ns(const char *name, const char *ns);
-    void open_object_section(const char *name);
-    void open_object_section_in_ns(const char *name, const char *ns);
-    void close_section();
-    void dump_unsigned(const char *name, uint64_t u);
-    void dump_int(const char *name, int64_t u);
-    void dump_float(const char *name, double d);
-    void dump_string(const char *name, const std::string& s);
-    std::ostream& dump_stream(const char *name);
-    void dump_format_va(const char *name, const char *ns, bool quoted, const char *fmt, va_list ap);
-    int get_len() const;
-    void write_raw_data(const char *data);
-
-    /* with attrs */
-    void open_array_section_with_attrs(const char *name, const FormatterAttrs& attrs);
-    void open_object_section_with_attrs(const char *name, const FormatterAttrs& attrs);
-    void dump_string_with_attrs(const char *name, const std::string& s, const FormatterAttrs& attrs);
-  protected:
-    void open_section_in_ns(const char *name, const char *ns, const FormatterAttrs *attrs);
-    void finish_pending_string();
-    void print_spaces();
-    static std::string escape_xml_str(const char *str);
-    void get_attrs_str(const FormatterAttrs *attrs, std::string& attrs_str);
-
-    std::stringstream m_ss, m_pending_string;
-    std::deque<std::string> m_sections;
-    bool m_pretty;
-    std::string m_pending_string_name;
-    bool m_header_done;
-  };
-
-}
-
-#endif