-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatter.h
144 lines (113 loc) · 3.23 KB
/
formatter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef datastream_formatter
#define datastream_formatter
#include "datastream_definitions.h"
#include "quote.h"
#include "indent.h"
#include <iostream>
#include <boost/optional.hpp>
namespace datastream {
using std::ostream;
class Formatter{
public:
virtual ~Formatter() = default;
virtual void up(unsigned int i = 1);
virtual void down(unsigned int i = 1);
virtual void setDepth(unsigned int i = 1);
/* Drew Dormann -
This was perhaps overlooked? I'm not certain. I noticed it
after implementing the "override" modifier.
Mat
LabelChild is only needed internally in the json classes,
i've made it private
*/
virtual void separate(
ostream & os,
unsigned int siblings_written = 0,
unsigned int extraIndent = 0
);
virtual void step(
ostream & os,
unsigned int siblings_written = 0,
unsigned int extraIndent = 0
);
virtual void stepUp(
ostream & os,
unsigned int siblings_written = 0,
unsigned int extraIndent = 0
);
virtual void stepDown(
ostream & os,
unsigned int siblings_written = 0,
unsigned int extraIndent = 0
);
virtual void openGroup(
ostream & os,
const string& group_label,
const string& row_label,
unsigned int & siblings_written,
RowWrapper parent_row_wrapper,
bool single_child_per_parent,
GroupWrapper group_wrapper
);
virtual void closeGroup(
ostream & os,
const string& group_label,
const string& row_label,
unsigned int & siblings_written,
RowWrapper parent_row_wrapper,
bool single_child_per_parent,
GroupWrapper group_wrapper
);
virtual void openElement(
ostream & os,
const string& label,
RowWrapper row_wrapper,
unsigned int & siblings_written
);
virtual void writeValue(
ostream & os,
const string& name,
const boost::optional<string>& value,
ElementDataType data_type,
unsigned int & siblings_written
);
virtual void writeElement(
ostream & os,
const string& name,
const boost::optional<string>& value,
ElementDataType data_type,
GroupWrapper parent_group_wrapper,
RowWrapper parent_row_wrapper,
unsigned int & siblings_written
);
virtual void writeEmptyGroup(
ostream & os,
const string& group_label,
const string& row_label,
unsigned int & siblings_written,
RowWrapper parent_row_wrapper,
bool single_child_per_parent,
GroupWrapper group_wrapper,
RowWrapper rowWrapper
);
virtual void open(ostream & os, GroupWrapper group_wrapper);
virtual void openRow(ostream & os, const string& name, RowWrapper rowWrapper, unsigned int & siblings_written );
virtual void closeRow(ostream & os, const string& name, RowWrapper rowWrapper);
virtual void closeElement(ostream & os, const string& name, RowWrapper row_wrapper, unsigned int & siblings_written );
virtual void close(ostream & os, GroupWrapper group_wrapper);
protected:
string new_line_token = newline;
string open_row_token = open_brace;
string close_token = close_brace;
string open_array_token = open_bracket;
string close_array_token = close_bracket;
string null_token = null_keyword;
string seperator = ",";
string divider = space_colon_space;
string indent = tab;
string quote = double_quote;
int depth = 0;
bool clean = true;
};
}
#endif