text_format.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: jschorr@google.com (Joseph Schorr)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 //
35 // Utilities for printing and parsing protocol messages in a human-readable,
36 // text-based format.
37 
38 #ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__
39 #define GOOGLE_PROTOBUF_TEXT_FORMAT_H__
40 
41 #include <map>
42 #include <memory>
43 #include <string>
44 #include <vector>
45 
50 #include <google/protobuf/port.h>
51 
52 #include <google/protobuf/port_def.inc>
53 
54 #ifdef SWIG
55 #error "You cannot SWIG proto headers"
56 #endif
57 
58 namespace google {
59 namespace protobuf {
60 
61 namespace io {
62 class ErrorCollector; // tokenizer.h
63 }
64 
65 // This class implements protocol buffer text format. Printing and parsing
66 // protocol messages in text format is useful for debugging and human editing
67 // of messages.
68 //
69 // This class is really a namespace that contains only static methods.
70 class PROTOBUF_EXPORT TextFormat {
71  public:
72  // Outputs a textual representation of the given message to the given
73  // output stream. Returns false if printing fails.
74  static bool Print(const Message& message, io::ZeroCopyOutputStream* output);
75 
76  // Print the fields in an UnknownFieldSet. They are printed by tag number
77  // only. Embedded messages are heuristically identified by attempting to
78  // parse them. Returns false if printing fails.
79  static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
81 
82  // Like Print(), but outputs directly to a string.
83  // Note: output will be cleared prior to printing, and will be left empty
84  // even if printing fails. Returns false if printing fails.
85  static bool PrintToString(const Message& message, std::string* output);
86 
87  // Like PrintUnknownFields(), but outputs directly to a string. Returns
88  // false if printing fails.
89  static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
91 
92  // Outputs a textual representation of the value of the field supplied on
93  // the message supplied. For non-repeated fields, an index of -1 must
94  // be supplied. Note that this method will print the default value for a
95  // field if it is not set.
96  static void PrintFieldValueToString(const Message& message,
97  const FieldDescriptor* field, int index,
99 
100  class PROTOBUF_EXPORT BaseTextGenerator {
101  public:
102  virtual ~BaseTextGenerator();
103 
104  virtual void Indent() {}
105  virtual void Outdent() {}
106 
107  // Print text to the output stream.
108  virtual void Print(const char* text, size_t size) = 0;
109 
110  void PrintString(const std::string& str) { Print(str.data(), str.size()); }
111 
112  template <size_t n>
113  void PrintLiteral(const char (&text)[n]) {
114  Print(text, n - 1); // n includes the terminating zero character.
115  }
116  };
117 
118  // The default printer that converts scalar values from fields into their
119  // string representation.
120  // You can derive from this FastFieldValuePrinter if you want to have fields
121  // to be printed in a different way and register it at the Printer.
122  class PROTOBUF_EXPORT FastFieldValuePrinter {
123  public:
125  virtual ~FastFieldValuePrinter();
126  virtual void PrintBool(bool val, BaseTextGenerator* generator) const;
127  virtual void PrintInt32(int32 val, BaseTextGenerator* generator) const;
128  virtual void PrintUInt32(uint32 val, BaseTextGenerator* generator) const;
129  virtual void PrintInt64(int64 val, BaseTextGenerator* generator) const;
130  virtual void PrintUInt64(uint64 val, BaseTextGenerator* generator) const;
131  virtual void PrintFloat(float val, BaseTextGenerator* generator) const;
132  virtual void PrintDouble(double val, BaseTextGenerator* generator) const;
133  virtual void PrintString(const std::string& val,
134  BaseTextGenerator* generator) const;
135  virtual void PrintBytes(const std::string& val,
136  BaseTextGenerator* generator) const;
137  virtual void PrintEnum(int32 val, const std::string& name,
138  BaseTextGenerator* generator) const;
139  virtual void PrintFieldName(const Message& message, int field_index,
140  int field_count, const Reflection* reflection,
141  const FieldDescriptor* field,
142  BaseTextGenerator* generator) const;
143  virtual void PrintFieldName(const Message& message,
144  const Reflection* reflection,
145  const FieldDescriptor* field,
146  BaseTextGenerator* generator) const;
147  virtual void PrintMessageStart(const Message& message, int field_index,
148  int field_count, bool single_line_mode,
149  BaseTextGenerator* generator) const;
150  virtual void PrintMessageEnd(const Message& message, int field_index,
151  int field_count, bool single_line_mode,
152  BaseTextGenerator* generator) const;
153 
154  private:
156  };
157 
158  class PROTOBUF_EXPORT PROTOBUF_DEPRECATED_MSG(
159  "Please use FastFieldValuePrinter") FieldValuePrinter {
160  public:
161  FieldValuePrinter();
162  virtual ~FieldValuePrinter();
163  virtual std::string PrintBool(bool val) const;
164  virtual std::string PrintInt32(int32 val) const;
165  virtual std::string PrintUInt32(uint32 val) const;
166  virtual std::string PrintInt64(int64 val) const;
167  virtual std::string PrintUInt64(uint64 val) const;
168  virtual std::string PrintFloat(float val) const;
169  virtual std::string PrintDouble(double val) const;
170  virtual std::string PrintString(const std::string& val) const;
171  virtual std::string PrintBytes(const std::string& val) const;
172  virtual std::string PrintEnum(int32 val, const std::string& name) const;
173  virtual std::string PrintFieldName(const Message& message,
174  const Reflection* reflection,
175  const FieldDescriptor* field) const;
176  virtual std::string PrintMessageStart(const Message& message,
177  int field_index, int field_count,
178  bool single_line_mode) const;
179  virtual std::string PrintMessageEnd(const Message& message, int field_index,
180  int field_count,
181  bool single_line_mode) const;
182 
183  private:
185  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldValuePrinter);
186  };
187 
188  class PROTOBUF_EXPORT MessagePrinter {
189  public:
191  virtual ~MessagePrinter() {}
192  virtual void Print(const Message& message, bool single_line_mode,
193  BaseTextGenerator* generator) const = 0;
194 
195  private:
197  };
198 
199  // Interface that Printers or Parsers can use to find extensions, or types
200  // referenced in Any messages.
201  class PROTOBUF_EXPORT Finder {
202  public:
203  virtual ~Finder();
204 
205  // Try to find an extension of *message by fully-qualified field
206  // name. Returns NULL if no extension is known for this name or number.
207  // The base implementation uses the extensions already known by the message.
208  virtual const FieldDescriptor* FindExtension(Message* message,
209  const std::string& name) const;
210 
211  // Similar to FindExtension, but uses a Descriptor and the extension number
212  // instead of using a Message and the name when doing the look up.
213  virtual const FieldDescriptor* FindExtensionByNumber(
214  const Descriptor* descriptor, int number) const;
215 
216  // Find the message type for an Any proto.
217  // Returns NULL if no message is known for this name.
218  // The base implementation only accepts prefixes of type.googleprod.com/ or
219  // type.googleapis.com/, and searches the DescriptorPool of the parent
220  // message.
221  virtual const Descriptor* FindAnyType(const Message& message,
222  const std::string& prefix,
223  const std::string& name) const;
224 
225  // Find the message factory for the given extension field. This can be used
226  // to generalize the Parser to add extension fields to a message in the same
227  // way as the "input" message for the Parser.
228  virtual MessageFactory* FindExtensionFactory(
229  const FieldDescriptor* field) const;
230  };
231 
232  // Class for those users which require more fine-grained control over how
233  // a protobuffer message is printed out.
234  class PROTOBUF_EXPORT Printer {
235  public:
236  Printer();
237  ~Printer();
238 
239  // Like TextFormat::Print
240  bool Print(const Message& message, io::ZeroCopyOutputStream* output) const;
241  // Like TextFormat::PrintUnknownFields
242  bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
244  // Like TextFormat::PrintToString
245  bool PrintToString(const Message& message, std::string* output) const;
246  // Like TextFormat::PrintUnknownFieldsToString
247  bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
248  std::string* output) const;
249  // Like TextFormat::PrintFieldValueToString
250  void PrintFieldValueToString(const Message& message,
251  const FieldDescriptor* field, int index,
252  std::string* output) const;
253 
254  // Adjust the initial indent level of all output. Each indent level is
255  // equal to two spaces.
256  void SetInitialIndentLevel(int indent_level) {
257  initial_indent_level_ = indent_level;
258  }
259 
260  // If printing in single line mode, then the entire message will be output
261  // on a single line with no line breaks.
262  void SetSingleLineMode(bool single_line_mode) {
263  single_line_mode_ = single_line_mode;
264  }
265 
266  bool IsInSingleLineMode() const { return single_line_mode_; }
267 
268  // If use_field_number is true, uses field number instead of field name.
269  void SetUseFieldNumber(bool use_field_number) {
270  use_field_number_ = use_field_number;
271  }
272 
273  // Set true to print repeated primitives in a format like:
274  // field_name: [1, 2, 3, 4]
275  // instead of printing each value on its own line. Short format applies
276  // only to primitive values -- i.e. everything except strings and
277  // sub-messages/groups.
278  void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) {
279  use_short_repeated_primitives_ = use_short_repeated_primitives;
280  }
281 
282  // Set true to output UTF-8 instead of ASCII. The only difference
283  // is that bytes >= 0x80 in string fields will not be escaped,
284  // because they are assumed to be part of UTF-8 multi-byte
285  // sequences. This will change the default FastFieldValuePrinter.
286  void SetUseUtf8StringEscaping(bool as_utf8);
287 
288  // Set the default (Fast)FieldValuePrinter that is used for all fields that
289  // don't have a field-specific printer registered.
290  // Takes ownership of the printer.
291  void SetDefaultFieldValuePrinter(const FastFieldValuePrinter* printer);
292  void SetDefaultFieldValuePrinter(const FieldValuePrinter* printer);
293 
294  // Sets whether we want to hide unknown fields or not.
295  // Usually unknown fields are printed in a generic way that includes the
296  // tag number of the field instead of field name. However, sometimes it
297  // is useful to be able to print the message without unknown fields (e.g.
298  // for the python protobuf version to maintain consistency between its pure
299  // python and c++ implementations).
300  void SetHideUnknownFields(bool hide) { hide_unknown_fields_ = hide; }
301 
302  // If print_message_fields_in_index_order is true, fields of a proto message
303  // will be printed using the order defined in source code instead of the
304  // field number, extensions will be printed at the end of the message
305  // and their relative order is determined by the extension number.
306  // By default, use the field number order.
308  bool print_message_fields_in_index_order) {
309  print_message_fields_in_index_order_ =
310  print_message_fields_in_index_order;
311  }
312 
313  // If expand==true, expand google.protobuf.Any payloads. The output
314  // will be of form
315  // [type_url] { <value_printed_in_text> }
316  //
317  // If expand==false, print Any using the default printer. The output will
318  // look like
319  // type_url: "<type_url>" value: "serialized_content"
320  void SetExpandAny(bool expand) { expand_any_ = expand; }
321 
322  // Set how parser finds message for Any payloads.
323  void SetFinder(const Finder* finder) { finder_ = finder; }
324 
325  // If non-zero, we truncate all string fields that are longer than
326  // this threshold. This is useful when the proto message has very long
327  // strings, e.g., dump of encoded image file.
328  //
329  // NOTE(hfgong): Setting a non-zero value breaks round-trip safe
330  // property of TextFormat::Printer. That is, from the printed message, we
331  // cannot fully recover the original string field any more.
333  const int64 truncate_string_field_longer_than) {
334  truncate_string_field_longer_than_ = truncate_string_field_longer_than;
335  }
336 
337  // Register a custom field-specific (Fast)FieldValuePrinter for fields
338  // with a particular FieldDescriptor.
339  // Returns "true" if the registration succeeded, or "false", if there is
340  // already a printer for that FieldDescriptor.
341  // Takes ownership of the printer on successful registration.
342  bool RegisterFieldValuePrinter(const FieldDescriptor* field,
343  const FieldValuePrinter* printer);
344  bool RegisterFieldValuePrinter(const FieldDescriptor* field,
345  const FastFieldValuePrinter* printer);
346 
347  // Register a custom message-specific MessagePrinter for messages with a
348  // particular Descriptor.
349  // Returns "true" if the registration succeeded, or "false" if there is
350  // already a printer for that Descriptor.
351  bool RegisterMessagePrinter(const Descriptor* descriptor,
352  const MessagePrinter* printer);
353 
354  private:
355  // Forward declaration of an internal class used to print the text
356  // output to the OutputStream (see text_format.cc for implementation).
357  class TextGenerator;
358 
359  // Internal Print method, used for writing to the OutputStream via
360  // the TextGenerator class.
361  void Print(const Message& message, TextGenerator* generator) const;
362 
363  // Print a single field.
364  void PrintField(const Message& message, const Reflection* reflection,
365  const FieldDescriptor* field,
366  TextGenerator* generator) const;
367 
368  // Print a repeated primitive field in short form.
369  void PrintShortRepeatedField(const Message& message,
370  const Reflection* reflection,
371  const FieldDescriptor* field,
372  TextGenerator* generator) const;
373 
374  // Print the name of a field -- i.e. everything that comes before the
375  // ':' for a single name/value pair.
376  void PrintFieldName(const Message& message, int field_index,
377  int field_count, const Reflection* reflection,
378  const FieldDescriptor* field,
379  TextGenerator* generator) const;
380 
381  // Outputs a textual representation of the value of the field supplied on
382  // the message supplied or the default value if not set.
383  void PrintFieldValue(const Message& message, const Reflection* reflection,
384  const FieldDescriptor* field, int index,
385  TextGenerator* generator) const;
386 
387  // Print the fields in an UnknownFieldSet. They are printed by tag number
388  // only. Embedded messages are heuristically identified by attempting to
389  // parse them.
390  void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
391  TextGenerator* generator) const;
392 
393  bool PrintAny(const Message& message, TextGenerator* generator) const;
394 
396 
398 
400 
402 
404 
406 
408 
410 
411  std::unique_ptr<const FastFieldValuePrinter> default_field_value_printer_;
412  typedef std::map<const FieldDescriptor*, const FastFieldValuePrinter*>
415 
416  typedef std::map<const Descriptor*, const MessagePrinter*>
419 
420  const Finder* finder_;
421  };
422 
423  // Parses a text-format protocol message from the given input stream to
424  // the given message object. This function parses the human-readable format
425  // written by Print(). Returns true on success. The message is cleared first,
426  // even if the function fails -- See Merge() to avoid this behavior.
427  //
428  // Example input: "user {\n id: 123 extra { gender: MALE language: 'en' }\n}"
429  //
430  // One use for this function is parsing handwritten strings in test code.
431  // Another use is to parse the output from google::protobuf::Message::DebugString()
432  // (or ShortDebugString()), because these functions output using
433  // google::protobuf::TextFormat::Print().
434  //
435  // If you would like to read a protocol buffer serialized in the
436  // (non-human-readable) binary wire format, see
437  // google::protobuf::MessageLite::ParseFromString().
439  // Like Parse(), but reads directly from a string.
440  static bool ParseFromString(const std::string& input, Message* output);
441 
442  // Like Parse(), but the data is merged into the given message, as if
443  // using Message::MergeFrom().
445  // Like Merge(), but reads directly from a string.
446  static bool MergeFromString(const std::string& input, Message* output);
447 
448  // Parse the given text as a single field value and store it into the
449  // given field of the given message. If the field is a repeated field,
450  // the new value will be added to the end
451  static bool ParseFieldValueFromString(const std::string& input,
452  const FieldDescriptor* field,
453  Message* message);
454 
455  // A location in the parsed text.
456  struct ParseLocation {
457  int line;
458  int column;
459 
460  ParseLocation() : line(-1), column(-1) {}
461  ParseLocation(int line_param, int column_param)
462  : line(line_param), column(column_param) {}
463  };
464 
465  // Data structure which is populated with the locations of each field
466  // value parsed from the text.
467  class PROTOBUF_EXPORT ParseInfoTree {
468  public:
469  ParseInfoTree();
470  ~ParseInfoTree();
471 
472  // Returns the parse location for index-th value of the field in the parsed
473  // text. If none exists, returns a location with line = -1. Index should be
474  // -1 for not-repeated fields.
475  ParseLocation GetLocation(const FieldDescriptor* field, int index) const;
476 
477  // Returns the parse info tree for the given field, which must be a message
478  // type. The nested information tree is owned by the root tree and will be
479  // deleted when it is deleted.
480  ParseInfoTree* GetTreeForNested(const FieldDescriptor* field,
481  int index) const;
482 
483  private:
484  // Allow the text format parser to record information into the tree.
485  friend class TextFormat;
486 
487  // Records the starting location of a single value for a field.
488  void RecordLocation(const FieldDescriptor* field, ParseLocation location);
489 
490  // Create and records a nested tree for a nested message field.
491  ParseInfoTree* CreateNested(const FieldDescriptor* field);
492 
493  // Defines the map from the index-th field descriptor to its parse location.
494  typedef std::map<const FieldDescriptor*, std::vector<ParseLocation> >
496 
497  // Defines the map from the index-th field descriptor to the nested parse
498  // info tree.
499  typedef std::map<const FieldDescriptor*, std::vector<ParseInfoTree*> >
501 
504 
506  };
507 
508  // For more control over parsing, use this class.
509  class PROTOBUF_EXPORT Parser {
510  public:
511  Parser();
512  ~Parser();
513 
514  // Like TextFormat::Parse().
516  // Like TextFormat::ParseFromString().
518  // Like TextFormat::Merge().
520  // Like TextFormat::MergeFromString().
522 
523  // Set where to report parse errors. If NULL (the default), errors will
524  // be printed to stderr.
525  void RecordErrorsTo(io::ErrorCollector* error_collector) {
526  error_collector_ = error_collector;
527  }
528 
529  // Set how parser finds extensions. If NULL (the default), the
530  // parser will use the standard Reflection object associated with
531  // the message being parsed.
532  void SetFinder(const Finder* finder) { finder_ = finder; }
533 
534  // Sets where location information about the parse will be written. If NULL
535  // (the default), then no location will be written.
536  void WriteLocationsTo(ParseInfoTree* tree) { parse_info_tree_ = tree; }
537 
538  // Normally parsing fails if, after parsing, output->IsInitialized()
539  // returns false. Call AllowPartialMessage(true) to skip this check.
540  void AllowPartialMessage(bool allow) { allow_partial_ = allow; }
541 
542  // Allow field names to be matched case-insensitively.
543  // This is not advisable if there are fields that only differ in case, or
544  // if you want to enforce writing in the canonical form.
545  // This is 'false' by default.
546  void AllowCaseInsensitiveField(bool allow) {
547  allow_case_insensitive_field_ = allow;
548  }
549 
550  // Like TextFormat::ParseFieldValueFromString
551  bool ParseFieldValueFromString(const std::string& input,
552  const FieldDescriptor* field,
553  Message* output);
554 
555  // When an unknown extension is met, parsing will fail if this option is set
556  // to false (the default). If true, unknown extensions will be ignored and
557  // a warning message will be generated.
558  void AllowUnknownExtension(bool allow) { allow_unknown_extension_ = allow; }
559 
560  // When an unknown field is met, parsing will fail if this option is set
561  // to false(the default). If true, unknown fields will be ignored and
562  // a warning message will be generated.
563  // Please aware that set this option true may hide some errors (e.g.
564  // spelling error on field name). Avoid to use this option if possible.
565  void AllowUnknownField(bool allow) { allow_unknown_field_ = allow; }
566 
567 
568  void AllowFieldNumber(bool allow) { allow_field_number_ = allow; }
569 
570  // Sets maximum recursion depth which parser can use. This is effectively
571  // the maximum allowed nesting of proto messages.
572  void SetRecursionLimit(int limit) { recursion_limit_ = limit; }
573 
574  private:
575  // Forward declaration of an internal class used to parse text
576  // representations (see text_format.cc for implementation).
577  class ParserImpl;
578 
579  // Like TextFormat::Merge(). The provided implementation is used
580  // to do the parsing.
581  bool MergeUsingImpl(io::ZeroCopyInputStream* input, Message* output,
582  ParserImpl* parser_impl);
583 
585  const Finder* finder_;
596  };
597 
598 
599  private:
600  // Hack: ParseInfoTree declares TextFormat as a friend which should extend
601  // the friendship to TextFormat::Parser::ParserImpl, but unfortunately some
602  // old compilers (e.g. GCC 3.4.6) don't implement this correctly. We provide
603  // helpers for ParserImpl to call methods of ParseInfoTree.
604  static inline void RecordLocation(ParseInfoTree* info_tree,
605  const FieldDescriptor* field,
607  static inline ParseInfoTree* CreateNested(ParseInfoTree* info_tree,
608  const FieldDescriptor* field);
609 
611 };
612 
614  const FieldDescriptor* field,
616  info_tree->RecordLocation(field, location);
617 }
618 
620  ParseInfoTree* info_tree, const FieldDescriptor* field) {
621  return info_tree->CreateNested(field);
622 }
623 
624 } // namespace protobuf
625 } // namespace google
626 
627 #include <google/protobuf/port_undef.inc>
628 
629 #endif // GOOGLE_PROTOBUF_TEXT_FORMAT_H__
google::protobuf::TextFormat::MessagePrinter::~MessagePrinter
virtual ~MessagePrinter()
Definition: text_format.h:191
google::protobuf::TextFormat::ParseInfoTree::RecordLocation
void RecordLocation(const FieldDescriptor *field, ParseLocation location)
Definition: text_format.cc:140
google::protobuf::TextFormat::Printer::SetSingleLineMode
void SetSingleLineMode(bool single_line_mode)
Definition: text_format.h:262
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
google::protobuf::FieldDescriptor
Definition: src/google/protobuf/descriptor.h:515
google::protobuf::TextFormat::MessagePrinter
Definition: text_format.h:188
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
Definition: macros.h:40
google::protobuf::TextFormat::Printer::IsInSingleLineMode
bool IsInSingleLineMode() const
Definition: text_format.h:266
google::protobuf::TextFormat::Parser::allow_field_number_
bool allow_field_number_
Definition: text_format.h:592
google::protobuf::TextFormat::Parser::SetFinder
void SetFinder(const Finder *finder)
Definition: text_format.h:532
google::protobuf::TextFormat::ParseInfoTree::NestedMap
std::map< const FieldDescriptor *, std::vector< ParseInfoTree * > > NestedMap
Definition: text_format.h:500
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
google::protobuf::TextFormat::Parser::AllowPartialMessage
void AllowPartialMessage(bool allow)
Definition: text_format.h:540
google::protobuf::TextFormat::Parser::recursion_limit_
int recursion_limit_
Definition: text_format.h:595
input
std::string input
Definition: tokenizer_unittest.cc:197
google::protobuf::TextFormat::Printer::SetUseFieldNumber
void SetUseFieldNumber(bool use_field_number)
Definition: text_format.h:269
google::protobuf::TextFormat::Printer::single_line_mode_
bool single_line_mode_
Definition: text_format.h:397
google::protobuf::TextFormat::BaseTextGenerator::PrintLiteral
void PrintLiteral(const char(&text)[n])
Definition: text_format.h:113
testing::gtest_printers_test::Print
std::string Print(const T &value)
Definition: googletest-printers-test.cc:233
google::protobuf.text_format.PrintField
def PrintField(field, value, out, indent=0, as_utf8=False, as_one_line=False, use_short_repeated_primitives=False, pointy_brackets=False, use_index_order=False, float_format=None, double_format=None, message_formatter=None, print_unknown_fields=False)
Definition: text_format.py:233
google::protobuf::TextFormat::Parser
Definition: text_format.h:509
google::protobuf::TextFormat::Parser::allow_unknown_enum_
bool allow_unknown_enum_
Definition: text_format.h:591
google::protobuf::TextFormat::ParseInfoTree::locations_
LocationMap locations_
Definition: text_format.h:502
google::protobuf::TextFormat::Parser::AllowCaseInsensitiveField
void AllowCaseInsensitiveField(bool allow)
Definition: text_format.h:546
google::protobuf::TextFormat::Parser::AllowUnknownField
void AllowUnknownField(bool allow)
Definition: text_format.h:565
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
google::protobuf::TextFormat::Printer::initial_indent_level_
int initial_indent_level_
Definition: text_format.h:395
google::protobuf::TextFormat::Parser::finder_
const Finder * finder_
Definition: text_format.h:585
google::protobuf::TextFormat::CreateNested
static ParseInfoTree * CreateNested(ParseInfoTree *info_tree, const FieldDescriptor *field)
Definition: text_format.h:619
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
google::protobuf::TextFormat::Printer::SetHideUnknownFields
void SetHideUnknownFields(bool hide)
Definition: text_format.h:300
google::protobuf::TextFormat::ParseLocation
Definition: text_format.h:456
google::protobuf::Reflection
Definition: src/google/protobuf/message.h:400
descriptor
Descriptor * descriptor
Definition: php/ext/google/protobuf/protobuf.h:936
port.h
google::protobuf::MessageFactory
Definition: src/google/protobuf/message.h:1069
google::protobuf::TextFormat::Printer::truncate_string_field_longer_than_
int64 truncate_string_field_longer_than_
Definition: text_format.h:409
google::protobuf::TextFormat::Parser::allow_relaxed_whitespace_
bool allow_relaxed_whitespace_
Definition: text_format.h:593
google::protobuf::TextFormat
Definition: text_format.h:70
google::protobuf::TextFormat::Printer::custom_message_printers_
CustomMessagePrinterMap custom_message_printers_
Definition: text_format.h:418
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
google::protobuf::python::cdescriptor_pool::FindExtensionByNumber
static PyObject * FindExtensionByNumber(PyObject *self, PyObject *args)
Definition: descriptor_pool.cc:420
google::protobuf::TextFormat::Parser::WriteLocationsTo
void WriteLocationsTo(ParseInfoTree *tree)
Definition: text_format.h:536
google::protobuf::TextFormat::ParseInfoTree
Definition: text_format.h:467
google::protobuf::TextFormat::RecordLocation
static void RecordLocation(ParseInfoTree *info_tree, const FieldDescriptor *field, ParseLocation location)
Definition: text_format.h:613
google::protobuf::TextFormat::Parser::allow_unknown_field_
bool allow_unknown_field_
Definition: text_format.h:589
google::protobuf::TextFormat::BaseTextGenerator
Definition: text_format.h:100
google::protobuf::TextFormat::Printer::SetFinder
void SetFinder(const Finder *finder)
Definition: text_format.h:323
prefix
static const char prefix[]
Definition: test_pair_ipc.cpp:26
google::protobuf::TextFormat::ParseLocation::line
int line
Definition: text_format.h:457
google::protobuf::TextFormat::Printer::use_field_number_
bool use_field_number_
Definition: text_format.h:399
update_failure_list.str
str
Definition: update_failure_list.py:41
google::protobuf::TextFormat::Printer
Definition: text_format.h:234
google::protobuf::TextFormat::MessagePrinter::MessagePrinter
MessagePrinter()
Definition: text_format.h:190
message.h
google::protobuf::TextFormat::Printer::finder_
const Finder * finder_
Definition: text_format.h:420
google::protobuf::TextFormat::Printer::SetExpandAny
void SetExpandAny(bool expand)
Definition: text_format.h:320
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
google::protobuf::TextFormat::Parser::parse_info_tree_
ParseInfoTree * parse_info_tree_
Definition: text_format.h:586
google::protobuf::TextFormat::Printer::SetTruncateStringFieldLongerThan
void SetTruncateStringFieldLongerThan(const int64 truncate_string_field_longer_than)
Definition: text_format.h:332
google::protobuf::TextFormat::ParseInfoTree::CreateNested
ParseInfoTree * CreateNested(const FieldDescriptor *field)
Definition: text_format.cc:145
google::protobuf::TextFormat::ParseInfoTree::LocationMap
std::map< const FieldDescriptor *, std::vector< ParseLocation > > LocationMap
Definition: text_format.h:495
google::protobuf::TextFormat::Parser::RecordErrorsTo
void RecordErrorsTo(io::ErrorCollector *error_collector)
Definition: text_format.h:525
google::protobuf::TextFormat::BaseTextGenerator::Indent
virtual void Indent()
Definition: text_format.h:104
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf::TextFormat::Finder
Definition: text_format.h:201
google::protobuf::TextFormat::ParseInfoTree::nested_
NestedMap nested_
Definition: text_format.h:503
google::protobuf::TextFormat::Printer::CustomPrinterMap
std::map< const FieldDescriptor *, const FastFieldValuePrinter * > CustomPrinterMap
Definition: text_format.h:413
google::protobuf::TextFormat::Printer::SetPrintMessageFieldsInIndexOrder
void SetPrintMessageFieldsInIndexOrder(bool print_message_fields_in_index_order)
Definition: text_format.h:307
location
GLint location
Definition: glcorearb.h:3074
google::protobuf::TextFormat::Printer::expand_any_
bool expand_any_
Definition: text_format.h:407
google::protobuf::TextFormat::FastFieldValuePrinter
Definition: text_format.h:122
n
GLdouble n
Definition: glcorearb.h:4153
google::protobuf::TextFormat::Printer::custom_printers_
CustomPrinterMap custom_printers_
Definition: text_format.h:414
google::protobuf::io::ZeroCopyInputStream
Definition: zero_copy_stream.h:126
google::protobuf.internal.python_message.MergeFromString
MergeFromString
Definition: python_message.py:1138
google::protobuf::TextFormat::Parser::allow_partial_
bool allow_partial_
Definition: text_format.h:587
google::protobuf::TextFormat::Printer::use_short_repeated_primitives_
bool use_short_repeated_primitives_
Definition: text_format.h:401
google::protobuf.json_format.Parse
def Parse(text, message, ignore_unknown_fields=False, descriptor_pool=None)
Definition: json_format.py:394
google::protobuf::Message
Definition: src/google/protobuf/message.h:205
error_collector_
MockErrorCollector error_collector_
Definition: importer_unittest.cc:129
google::protobuf::TextFormat::Parser::allow_case_insensitive_field_
bool allow_case_insensitive_field_
Definition: text_format.h:588
google::protobuf::TextFormat::Printer::SetInitialIndentLevel
void SetInitialIndentLevel(int indent_level)
Definition: text_format.h:256
common.h
google::protobuf::TextFormat::ParseLocation::ParseLocation
ParseLocation()
Definition: text_format.h:460
google::protobuf::python::cmessage::ParseFromString
static PyObject * ParseFromString(CMessage *self, PyObject *arg)
Definition: python/google/protobuf/pyext/message.cc:1964
google::protobuf::TextFormat::BaseTextGenerator::PrintString
void PrintString(const std::string &str)
Definition: text_format.h:110
google::protobuf.text_format.PrintFieldValue
def PrintFieldValue(field, value, out, indent=0, as_utf8=False, as_one_line=False, use_short_repeated_primitives=False, pointy_brackets=False, use_index_order=False, float_format=None, double_format=None, message_formatter=None, print_unknown_fields=False)
Definition: text_format.py:255
google::protobuf::TextFormat::Parser::SetRecursionLimit
void SetRecursionLimit(int limit)
Definition: text_format.h:572
size
GLsizeiptr size
Definition: glcorearb.h:2943
google::protobuf::io::ErrorCollector
Definition: tokenizer.h:66
google::protobuf::UnknownFieldSet
Definition: unknown_field_set.h:86
delegate_
std::unique_ptr< const TextFormat::FieldValuePrinter > delegate_
Definition: text_format.cc:1776
message_lite.h
google::protobuf::io::ZeroCopyOutputStream
Definition: zero_copy_stream.h:183
google::protobuf::Descriptor
Definition: src/google/protobuf/descriptor.h:231
descriptor.h
google::protobuf::TextFormat::Parser::allow_singular_overwrites_
bool allow_singular_overwrites_
Definition: text_format.h:594
google::protobuf::TextFormat::Parser::AllowUnknownExtension
void AllowUnknownExtension(bool allow)
Definition: text_format.h:558
tree
Definition: wepoll.c:502
google::protobuf::TextFormat::BaseTextGenerator::Outdent
virtual void Outdent()
Definition: text_format.h:105
val
GLuint GLfloat * val
Definition: glcorearb.h:3604
google::protobuf::TextFormat::Printer::default_field_value_printer_
std::unique_ptr< const FastFieldValuePrinter > default_field_value_printer_
Definition: text_format.h:411
google::protobuf::TextFormat::Printer::CustomMessagePrinterMap
std::map< const Descriptor *, const MessagePrinter * > CustomMessagePrinterMap
Definition: text_format.h:417
output
const upb_json_parsermethod const upb_symtab upb_sink * output
Definition: ruby/ext/google/protobuf_c/upb.h:10503
index
GLuint index
Definition: glcorearb.h:3055
google::protobuf::TextFormat::Parser::error_collector_
io::ErrorCollector * error_collector_
Definition: text_format.h:584
number
double number
Definition: cJSON.h:326
google::protobuf::TextFormat::ParseLocation::ParseLocation
ParseLocation(int line_param, int column_param)
Definition: text_format.h:461
google
Definition: data_proto2_to_proto3_util.h:11
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
google::protobuf::TextFormat::Parser::AllowFieldNumber
void AllowFieldNumber(bool allow)
Definition: text_format.h:568
google::protobuf::TextFormat::Parser::allow_unknown_extension_
bool allow_unknown_extension_
Definition: text_format.h:590
google::protobuf::TextFormat::Printer::hide_unknown_fields_
bool hide_unknown_fields_
Definition: text_format.h:403
google::protobuf.text_format.Merge
def Merge(text, message, allow_unknown_extension=False, allow_field_number=False, descriptor_pool=None, allow_unknown_field=False)
Definition: text_format.py:656
google::protobuf::TextFormat::Printer::print_message_fields_in_index_order_
bool print_message_fields_in_index_order_
Definition: text_format.h:405
google::protobuf::TextFormat::Printer::SetUseShortRepeatedPrimitives
void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives)
Definition: text_format.h:278
google::protobuf::TextFormat::ParseLocation::column
int column
Definition: text_format.h:458
testing::PrintToString
::std::string PrintToString(const T &value)
Definition: gtest-printers.h:938


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:59