[dbg] Hide implementations of shared components
This commit is contained in:
@@ -8,6 +8,31 @@ using namespace std;
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
class abstract_formatter : public formatter {
|
||||
typedef boost::optional<std::string> maybe_string;
|
||||
|
||||
void field(std::string const &name, std::string const &value) {
|
||||
fields_.push_back(field_type(name, value));
|
||||
}
|
||||
|
||||
void child(std::string const &name, formatter::ptr t) {
|
||||
children_.push_back(field_type(name, t));
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef boost::variant<std::string, ptr> value;
|
||||
typedef boost::tuple<std::string, value> field_type;
|
||||
|
||||
std::vector<field_type> fields_;
|
||||
std::vector<field_type> children_;
|
||||
};
|
||||
|
||||
class xml_formatter : public abstract_formatter {
|
||||
public:
|
||||
void output(std::ostream &out, int depth = 0,
|
||||
boost::optional<std::string> name = boost::none);
|
||||
};
|
||||
|
||||
void indent(int depth, std::ostream &out) {
|
||||
for (int i = 0; i < depth * 2; i++)
|
||||
out << ' ';
|
||||
@@ -51,3 +76,11 @@ void xml_formatter::output(std::ostream &out,
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
formatter::ptr
|
||||
dbg::create_xml_formatter()
|
||||
{
|
||||
return formatter::ptr(new xml_formatter());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user