85
// Class for those users which require more fine-grained control over how
86
// a protobuffer message is printed out.
87
class LIBPROTOBUF_EXPORT Printer {
92
// Like TextFormat::Print
93
bool Print(const Message& message, io::ZeroCopyOutputStream* output);
94
// Like TextFormat::PrintUnknownFields
95
bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
96
io::ZeroCopyOutputStream* output);
97
// Like TextFormat::PrintToString
98
bool PrintToString(const Message& message, string* output);
99
// Like TextFormat::PrintUnknownFieldsToString
100
bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
102
// Like TextFormat::PrintFieldValueToString
103
void PrintFieldValueToString(const Message& message,
104
const FieldDescriptor* field,
108
// Adjust the initial indent level of all output. Each indent level is
109
// equal to two spaces.
110
void SetInitialIndentLevel(int indent_level) {
111
initial_indent_level_ = indent_level;
114
// If printing in single line mode, then the entire message will be output
115
// on a single line with no line breaks.
116
void SetSingleLineMode(bool single_line_mode) {
117
single_line_mode_ = single_line_mode;
121
// Forward declaration of an internal class used to print the text
122
// output to the OutputStream (see text_format.cc for implementation).
125
// Internal Print method, used for writing to the OutputStream via
126
// the TextGenerator class.
127
void Print(const Message& message,
128
TextGenerator& generator);
130
// Print a single field.
131
void PrintField(const Message& message,
132
const Reflection* reflection,
133
const FieldDescriptor* field,
134
TextGenerator& generator);
136
// Outputs a textual representation of the value of the field supplied on
137
// the message supplied or the default value if not set.
138
void PrintFieldValue(const Message& message,
139
const Reflection* reflection,
140
const FieldDescriptor* field,
142
TextGenerator& generator);
144
// Print the fields in an UnknownFieldSet. They are printed by tag number
145
// only. Embedded messages are heuristically identified by attempting to
147
void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
148
TextGenerator& generator);
150
int initial_indent_level_;
152
bool single_line_mode_;
85
155
// Parses a text-format protocol message from the given input stream to
86
156
// the given message object. This function parses the format written
141
// Forward declaration of an internal class used to print the text
142
// output to the OutputStream (see text_format.cc for implementation).
145
// Internal Print method, used for writing to the OutputStream via
146
// the TextGenerator class.
147
static void Print(const Message& message,
148
TextGenerator& generator);
150
// Print a single field.
151
static void PrintField(const Message& message,
152
const Reflection* reflection,
153
const FieldDescriptor* field,
154
TextGenerator& generator);
156
// Outputs a textual representation of the value of the field supplied on
157
// the message supplied or the default value if not set.
158
static void PrintFieldValue(const Message& message,
159
const Reflection* reflection,
160
const FieldDescriptor* field,
162
TextGenerator& generator);
164
// Print the fields in an UnknownFieldSet. They are printed by tag number
165
// only. Embedded messages are heuristically identified by attempting to
167
static void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
168
TextGenerator& generator);
170
211
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat);