| 97 | void Formatter::write_bin_data(const char*, int){} |
| 98 | |
| 99 | Formatter *Formatter::create(std::string_view type, |
| 100 | std::string_view default_type, |
| 101 | std::string_view fallback) |
| 102 | { |
| 103 | std::string_view mytype(type); |
| 104 | if (mytype.empty()) { |
| 105 | mytype = default_type; |
| 106 | } |
| 107 | |
| 108 | if (mytype == "json") |
| 109 | return new JSONFormatter(false); |
| 110 | else if (mytype == "json-pretty") |
| 111 | return new JSONFormatter(true); |
| 112 | else if (mytype == "xml") |
| 113 | return new XMLFormatter(false); |
| 114 | else if (mytype == "xml-pretty") |
| 115 | return new XMLFormatter(true); |
| 116 | else if (mytype == "table") |
| 117 | return new TableFormatter(); |
| 118 | else if (mytype == "table-kv") |
| 119 | return new TableFormatter(true); |
| 120 | else if (mytype == "html") |
| 121 | return new HTMLFormatter(false); |
| 122 | else if (mytype == "html-pretty") |
| 123 | return new HTMLFormatter(true); |
| 124 | else if (fallback != "") |
| 125 | return create(fallback, "", ""); |
| 126 | else |
| 127 | return (Formatter *) NULL; |
| 128 | } |
| 129 | |
| 130 | |
| 131 | void Formatter::flush(bufferlist &bl) |