[dbg] Pull out common code into dbg-lib
- Modularize common routines - Extract the block_dumper interface for displaying blocks - Remove inheritance from show_traits
This commit is contained in:
37
dbg-lib/output_formatter.h
Normal file
37
dbg-lib/output_formatter.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#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() {}
|
||||
virtual void field(std::string const &name, std::string const &value) = 0;
|
||||
virtual void child(std::string const &name, formatter::ptr t) = 0;
|
||||
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));
|
||||
}
|
||||
|
||||
formatter::ptr create_xml_formatter();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user