21 #ifndef INCLUDE_OLA_MESSAGING_SCHEMAPRINTER_H_
22 #define INCLUDE_OLA_MESSAGING_SCHEMAPRINTER_H_
24 #include <ola/messaging/DescriptorVisitor.h>
38 bool include_labels =
true,
39 unsigned int indent_size = DEFAULT_INDENT)
40 : m_include_intervals(include_intervals),
41 m_include_labels(include_labels),
43 m_indent_size(indent_size) {
47 bool Descend()
const {
return true; }
48 string AsString() {
return m_str.str(); }
49 void Reset() { m_str.str(
""); }
65 bool m_include_intervals, m_include_labels;
66 std::stringstream m_str;
67 unsigned int m_indent, m_indent_size;
69 void AppendHeading(
const string &name,
const string &type);
71 template<
class vector_
class>
72 void MaybeAppendIntervals(
const vector_class &intervals) {
73 if (!m_include_intervals)
75 typename vector_class::const_iterator iter = intervals.begin();
76 for (; iter != intervals.end(); ++iter) {
77 if (iter->first == iter->second) {
78 m_str << (iter == intervals.begin() ?
": " :
", ") <<
79 static_cast<int64_t>(iter->first);
81 m_str << (iter == intervals.begin() ?
": " :
", ") <<
"(" <<
82 static_cast<int64_t>(iter->first) <<
", " <<
83 static_cast<int64_t
>(iter->second) <<
")";
88 template<
class map_
class>
89 void MaybeAppendLabels(
const map_class &labels) {
90 if (!m_include_labels)
92 typename map_class::const_iterator iter = labels.begin();
93 for (; iter != labels.end(); ++iter) {
94 m_str << std::endl << string(m_indent + m_indent_size,
' ') <<
95 iter->first <<
": " <<
static_cast<int64_t
>(iter->second);
99 static const unsigned int DEFAULT_INDENT = 2;
103 #endif // INCLUDE_OLA_MESSAGING_SCHEMAPRINTER_H_