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 std::string AsString() {
return m_str.str(); }
49 void Reset() { m_str.str(
""); }
66 bool m_include_intervals, m_include_labels;
67 std::ostringstream m_str;
68 unsigned int m_indent, m_indent_size;
70 void AppendHeading(
const std::string &name,
const std::string &type);
72 template<
class vector_
class>
73 void MaybeAppendIntervals(
const vector_class &intervals) {
74 if (!m_include_intervals)
76 typename vector_class::const_iterator iter = intervals.begin();
77 for (; iter != intervals.end(); ++iter) {
78 if (iter->first == iter->second) {
79 m_str << (iter == intervals.begin() ?
": " :
", ") <<
80 static_cast<int64_t>(iter->first);
82 m_str << (iter == intervals.begin() ?
": " :
", ") <<
"(" <<
83 static_cast<int64_t>(iter->first) <<
", " <<
84 static_cast<int64_t
>(iter->second) <<
")";
89 template<
class map_
class>
90 void MaybeAppendLabels(
const map_class &labels) {
91 if (!m_include_labels)
93 typename map_class::const_iterator iter = labels.begin();
94 for (; iter != labels.end(); ++iter) {
95 m_str << std::endl << std::string(m_indent + m_indent_size,
' ') <<
96 iter->first <<
": " <<
static_cast<int64_t
>(iter->second);
100 static const unsigned int DEFAULT_INDENT = 2;
104 #endif // INCLUDE_OLA_MESSAGING_SCHEMAPRINTER_H_
Definition: Descriptor.h:84
Definition: DescriptorVisitor.h:43
Definition: Descriptor.h:122
Definition: SchemaPrinter.h:35
Definition: Descriptor.h:320
Definition: Descriptor.h:141
Definition: Descriptor.h:103
Definition: Descriptor.h:160
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: Descriptor.h:190