92
92
// Like TextFormat::Print
93
bool Print(const Message& message, io::ZeroCopyOutputStream* output);
93
bool Print(const Message& message, io::ZeroCopyOutputStream* output) const;
94
94
// Like TextFormat::PrintUnknownFields
95
95
bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
96
io::ZeroCopyOutputStream* output);
96
io::ZeroCopyOutputStream* output) const;
97
97
// Like TextFormat::PrintToString
98
bool PrintToString(const Message& message, string* output);
98
bool PrintToString(const Message& message, string* output) const;
99
99
// Like TextFormat::PrintUnknownFieldsToString
100
100
bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
101
string* output) const;
102
102
// Like TextFormat::PrintFieldValueToString
103
103
void PrintFieldValueToString(const Message& message,
104
104
const FieldDescriptor* field,
106
string* output) const;
108
108
// Adjust the initial indent level of all output. Each indent level is
109
109
// equal to two spaces.
121
121
// field_name: [1, 2, 3, 4]
122
122
// instead of printing each value on its own line. Short format applies
123
123
// only to primitive values -- i.e. everything except strings and
124
// sub-messages/groups. Note that at present this format is not recognized
124
// sub-messages/groups.
126
125
void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) {
127
126
use_short_repeated_primitives_ = use_short_repeated_primitives;
143
142
// Internal Print method, used for writing to the OutputStream via
144
143
// the TextGenerator class.
145
144
void Print(const Message& message,
146
TextGenerator& generator);
145
TextGenerator& generator) const;
148
147
// Print a single field.
149
148
void PrintField(const Message& message,
150
149
const Reflection* reflection,
151
150
const FieldDescriptor* field,
152
TextGenerator& generator);
151
TextGenerator& generator) const;
154
153
// Print a repeated primitive field in short form.
155
154
void PrintShortRepeatedField(const Message& message,
156
155
const Reflection* reflection,
157
156
const FieldDescriptor* field,
158
TextGenerator& generator);
157
TextGenerator& generator) const;
160
159
// Print the name of a field -- i.e. everything that comes before the
161
160
// ':' for a single name/value pair.
162
161
void PrintFieldName(const Message& message,
163
162
const Reflection* reflection,
164
163
const FieldDescriptor* field,
165
TextGenerator& generator);
164
TextGenerator& generator) const;
167
166
// Outputs a textual representation of the value of the field supplied on
168
167
// the message supplied or the default value if not set.
170
169
const Reflection* reflection,
171
170
const FieldDescriptor* field,
173
TextGenerator& generator);
172
TextGenerator& generator) const;
175
174
// Print the fields in an UnknownFieldSet. They are printed by tag number
176
175
// only. Embedded messages are heuristically identified by attempting to
178
177
void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
179
TextGenerator& generator);
178
TextGenerator& generator) const;
181
180
int initial_indent_level_;
207
206
const FieldDescriptor* field,
208
207
Message* message);
209
// Interface that TextFormat::Parser can use to find extensions.
210
// This class may be extended in the future to find more information
212
class LIBPROTOBUF_EXPORT Finder {
216
// Try to find an extension of *message by fully-qualified field
217
// name. Returns NULL if no extension is known for this name or number.
218
virtual const FieldDescriptor* FindExtension(
220
const string& name) const = 0;
210
223
// For more control over parsing, use this class.
211
224
class LIBPROTOBUF_EXPORT Parser {
228
241
error_collector_ = error_collector;
244
// Set how parser finds extensions. If NULL (the default), the
245
// parser will use the standard Reflection object associated with
246
// the message being parsed.
247
void SetFinder(Finder* finder) {
231
251
// Normally parsing fails if, after parsing, output->IsInitialized()
232
252
// returns false. Call AllowPartialMessage(true) to skip this check.
233
253
void AllowPartialMessage(bool allow) {