2021-01-21 13:35:28 +05:30
|
|
|
#ifndef DBG_OUTPUT_FORMATTER_H
|
|
|
|
#define DBG_OUTPUT_FORMATTER_H
|
|
|
|
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
#include <boost/tuple/tuple.hpp>
|
|
|
|
#include <boost/variant.hpp>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace dbg {
|
|
|
|
class formatter {
|
|
|
|
public:
|
|
|
|
typedef std::shared_ptr<formatter> ptr;
|
|
|
|
|
|
|
|
virtual ~formatter() {}
|
2021-02-03 14:41:24 +05:30
|
|
|
virtual void field(std::string const &name, std::string const &value) = 0;
|
|
|
|
virtual void child(std::string const &name, formatter::ptr t) = 0;
|
2021-01-21 13:35:28 +05:30
|
|
|
virtual void output(std::ostream &out, int depth = 0,
|
|
|
|
boost::optional<std::string> name = boost::none) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void
|
|
|
|
field(formatter &t, std::string const &name, T const &value) {
|
|
|
|
t.field(name, boost::lexical_cast<std::string>(value));
|
|
|
|
}
|
|
|
|
|
2021-02-03 14:41:24 +05:30
|
|
|
formatter::ptr create_xml_formatter();
|
2021-01-21 13:35:28 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|