protobuf/src/google/protobuf/text_format.cc
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 #include <google/protobuf/text_format.h>
36 
37 #include <float.h>
38 #include <stdio.h>
39 
40 #include <algorithm>
41 #include <atomic>
42 #include <climits>
43 #include <cmath>
44 #include <limits>
45 #include <vector>
46 
47 #include <google/protobuf/stubs/stringprintf.h>
48 #include <google/protobuf/any.h>
49 #include <google/protobuf/descriptor.pb.h>
50 #include <google/protobuf/io/coded_stream.h>
51 #include <google/protobuf/io/tokenizer.h>
52 #include <google/protobuf/io/zero_copy_stream.h>
53 #include <google/protobuf/io/zero_copy_stream_impl.h>
54 #include <google/protobuf/descriptor.h>
55 #include <google/protobuf/dynamic_message.h>
56 #include <google/protobuf/map_field.h>
57 #include <google/protobuf/message.h>
58 #include <google/protobuf/repeated_field.h>
59 #include <google/protobuf/unknown_field_set.h>
60 #include <google/protobuf/wire_format_lite.h>
61 #include <google/protobuf/stubs/strutil.h>
62 #include <google/protobuf/io/strtod.h>
63 #include <google/protobuf/stubs/map_util.h>
64 #include <google/protobuf/stubs/stl_util.h>
65 
66 // Must be included last.
67 #include <google/protobuf/port_def.inc>
68 
69 #define DEBUG_STRING_SILENT_MARKER "\t "
70 
71 namespace google {
72 namespace protobuf {
73 
74 namespace {
75 
76 inline bool IsHexNumber(const std::string& str) {
77  return (str.length() >= 2 && str[0] == '0' &&
78  (str[1] == 'x' || str[1] == 'X'));
79 }
80 
81 inline bool IsOctNumber(const std::string& str) {
82  return (str.length() >= 2 && str[0] == '0' &&
83  (str[1] >= '0' && str[1] < '8'));
84 }
85 
86 } // namespace
87 
88 namespace internal {
89 // Controls insertion of DEBUG_STRING_SILENT_MARKER.
90 PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_format_marker;
91 } // namespace internal
92 
94  std::string debug_string;
95 
96  TextFormat::Printer printer;
97  printer.SetExpandAny(true);
99  std::memory_order_relaxed));
100 
101  printer.PrintToString(*this, &debug_string);
102 
103  return debug_string;
104 }
105 
107  std::string debug_string;
108 
109  TextFormat::Printer printer;
110  printer.SetSingleLineMode(true);
111  printer.SetExpandAny(true);
112  printer.SetInsertSilentMarker(internal::enable_debug_text_format_marker.load(
113  std::memory_order_relaxed));
114 
115  printer.PrintToString(*this, &debug_string);
116  // Single line mode currently might have an extra space at the end.
117  if (!debug_string.empty() && debug_string[debug_string.size() - 1] == ' ') {
118  debug_string.resize(debug_string.size() - 1);
119  }
120 
121  return debug_string;
122 }
123 
125  std::string debug_string;
126 
127  TextFormat::Printer printer;
128  printer.SetUseUtf8StringEscaping(true);
129  printer.SetExpandAny(true);
130  printer.SetInsertSilentMarker(internal::enable_debug_text_format_marker.load(
131  std::memory_order_relaxed));
132 
133  printer.PrintToString(*this, &debug_string);
134 
135  return debug_string;
136 }
137 
138 void Message::PrintDebugString() const { printf("%s", DebugString().c_str()); }
139 
140 
141 // ===========================================================================
142 // Implementation of the parse information tree class.
145  locations_[field].push_back(range);
146 }
147 
149  const FieldDescriptor* field) {
150  // Owned by us in the map.
151  auto& vec = nested_[field];
152  vec.emplace_back(new TextFormat::ParseInfoTree());
153  return vec.back().get();
154 }
155 
156 void CheckFieldIndex(const FieldDescriptor* field, int index) {
157  if (field == nullptr) {
158  return;
159  }
160 
161  if (field->is_repeated() && index == -1) {
162  GOOGLE_LOG(DFATAL) << "Index must be in range of repeated field values. "
163  << "Field: " << field->name();
164  } else if (!field->is_repeated() && index != -1) {
165  GOOGLE_LOG(DFATAL) << "Index must be -1 for singular fields."
166  << "Field: " << field->name();
167  }
168 }
169 
171  const FieldDescriptor* field, int index) const {
173  if (index == -1) {
174  index = 0;
175  }
176 
177  const std::vector<TextFormat::ParseLocationRange>* locations =
178  FindOrNull(locations_, field);
179  if (locations == nullptr ||
180  index >= static_cast<int64_t>(locations->size())) {
182  }
183 
184  return (*locations)[index];
185 }
186 
188  const FieldDescriptor* field, int index) const {
190  if (index == -1) {
191  index = 0;
192  }
193 
194  auto it = nested_.find(field);
195  if (it == nested_.end() || index >= static_cast<int64_t>(it->second.size())) {
196  return nullptr;
197  }
198 
199  return it->second[index].get();
200 }
201 
202 namespace {
203 // These functions implement the behavior of the "default" TextFormat::Finder,
204 // they are defined as standalone to be called when finder_ is nullptr.
205 const FieldDescriptor* DefaultFinderFindExtension(Message* message,
206  const std::string& name) {
207  const Descriptor* descriptor = message->GetDescriptor();
208  return descriptor->file()->pool()->FindExtensionByPrintableName(descriptor,
209  name);
210 }
211 
212 const FieldDescriptor* DefaultFinderFindExtensionByNumber(
213  const Descriptor* descriptor, int number) {
214  return descriptor->file()->pool()->FindExtensionByNumber(descriptor, number);
215 }
216 
217 const Descriptor* DefaultFinderFindAnyType(const Message& message,
218  const std::string& prefix,
219  const std::string& name) {
222  return nullptr;
223  }
224  return message.GetDescriptor()->file()->pool()->FindMessageTypeByName(name);
225 }
226 } // namespace
227 
228 // ===========================================================================
229 // Internal class for parsing an ASCII representation of a Protocol Message.
230 // This class makes use of the Protocol Message compiler's tokenizer found
231 // in //net/proto2/io/public/tokenizer.h. Note that class's Parse
232 // method is *not* thread-safe and should only be used in a single thread at
233 // a time.
234 
235 // Makes code slightly more readable. The meaning of "DO(foo)" is
236 // "Execute foo and fail if it fails.", where failure is indicated by
237 // returning false. Borrowed from parser.cc (Thanks Kenton!).
238 #define DO(STATEMENT) \
239  if (STATEMENT) { \
240  } else { \
241  return false; \
242  }
243 
244 class TextFormat::Parser::ParserImpl {
245  public:
246  // Determines if repeated values for non-repeated fields and
247  // oneofs are permitted, e.g., the string "foo: 1 foo: 2" for a
248  // required/optional field named "foo", or "baz: 1 qux: 2"
249  // where "baz" and "qux" are members of the same oneof.
251  ALLOW_SINGULAR_OVERWRITES = 0, // the last value is retained
252  FORBID_SINGULAR_OVERWRITES = 1, // an error is issued
253  };
254 
255  ParserImpl(const Descriptor* root_message_type,
256  io::ZeroCopyInputStream* input_stream,
257  io::ErrorCollector* error_collector,
258  const TextFormat::Finder* finder, ParseInfoTree* parse_info_tree,
259  SingularOverwritePolicy singular_overwrite_policy,
260  bool allow_case_insensitive_field, bool allow_unknown_field,
261  bool allow_unknown_extension, bool allow_unknown_enum,
262  bool allow_field_number, bool allow_relaxed_whitespace,
263  bool allow_partial, int recursion_limit)
264  : error_collector_(error_collector),
265  finder_(finder),
266  parse_info_tree_(parse_info_tree),
267  tokenizer_error_collector_(this),
268  tokenizer_(input_stream, &tokenizer_error_collector_),
269  root_message_type_(root_message_type),
270  singular_overwrite_policy_(singular_overwrite_policy),
271  allow_case_insensitive_field_(allow_case_insensitive_field),
272  allow_unknown_field_(allow_unknown_field),
273  allow_unknown_extension_(allow_unknown_extension),
274  allow_unknown_enum_(allow_unknown_enum),
275  allow_field_number_(allow_field_number),
276  allow_partial_(allow_partial),
277  initial_recursion_limit_(recursion_limit),
278  recursion_limit_(recursion_limit),
279  had_errors_(false) {
280  // For backwards-compatibility with proto1, we need to allow the 'f' suffix
281  // for floats.
282  tokenizer_.set_allow_f_after_float(true);
283 
284  // '#' starts a comment.
285  tokenizer_.set_comment_style(io::Tokenizer::SH_COMMENT_STYLE);
286 
287  if (allow_relaxed_whitespace) {
288  tokenizer_.set_require_space_after_number(false);
289  tokenizer_.set_allow_multiline_strings(true);
290  }
291 
292  // Consume the starting token.
293  tokenizer_.Next();
294  }
296 
297  // Parses the ASCII representation specified in input and saves the
298  // information into the output pointer (a Message). Returns
299  // false if an error occurs (an error will also be logged to
300  // GOOGLE_LOG(ERROR)).
302  // Consume fields until we cannot do so anymore.
303  while (true) {
304  if (LookingAtType(io::Tokenizer::TYPE_END)) {
305  // Ensures recursion limit properly unwinded, but only for success
306  // cases. This implicitly avoids the check when `Parse` returns false
307  // via `DO(...)`.
308  GOOGLE_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_)
309  << "Recursion limit at end of parse should be "
310  << initial_recursion_limit_ << ", but was " << recursion_limit_
311  << ". Difference of " << initial_recursion_limit_ - recursion_limit_
312  << " stack frames not accounted for stack unwind.";
313 
314  return !had_errors_;
315  }
316 
317  DO(ConsumeField(output));
318  }
319  }
320 
322  bool suc;
323  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
324  suc = ConsumeFieldMessage(output, output->GetReflection(), field);
325  } else {
326  suc = ConsumeFieldValue(output, output->GetReflection(), field);
327  }
328  return suc && LookingAtType(io::Tokenizer::TYPE_END);
329  }
330 
331  void ReportError(int line, int col, const std::string& message) {
332  had_errors_ = true;
333  if (error_collector_ == nullptr) {
334  if (line >= 0) {
335  GOOGLE_LOG(ERROR) << "Error parsing text-format "
336  << root_message_type_->full_name() << ": " << (line + 1)
337  << ":" << (col + 1) << ": " << message;
338  } else {
339  GOOGLE_LOG(ERROR) << "Error parsing text-format "
340  << root_message_type_->full_name() << ": " << message;
341  }
342  } else {
343  error_collector_->AddError(line, col, message);
344  }
345  }
346 
347  void ReportWarning(int line, int col, const std::string& message) {
348  if (error_collector_ == nullptr) {
349  if (line >= 0) {
350  GOOGLE_LOG(WARNING) << "Warning parsing text-format "
351  << root_message_type_->full_name() << ": " << (line + 1)
352  << ":" << (col + 1) << ": " << message;
353  } else {
354  GOOGLE_LOG(WARNING) << "Warning parsing text-format "
355  << root_message_type_->full_name() << ": " << message;
356  }
357  } else {
358  error_collector_->AddWarning(line, col, message);
359  }
360  }
361 
362  private:
368 
370 
371  // Reports an error with the given message with information indicating
372  // the position (as derived from the current token).
374  ReportError(tokenizer_.current().line, tokenizer_.current().column,
375  message);
376  }
377 
378  // Reports a warning with the given message with information indicating
379  // the position (as derived from the current token).
381  ReportWarning(tokenizer_.current().line, tokenizer_.current().column,
382  message);
383  }
384 
385  // Consumes the specified message with the given starting delimiter.
386  // This method checks to see that the end delimiter at the conclusion of
387  // the consumption matches the starting delimiter passed in here.
388  bool ConsumeMessage(Message* message, const std::string delimiter) {
389  while (!LookingAt(">") && !LookingAt("}")) {
390  DO(ConsumeField(message));
391  }
392 
393  // Confirm that we have a valid ending delimiter.
394  DO(Consume(delimiter));
395  return true;
396  }
397 
398  // Consume either "<" or "{".
400  if (TryConsume("<")) {
401  *delimiter = ">";
402  } else {
403  DO(Consume("{"));
404  *delimiter = "}";
405  }
406  return true;
407  }
408 
409 
410  // Consumes the current field (as returned by the tokenizer) on the
411  // passed in message.
413  const Reflection* reflection = message->GetReflection();
414  const Descriptor* descriptor = message->GetDescriptor();
415 
416  std::string field_name;
417  bool reserved_field = false;
418  const FieldDescriptor* field = nullptr;
419  int start_line = tokenizer_.current().line;
420  int start_column = tokenizer_.current().column;
421 
422  const FieldDescriptor* any_type_url_field;
423  const FieldDescriptor* any_value_field;
424  if (internal::GetAnyFieldDescriptors(*message, &any_type_url_field,
425  &any_value_field) &&
426  TryConsume("[")) {
427  std::string full_type_name, prefix;
428  DO(ConsumeAnyTypeUrl(&full_type_name, &prefix));
429  std::string prefix_and_full_type_name =
430  StrCat(prefix, full_type_name);
431  DO(ConsumeBeforeWhitespace("]"));
432  TryConsumeWhitespace(prefix_and_full_type_name, "Any");
433  // ':' is optional between message labels and values.
434  TryConsumeBeforeWhitespace(":");
435  TryConsumeWhitespace(prefix_and_full_type_name, "Any");
436  std::string serialized_value;
437  const Descriptor* value_descriptor =
438  finder_ ? finder_->FindAnyType(*message, prefix, full_type_name)
439  : DefaultFinderFindAnyType(*message, prefix, full_type_name);
440  if (value_descriptor == nullptr) {
441  ReportError("Could not find type \"" + prefix_and_full_type_name +
442  "\" stored in google.protobuf.Any.");
443  return false;
444  }
445  DO(ConsumeAnyValue(value_descriptor, &serialized_value));
446  if (singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) {
447  // Fail if any_type_url_field has already been specified.
448  if ((!any_type_url_field->is_repeated() &&
449  reflection->HasField(*message, any_type_url_field)) ||
450  (!any_value_field->is_repeated() &&
451  reflection->HasField(*message, any_value_field))) {
452  ReportError("Non-repeated Any specified multiple times.");
453  return false;
454  }
455  }
456  reflection->SetString(message, any_type_url_field,
457  prefix_and_full_type_name);
458  reflection->SetString(message, any_value_field, serialized_value);
459  return true;
460  }
461  if (TryConsume("[")) {
462  // Extension.
463  DO(ConsumeFullTypeName(&field_name));
464  DO(ConsumeBeforeWhitespace("]"));
465  TryConsumeWhitespace(message->GetTypeName(), "Extension");
466 
467  field = finder_ ? finder_->FindExtension(message, field_name)
468  : DefaultFinderFindExtension(message, field_name);
469 
470  if (field == nullptr) {
471  if (!allow_unknown_field_ && !allow_unknown_extension_) {
472  ReportError("Extension \"" + field_name +
473  "\" is not defined or "
474  "is not an extension of \"" +
475  descriptor->full_name() + "\".");
476  return false;
477  } else {
478  ReportWarning("Ignoring extension \"" + field_name +
479  "\" which is not defined or is not an extension of \"" +
480  descriptor->full_name() + "\".");
481  }
482  }
483  } else {
484  DO(ConsumeIdentifierBeforeWhitespace(&field_name));
485  TryConsumeWhitespace(message->GetTypeName(), "Normal");
486 
487  int32_t field_number;
488  if (allow_field_number_ && safe_strto32(field_name, &field_number)) {
489  if (descriptor->IsExtensionNumber(field_number)) {
490  field = finder_
491  ? finder_->FindExtensionByNumber(descriptor, field_number)
492  : DefaultFinderFindExtensionByNumber(descriptor,
493  field_number);
494  } else if (descriptor->IsReservedNumber(field_number)) {
495  reserved_field = true;
496  } else {
497  field = descriptor->FindFieldByNumber(field_number);
498  }
499  } else {
500  field = descriptor->FindFieldByName(field_name);
501  // Group names are expected to be capitalized as they appear in the
502  // .proto file, which actually matches their type names, not their
503  // field names.
504  if (field == nullptr) {
505  std::string lower_field_name = field_name;
506  LowerString(&lower_field_name);
507  field = descriptor->FindFieldByName(lower_field_name);
508  // If the case-insensitive match worked but the field is NOT a group,
509  if (field != nullptr &&
510  field->type() != FieldDescriptor::TYPE_GROUP) {
511  field = nullptr;
512  }
513  }
514  // Again, special-case group names as described above.
515  if (field != nullptr && field->type() == FieldDescriptor::TYPE_GROUP &&
516  field->message_type()->name() != field_name) {
517  field = nullptr;
518  }
519 
520  if (field == nullptr && allow_case_insensitive_field_) {
521  std::string lower_field_name = field_name;
522  LowerString(&lower_field_name);
523  field = descriptor->FindFieldByLowercaseName(lower_field_name);
524  }
525 
526  if (field == nullptr) {
527  reserved_field = descriptor->IsReservedName(field_name);
528  }
529  }
530 
531  if (field == nullptr && !reserved_field) {
532  if (!allow_unknown_field_) {
533  ReportError("Message type \"" + descriptor->full_name() +
534  "\" has no field named \"" + field_name + "\".");
535  return false;
536  } else {
537  ReportWarning("Message type \"" + descriptor->full_name() +
538  "\" has no field named \"" + field_name + "\".");
539  }
540  }
541  }
542 
543  // Skips unknown or reserved fields.
544  if (field == nullptr) {
545  GOOGLE_CHECK(allow_unknown_field_ || allow_unknown_extension_ || reserved_field);
546 
547  // Try to guess the type of this field.
548  // If this field is not a message, there should be a ":" between the
549  // field name and the field value and also the field value should not
550  // start with "{" or "<" which indicates the beginning of a message body.
551  // If there is no ":" or there is a "{" or "<" after ":", this field has
552  // to be a message or the input is ill-formed.
553  if (TryConsumeBeforeWhitespace(":")) {
554  TryConsumeWhitespace(message->GetTypeName(), "Unknown/Reserved");
555  if (!LookingAt("{") && !LookingAt("<")) {
556  return SkipFieldValue();
557  }
558  }
559  return SkipFieldMessage();
560  }
561 
562  if (singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) {
563  // Fail if the field is not repeated and it has already been specified.
564  if (!field->is_repeated() && reflection->HasField(*message, field)) {
565  ReportError("Non-repeated field \"" + field_name +
566  "\" is specified multiple times.");
567  return false;
568  }
569  // Fail if the field is a member of a oneof and another member has already
570  // been specified.
571  const OneofDescriptor* oneof = field->containing_oneof();
572  if (oneof != nullptr && reflection->HasOneof(*message, oneof)) {
573  const FieldDescriptor* other_field =
574  reflection->GetOneofFieldDescriptor(*message, oneof);
575  ReportError("Field \"" + field_name +
576  "\" is specified along with "
577  "field \"" +
578  other_field->name() +
579  "\", another member "
580  "of oneof \"" +
581  oneof->name() + "\".");
582  return false;
583  }
584  }
585 
586  // Perform special handling for embedded message types.
587  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
588  // ':' is optional here.
589  bool consumed_semicolon = TryConsumeBeforeWhitespace(":");
590  TryConsumeWhitespace(message->GetTypeName(), "Normal");
591  if (consumed_semicolon && field->options().weak() &&
592  LookingAtType(io::Tokenizer::TYPE_STRING)) {
593  // we are getting a bytes string for a weak field.
595  DO(ConsumeString(&tmp));
596  MessageFactory* factory =
597  finder_ ? finder_->FindExtensionFactory(field) : nullptr;
598  reflection->MutableMessage(message, field, factory)
599  ->ParseFromString(tmp);
600  goto label_skip_parsing;
601  }
602  } else {
603  // ':' is required here.
604  DO(ConsumeBeforeWhitespace(":"));
605  TryConsumeWhitespace(message->GetTypeName(), "Normal");
606  }
607 
608  if (field->is_repeated() && TryConsume("[")) {
609  // Short repeated format, e.g. "foo: [1, 2, 3]".
610  if (!TryConsume("]")) {
611  // "foo: []" is treated as empty.
612  while (true) {
613  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
614  // Perform special handling for embedded message types.
615  DO(ConsumeFieldMessage(message, reflection, field));
616  } else {
617  DO(ConsumeFieldValue(message, reflection, field));
618  }
619  if (TryConsume("]")) {
620  break;
621  }
622  DO(Consume(","));
623  }
624  }
625  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
626  DO(ConsumeFieldMessage(message, reflection, field));
627  } else {
628  DO(ConsumeFieldValue(message, reflection, field));
629  }
630  label_skip_parsing:
631  // For historical reasons, fields may optionally be separated by commas or
632  // semicolons.
633  TryConsume(";") || TryConsume(",");
634 
635  if (field->options().deprecated()) {
636  ReportWarning("text format contains deprecated field \"" + field_name +
637  "\"");
638  }
639 
640  // If a parse info tree exists, add the location for the parsed
641  // field.
642  if (parse_info_tree_ != nullptr) {
643  int end_line = tokenizer_.previous().line;
644  int end_column = tokenizer_.previous().end_column;
645 
646  RecordLocation(parse_info_tree_, field,
647  ParseLocationRange(ParseLocation(start_line, start_column),
648  ParseLocation(end_line, end_column)));
649  }
650 
651  return true;
652  }
653 
654  // Skips the next field including the field's name and value.
655  bool SkipField() {
656  if (TryConsume("[")) {
657  // Extension name or type URL.
658  DO(ConsumeTypeUrlOrFullTypeName());
659  DO(ConsumeBeforeWhitespace("]"));
660  } else {
661  std::string field_name;
662  DO(ConsumeIdentifierBeforeWhitespace(&field_name));
663  }
664  TryConsumeWhitespace("Unknown/Reserved", "n/a");
665 
666  // Try to guess the type of this field.
667  // If this field is not a message, there should be a ":" between the
668  // field name and the field value and also the field value should not
669  // start with "{" or "<" which indicates the beginning of a message body.
670  // If there is no ":" or there is a "{" or "<" after ":", this field has
671  // to be a message or the input is ill-formed.
672  if (TryConsumeBeforeWhitespace(":")) {
673  TryConsumeWhitespace("Unknown/Reserved", "n/a");
674  if (!LookingAt("{") && !LookingAt("<")) {
675  DO(SkipFieldValue());
676  } else {
677  DO(SkipFieldMessage());
678  }
679  } else {
680  DO(SkipFieldMessage());
681  }
682  // For historical reasons, fields may optionally be separated by commas or
683  // semicolons.
684  TryConsume(";") || TryConsume(",");
685  return true;
686  }
687 
688  bool ConsumeFieldMessage(Message* message, const Reflection* reflection,
689  const FieldDescriptor* field) {
690  if (--recursion_limit_ < 0) {
691  ReportError(
692  StrCat("Message is too deep, the parser exceeded the "
693  "configured recursion limit of ",
694  initial_recursion_limit_, "."));
695  return false;
696  }
697  // If the parse information tree is not nullptr, create a nested one
698  // for the nested message.
699  ParseInfoTree* parent = parse_info_tree_;
700  if (parent != nullptr) {
701  parse_info_tree_ = CreateNested(parent, field);
702  }
703 
704  std::string delimiter;
705  DO(ConsumeMessageDelimiter(&delimiter));
706  MessageFactory* factory =
707  finder_ ? finder_->FindExtensionFactory(field) : nullptr;
708  if (field->is_repeated()) {
709  DO(ConsumeMessage(reflection->AddMessage(message, field, factory),
710  delimiter));
711  } else {
712  DO(ConsumeMessage(reflection->MutableMessage(message, field, factory),
713  delimiter));
714  }
715 
716  ++recursion_limit_;
717 
718  // Reset the parse information tree.
719  parse_info_tree_ = parent;
720  return true;
721  }
722 
723  // Skips the whole body of a message including the beginning delimiter and
724  // the ending delimiter.
726  if (--recursion_limit_ < 0) {
727  ReportError(
728  StrCat("Message is too deep, the parser exceeded the "
729  "configured recursion limit of ",
730  initial_recursion_limit_, "."));
731  return false;
732  }
733 
734  std::string delimiter;
735  DO(ConsumeMessageDelimiter(&delimiter));
736  while (!LookingAt(">") && !LookingAt("}")) {
737  DO(SkipField());
738  }
739  DO(Consume(delimiter));
740 
741  ++recursion_limit_;
742  return true;
743  }
744 
745  bool ConsumeFieldValue(Message* message, const Reflection* reflection,
746  const FieldDescriptor* field) {
747 // Define an easy to use macro for setting fields. This macro checks
748 // to see if the field is repeated (in which case we need to use the Add
749 // methods or not (in which case we need to use the Set methods).
750 #define SET_FIELD(CPPTYPE, VALUE) \
751  if (field->is_repeated()) { \
752  reflection->Add##CPPTYPE(message, field, VALUE); \
753  } else { \
754  reflection->Set##CPPTYPE(message, field, VALUE); \
755  }
756 
757  switch (field->cpp_type()) {
759  int64_t value;
760  DO(ConsumeSignedInteger(&value, kint32max));
761  SET_FIELD(Int32, static_cast<int32_t>(value));
762  break;
763  }
764 
766  uint64_t value;
767  DO(ConsumeUnsignedInteger(&value, kuint32max));
768  SET_FIELD(UInt32, static_cast<uint32_t>(value));
769  break;
770  }
771 
773  int64_t value;
774  DO(ConsumeSignedInteger(&value, kint64max));
776  break;
777  }
778 
780  uint64_t value;
781  DO(ConsumeUnsignedInteger(&value, kuint64max));
783  break;
784  }
785 
787  double value;
788  DO(ConsumeDouble(&value));
790  break;
791  }
792 
794  double value;
795  DO(ConsumeDouble(&value));
797  break;
798  }
799 
802  DO(ConsumeString(&value));
803  SET_FIELD(String, value);
804  break;
805  }
806 
808  if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
809  uint64_t value;
810  DO(ConsumeUnsignedInteger(&value, 1));
811  SET_FIELD(Bool, value);
812  } else {
814  DO(ConsumeIdentifier(&value));
815  if (value == "true" || value == "True" || value == "t") {
816  SET_FIELD(Bool, true);
817  } else if (value == "false" || value == "False" || value == "f") {
818  SET_FIELD(Bool, false);
819  } else {
820  ReportError("Invalid value for boolean field \"" + field->name() +
821  "\". Value: \"" + value + "\".");
822  return false;
823  }
824  }
825  break;
826  }
827 
830  int64_t int_value = kint64max;
831  const EnumDescriptor* enum_type = field->enum_type();
832  const EnumValueDescriptor* enum_value = nullptr;
833 
834  if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
835  DO(ConsumeIdentifier(&value));
836  // Find the enumeration value.
837  enum_value = enum_type->FindValueByName(value);
838 
839  } else if (LookingAt("-") ||
840  LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
841  DO(ConsumeSignedInteger(&int_value, kint32max));
842  value = StrCat(int_value); // for error reporting
843  enum_value = enum_type->FindValueByNumber(int_value);
844  } else {
845  ReportError("Expected integer or identifier, got: " +
846  tokenizer_.current().text);
847  return false;
848  }
849 
850  if (enum_value == nullptr) {
851  if (int_value != kint64max &&
852  reflection->SupportsUnknownEnumValues()) {
853  SET_FIELD(EnumValue, int_value);
854  return true;
855  } else if (!allow_unknown_enum_) {
856  ReportError("Unknown enumeration value of \"" + value +
857  "\" for "
858  "field \"" +
859  field->name() + "\".");
860  return false;
861  } else {
862  ReportWarning("Unknown enumeration value of \"" + value +
863  "\" for "
864  "field \"" +
865  field->name() + "\".");
866  return true;
867  }
868  }
869 
870  SET_FIELD(Enum, enum_value);
871  break;
872  }
873 
875  // We should never get here. Put here instead of a default
876  // so that if new types are added, we get a nice compiler warning.
877  GOOGLE_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE";
878  break;
879  }
880  }
881 #undef SET_FIELD
882  return true;
883  }
884 
885  bool SkipFieldValue() {
886  if (--recursion_limit_ < 0) {
887  ReportError(
888  StrCat("Message is too deep, the parser exceeded the "
889  "configured recursion limit of ",
890  initial_recursion_limit_, "."));
891  return false;
892  }
893 
894  if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
895  while (LookingAtType(io::Tokenizer::TYPE_STRING)) {
896  tokenizer_.Next();
897  }
898  ++recursion_limit_;
899  return true;
900  }
901  if (TryConsume("[")) {
902  while (true) {
903  if (!LookingAt("{") && !LookingAt("<")) {
904  DO(SkipFieldValue());
905  } else {
906  DO(SkipFieldMessage());
907  }
908  if (TryConsume("]")) {
909  break;
910  }
911  DO(Consume(","));
912  }
913  ++recursion_limit_;
914  return true;
915  }
916  // Possible field values other than string:
917  // 12345 => TYPE_INTEGER
918  // -12345 => TYPE_SYMBOL + TYPE_INTEGER
919  // 1.2345 => TYPE_FLOAT
920  // -1.2345 => TYPE_SYMBOL + TYPE_FLOAT
921  // inf => TYPE_IDENTIFIER
922  // -inf => TYPE_SYMBOL + TYPE_IDENTIFIER
923  // TYPE_INTEGER => TYPE_IDENTIFIER
924  // Divides them into two group, one with TYPE_SYMBOL
925  // and the other without:
926  // Group one:
927  // 12345 => TYPE_INTEGER
928  // 1.2345 => TYPE_FLOAT
929  // inf => TYPE_IDENTIFIER
930  // TYPE_INTEGER => TYPE_IDENTIFIER
931  // Group two:
932  // -12345 => TYPE_SYMBOL + TYPE_INTEGER
933  // -1.2345 => TYPE_SYMBOL + TYPE_FLOAT
934  // -inf => TYPE_SYMBOL + TYPE_IDENTIFIER
935  // As we can see, the field value consists of an optional '-' and one of
936  // TYPE_INTEGER, TYPE_FLOAT and TYPE_IDENTIFIER.
937  bool has_minus = TryConsume("-");
938  if (!LookingAtType(io::Tokenizer::TYPE_INTEGER) &&
939  !LookingAtType(io::Tokenizer::TYPE_FLOAT) &&
940  !LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
941  std::string text = tokenizer_.current().text;
942  ReportError("Cannot skip field value, unexpected token: " + text);
943  ++recursion_limit_;
944  return false;
945  }
946  // Combination of '-' and TYPE_IDENTIFIER may result in an invalid field
947  // value while other combinations all generate valid values.
948  // We check if the value of this combination is valid here.
949  // TYPE_IDENTIFIER after a '-' should be one of the float values listed
950  // below:
951  // inf, inff, infinity, nan
952  if (has_minus && LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
953  std::string text = tokenizer_.current().text;
954  LowerString(&text);
955  if (text != "inf" &&
956  text != "infinity" && text != "nan") {
957  ReportError("Invalid float number: " + text);
958  ++recursion_limit_;
959  return false;
960  }
961  }
962  tokenizer_.Next();
963  ++recursion_limit_;
964  return true;
965  }
966 
967  // Returns true if the current token's text is equal to that specified.
968  bool LookingAt(const std::string& text) {
969  return tokenizer_.current().text == text;
970  }
971 
972  // Returns true if the current token's type is equal to that specified.
974  return tokenizer_.current().type == token_type;
975  }
976 
977  // Consumes an identifier and saves its value in the identifier parameter.
978  // Returns false if the token is not of type IDENTFIER.
979  bool ConsumeIdentifier(std::string* identifier) {
980  if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
981  *identifier = tokenizer_.current().text;
982  tokenizer_.Next();
983  return true;
984  }
985 
986  // If allow_field_numer_ or allow_unknown_field_ is true, we should able
987  // to parse integer identifiers.
988  if ((allow_field_number_ || allow_unknown_field_ ||
989  allow_unknown_extension_) &&
990  LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
991  *identifier = tokenizer_.current().text;
992  tokenizer_.Next();
993  return true;
994  }
995 
996  ReportError("Expected identifier, got: " + tokenizer_.current().text);
997  return false;
998  }
999 
1000  // Similar to `ConsumeIdentifier`, but any following whitespace token may
1001  // be reported.
1003  tokenizer_.set_report_whitespace(true);
1004  bool result = ConsumeIdentifier(identifier);
1005  tokenizer_.set_report_whitespace(false);
1006  return result;
1007  }
1008 
1009  // Consume a string of form "<id1>.<id2>....<idN>".
1011  DO(ConsumeIdentifier(name));
1012  while (TryConsume(".")) {
1013  std::string part;
1014  DO(ConsumeIdentifier(&part));
1015  *name += ".";
1016  *name += part;
1017  }
1018  return true;
1019  }
1020 
1022  std::string discarded;
1023  DO(ConsumeIdentifier(&discarded));
1024  while (TryConsume(".") || TryConsume("/")) {
1025  DO(ConsumeIdentifier(&discarded));
1026  }
1027  return true;
1028  }
1029 
1030  // Consumes a string and saves its value in the text parameter.
1031  // Returns false if the token is not of type STRING.
1033  if (!LookingAtType(io::Tokenizer::TYPE_STRING)) {
1034  ReportError("Expected string, got: " + tokenizer_.current().text);
1035  return false;
1036  }
1037 
1038  text->clear();
1039  while (LookingAtType(io::Tokenizer::TYPE_STRING)) {
1040  io::Tokenizer::ParseStringAppend(tokenizer_.current().text, text);
1041 
1042  tokenizer_.Next();
1043  }
1044 
1045  return true;
1046  }
1047 
1048  // Consumes a uint64_t and saves its value in the value parameter.
1049  // Returns false if the token is not of type INTEGER.
1051  if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
1052  ReportError("Expected integer, got: " + tokenizer_.current().text);
1053  return false;
1054  }
1055 
1056  if (!io::Tokenizer::ParseInteger(tokenizer_.current().text, max_value,
1057  value)) {
1058  ReportError("Integer out of range (" + tokenizer_.current().text + ")");
1059  return false;
1060  }
1061 
1062  tokenizer_.Next();
1063  return true;
1064  }
1065 
1066  // Consumes an int64_t and saves its value in the value parameter.
1067  // Note that since the tokenizer does not support negative numbers,
1068  // we actually may consume an additional token (for the minus sign) in this
1069  // method. Returns false if the token is not an integer
1070  // (signed or otherwise).
1072  bool negative = false;
1073 
1074  if (TryConsume("-")) {
1075  negative = true;
1076  // Two's complement always allows one more negative integer than
1077  // positive.
1078  ++max_value;
1079  }
1080 
1081  uint64_t unsigned_value;
1082 
1083  DO(ConsumeUnsignedInteger(&unsigned_value, max_value));
1084 
1085  if (negative) {
1086  if ((static_cast<uint64_t>(kint64max) + 1) == unsigned_value) {
1087  *value = kint64min;
1088  } else {
1089  *value = -static_cast<int64_t>(unsigned_value);
1090  }
1091  } else {
1092  *value = static_cast<int64_t>(unsigned_value);
1093  }
1094 
1095  return true;
1096  }
1097 
1098  // Consumes a double and saves its value in the value parameter.
1099  // Accepts decimal numbers only, rejects hex or oct numbers.
1100  bool ConsumeUnsignedDecimalAsDouble(double* value, uint64_t max_value) {
1101  if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
1102  ReportError("Expected integer, got: " + tokenizer_.current().text);
1103  return false;
1104  }
1105 
1106  const std::string& text = tokenizer_.current().text;
1107  if (IsHexNumber(text) || IsOctNumber(text)) {
1108  ReportError("Expect a decimal number, got: " + text);
1109  return false;
1110  }
1111 
1112  uint64_t uint64_value;
1113  if (io::Tokenizer::ParseInteger(text, max_value, &uint64_value)) {
1114  *value = static_cast<double>(uint64_value);
1115  } else {
1116  // Uint64 overflow, attempt to parse as a double instead.
1118  }
1119 
1120  tokenizer_.Next();
1121  return true;
1122  }
1123 
1124  // Consumes a double and saves its value in the value parameter.
1125  // Note that since the tokenizer does not support negative numbers,
1126  // we actually may consume an additional token (for the minus sign) in this
1127  // method. Returns false if the token is not a double
1128  // (signed or otherwise).
1129  bool ConsumeDouble(double* value) {
1130  bool negative = false;
1131 
1132  if (TryConsume("-")) {
1133  negative = true;
1134  }
1135 
1136  // A double can actually be an integer, according to the tokenizer.
1137  // Therefore, we must check both cases here.
1138  if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
1139  // We have found an integer value for the double.
1140  DO(ConsumeUnsignedDecimalAsDouble(value, kuint64max));
1141  } else if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) {
1142  // We have found a float value for the double.
1143  *value = io::Tokenizer::ParseFloat(tokenizer_.current().text);
1144 
1145  // Mark the current token as consumed.
1146  tokenizer_.Next();
1147  } else if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
1148  std::string text = tokenizer_.current().text;
1149  LowerString(&text);
1150  if (text == "inf" ||
1151  text == "infinity") {
1152  *value = std::numeric_limits<double>::infinity();
1153  tokenizer_.Next();
1154  } else if (text == "nan") {
1155  *value = std::numeric_limits<double>::quiet_NaN();
1156  tokenizer_.Next();
1157  } else {
1158  ReportError("Expected double, got: " + text);
1159  return false;
1160  }
1161  } else {
1162  ReportError("Expected double, got: " + tokenizer_.current().text);
1163  return false;
1164  }
1165 
1166  if (negative) {
1167  *value = -*value;
1168  }
1169 
1170  return true;
1171  }
1172 
1173  // Consumes Any::type_url value, of form "type.googleapis.com/full.type.Name"
1174  // or "type.googleprod.com/full.type.Name"
1176  // TODO(saito) Extend Consume() to consume multiple tokens at once, so that
1177  // this code can be written as just DO(Consume(kGoogleApisTypePrefix)).
1178  DO(ConsumeIdentifier(prefix));
1179  while (TryConsume(".")) {
1180  std::string url;
1181  DO(ConsumeIdentifier(&url));
1182  *prefix += "." + url;
1183  }
1184  DO(Consume("/"));
1185  *prefix += "/";
1186  DO(ConsumeFullTypeName(full_type_name));
1187 
1188  return true;
1189  }
1190 
1191  // A helper function for reconstructing Any::value. Consumes a text of
1192  // full_type_name, then serializes it into serialized_value.
1193  bool ConsumeAnyValue(const Descriptor* value_descriptor,
1194  std::string* serialized_value) {
1195  DynamicMessageFactory factory;
1196  const Message* value_prototype = factory.GetPrototype(value_descriptor);
1197  if (value_prototype == nullptr) {
1198  return false;
1199  }
1200  std::unique_ptr<Message> value(value_prototype->New());
1201  std::string sub_delimiter;
1202  DO(ConsumeMessageDelimiter(&sub_delimiter));
1203  DO(ConsumeMessage(value.get(), sub_delimiter));
1204 
1205  if (allow_partial_) {
1206  value->AppendPartialToString(serialized_value);
1207  } else {
1208  if (!value->IsInitialized()) {
1209  ReportError(
1210  "Value of type \"" + value_descriptor->full_name() +
1211  "\" stored in google.protobuf.Any has missing required fields");
1212  return false;
1213  }
1214  value->AppendToString(serialized_value);
1215  }
1216  return true;
1217  }
1218 
1219  // Consumes a token and confirms that it matches that specified in the
1220  // value parameter. Returns false if the token found does not match that
1221  // which was specified.
1222  bool Consume(const std::string& value) {
1223  const std::string& current_value = tokenizer_.current().text;
1224 
1225  if (current_value != value) {
1226  ReportError("Expected \"" + value + "\", found \"" + current_value +
1227  "\".");
1228  return false;
1229  }
1230 
1231  tokenizer_.Next();
1232 
1233  return true;
1234  }
1235 
1236  // Similar to `Consume`, but the following token may be tokenized as
1237  // TYPE_WHITESPACE.
1239  // Report whitespace after this token, but only once.
1240  tokenizer_.set_report_whitespace(true);
1241  bool result = Consume(value);
1242  tokenizer_.set_report_whitespace(false);
1243  return result;
1244  }
1245 
1246  // Attempts to consume the supplied value. Returns false if a the
1247  // token found does not match the value specified.
1249  if (tokenizer_.current().text == value) {
1250  tokenizer_.Next();
1251  return true;
1252  } else {
1253  return false;
1254  }
1255  }
1256 
1257  // Similar to `TryConsume`, but the following token may be tokenized as
1258  // TYPE_WHITESPACE.
1260  // Report whitespace after this token, but only once.
1261  tokenizer_.set_report_whitespace(true);
1262  bool result = TryConsume(value);
1263  tokenizer_.set_report_whitespace(false);
1264  return result;
1265  }
1266 
1268  const char* field_type) {
1269  if (LookingAtType(io::Tokenizer::TYPE_WHITESPACE)) {
1270  tokenizer_.Next();
1271  return true;
1272  }
1273 
1274  return false;
1275  }
1276 
1277  // An internal instance of the Tokenizer's error collector, used to
1278  // collect any base-level parse errors and feed them to the ParserImpl.
1279  class ParserErrorCollector : public io::ErrorCollector {
1280  public:
1282  : parser_(parser) {}
1283 
1285 
1286  void AddError(int line, int column, const std::string& message) override {
1287  parser_->ReportError(line, column, message);
1288  }
1289 
1290  void AddWarning(int line, int column, const std::string& message) override {
1291  parser_->ReportWarning(line, column, message);
1292  }
1293 
1294  private:
1297  };
1298 
1300  const TextFormat::Finder* finder_;
1301  ParseInfoTree* parse_info_tree_;
1302  ParserErrorCollector tokenizer_error_collector_;
1303  io::Tokenizer tokenizer_;
1304  const Descriptor* root_message_type_;
1305  SingularOverwritePolicy singular_overwrite_policy_;
1306  const bool allow_case_insensitive_field_;
1307  const bool allow_unknown_field_;
1308  const bool allow_unknown_extension_;
1309  const bool allow_unknown_enum_;
1310  const bool allow_field_number_;
1311  const bool allow_partial_;
1313  int recursion_limit_;
1314  bool had_errors_;
1315 };
1316 
1317 // ===========================================================================
1318 // Internal class for writing text to the io::ZeroCopyOutputStream. Adapted
1319 // from the Printer found in //net/proto2/io/public/printer.h
1320 class TextFormat::Printer::TextGenerator
1322  public:
1324  int initial_indent_level)
1325  : output_(output),
1326  buffer_(nullptr),
1327  buffer_size_(0),
1328  at_start_of_line_(true),
1329  failed_(false),
1330  insert_silent_marker_(false),
1331  indent_level_(initial_indent_level),
1332  initial_indent_level_(initial_indent_level) {}
1333 
1335  bool insert_silent_marker, int initial_indent_level)
1336  : output_(output),
1337  buffer_(nullptr),
1338  buffer_size_(0),
1339  at_start_of_line_(true),
1340  failed_(false),
1341  insert_silent_marker_(insert_silent_marker),
1342  indent_level_(initial_indent_level),
1343  initial_indent_level_(initial_indent_level) {}
1344 
1346  // Only BackUp() if we're sure we've successfully called Next() at least
1347  // once.
1348  if (!failed_ && buffer_size_ > 0) {
1349  output_->BackUp(buffer_size_);
1350  }
1351  }
1352 
1353  // Indent text by two spaces. After calling Indent(), two spaces will be
1354  // inserted at the beginning of each line of text. Indent() may be called
1355  // multiple times to produce deeper indents.
1356  void Indent() override { ++indent_level_; }
1357 
1358  // Reduces the current indent level by two spaces, or crashes if the indent
1359  // level is zero.
1360  void Outdent() override {
1361  if (indent_level_ == 0 || indent_level_ < initial_indent_level_) {
1362  GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent().";
1363  return;
1364  }
1365 
1366  --indent_level_;
1367  }
1368 
1369  size_t GetCurrentIndentationSize() const override {
1370  return 2 * indent_level_;
1371  }
1372 
1373  // Print text to the output stream.
1374  void Print(const char* text, size_t size) override {
1375  if (indent_level_ > 0) {
1376  size_t pos = 0; // The number of bytes we've written so far.
1377  for (size_t i = 0; i < size; i++) {
1378  if (text[i] == '\n') {
1379  // Saw newline. If there is more text, we may need to insert an
1380  // indent here. So, write what we have so far, including the '\n'.
1381  Write(text + pos, i - pos + 1);
1382  pos = i + 1;
1383 
1384  // Setting this true will cause the next Write() to insert an indent
1385  // first.
1386  at_start_of_line_ = true;
1387  }
1388  }
1389  // Write the rest.
1390  Write(text + pos, size - pos);
1391  } else {
1392  Write(text, size);
1393  if (size > 0 && text[size - 1] == '\n') {
1394  at_start_of_line_ = true;
1395  }
1396  }
1397  }
1398 
1399  // True if any write to the underlying stream failed. (We don't just
1400  // crash in this case because this is an I/O failure, not a programming
1401  // error.)
1402  bool failed() const { return failed_; }
1403 
1405  Print(text.data(), text.size());
1406  if (ConsumeInsertSilentMarker()) {
1407  PrintLiteral(DEBUG_STRING_SILENT_MARKER);
1408  }
1409  }
1410 
1412  StringPiece text_tail) {
1413  Print(text_head.data(), text_head.size());
1414  if (ConsumeInsertSilentMarker()) {
1415  PrintLiteral(DEBUG_STRING_SILENT_MARKER);
1416  }
1417  Print(text_tail.data(), text_tail.size());
1418  }
1419 
1420  private:
1422 
1423  void Write(const char* data, size_t size) {
1424  if (failed_) return;
1425  if (size == 0) return;
1426 
1427  if (at_start_of_line_) {
1428  // Insert an indent.
1429  at_start_of_line_ = false;
1430  WriteIndent();
1431  if (failed_) return;
1432  }
1433 
1434  while (static_cast<int64_t>(size) > buffer_size_) {
1435  // Data exceeds space in the buffer. Copy what we can and request a
1436  // new buffer.
1437  if (buffer_size_ > 0) {
1438  memcpy(buffer_, data, buffer_size_);
1439  data += buffer_size_;
1440  size -= buffer_size_;
1441  }
1442  void* void_buffer = nullptr;
1443  failed_ = !output_->Next(&void_buffer, &buffer_size_);
1444  if (failed_) return;
1445  buffer_ = reinterpret_cast<char*>(void_buffer);
1446  }
1447 
1448  // Buffer is big enough to receive the data; copy it.
1449  memcpy(buffer_, data, size);
1450  buffer_ += size;
1451  buffer_size_ -= size;
1452  }
1453 
1454  void WriteIndent() {
1455  if (indent_level_ == 0) {
1456  return;
1457  }
1458  GOOGLE_DCHECK(!failed_);
1459  int size = GetCurrentIndentationSize();
1460 
1461  while (size > buffer_size_) {
1462  // Data exceeds space in the buffer. Write what we can and request a new
1463  // buffer.
1464  if (buffer_size_ > 0) {
1465  memset(buffer_, ' ', buffer_size_);
1466  }
1467  size -= buffer_size_;
1468  void* void_buffer;
1469  failed_ = !output_->Next(&void_buffer, &buffer_size_);
1470  if (failed_) return;
1471  buffer_ = reinterpret_cast<char*>(void_buffer);
1472  }
1473 
1474  // Buffer is big enough to receive the data; copy it.
1475  memset(buffer_, ' ', size);
1476  buffer_ += size;
1477  buffer_size_ -= size;
1478  }
1479 
1480  // Return the current value of insert_silent_marker_. If it is true, set it
1481  // to false as we assume that a silent marker is inserted after a call to this
1482  // function.
1484  if (insert_silent_marker_) {
1485  insert_silent_marker_ = false;
1486  return true;
1487  }
1488  return false;
1489  }
1490 
1492  char* buffer_;
1493  int buffer_size_;
1494  bool at_start_of_line_;
1495  bool failed_;
1496  // This flag is false when inserting silent marker is disabled or a silent
1497  // marker has been inserted.
1499 
1500  int indent_level_;
1501  int initial_indent_level_;
1502 };
1503 
1504 // ===========================================================================
1505 // An internal field value printer that may insert a silent marker in
1506 // DebugStrings.
1509  public:
1510  void PrintMessageStart(const Message& /*message*/, int /*field_index*/,
1511  int /*field_count*/, bool single_line_mode,
1512  BaseTextGenerator* generator) const override {
1513  // This is safe as only TextGenerator is used with
1514  // DebugStringFieldValuePrinter.
1515  TextGenerator* text_generator = static_cast<TextGenerator*>(generator);
1516  if (single_line_mode) {
1517  text_generator->PrintMaybeWithMarker(" ", "{ ");
1518  } else {
1519  text_generator->PrintMaybeWithMarker(" ", "{\n");
1520  }
1521  }
1522 };
1523 
1524 // ===========================================================================
1525 // An internal field value printer that escape UTF8 strings.
1528  public:
1529  void PrintString(const std::string& val,
1530  TextFormat::BaseTextGenerator* generator) const override {
1531  generator->PrintLiteral("\"");
1532  generator->PrintString(strings::Utf8SafeCEscape(val));
1533  generator->PrintLiteral("\"");
1534  }
1535  void PrintBytes(const std::string& val,
1536  TextFormat::BaseTextGenerator* generator) const override {
1537  return FastFieldValuePrinter::PrintString(val, generator);
1538  }
1539 };
1540 
1541 // ===========================================================================
1542 // Implementation of the default Finder for extensions.
1544 
1546  Message* message, const std::string& name) const {
1547  return DefaultFinderFindExtension(message, name);
1548 }
1549 
1551  const Descriptor* descriptor, int number) const {
1552  return DefaultFinderFindExtensionByNumber(descriptor, number);
1553 }
1554 
1556  const Message& message, const std::string& prefix,
1557  const std::string& name) const {
1558  return DefaultFinderFindAnyType(message, prefix, name);
1559 }
1560 
1562  const FieldDescriptor* /*field*/) const {
1563  return nullptr;
1564 }
1565 
1566 // ===========================================================================
1567 
1569  : error_collector_(nullptr),
1570  finder_(nullptr),
1571  parse_info_tree_(nullptr),
1572  allow_partial_(false),
1573  allow_case_insensitive_field_(false),
1574  allow_unknown_field_(false),
1575  allow_unknown_extension_(false),
1576  allow_unknown_enum_(false),
1577  allow_field_number_(false),
1578  allow_relaxed_whitespace_(false),
1579  allow_singular_overwrites_(false),
1580  recursion_limit_(std::numeric_limits<int>::max()) {}
1581 
1583 
1584 namespace {
1585 
1586 bool CheckParseInputSize(StringPiece input,
1587  io::ErrorCollector* error_collector) {
1588  if (input.size() > INT_MAX) {
1589  error_collector->AddError(
1590  -1, 0,
1591  StrCat(
1592  "Input size too large: ", static_cast<int64_t>(input.size()),
1593  " bytes", " > ", INT_MAX, " bytes."));
1594  return false;
1595  }
1596  return true;
1597 }
1598 
1599 } // namespace
1600 
1602  Message* output) {
1603  output->Clear();
1604 
1605  ParserImpl::SingularOverwritePolicy overwrites_policy =
1606  allow_singular_overwrites_ ? ParserImpl::ALLOW_SINGULAR_OVERWRITES
1607  : ParserImpl::FORBID_SINGULAR_OVERWRITES;
1608 
1609  ParserImpl parser(output->GetDescriptor(), input, error_collector_, finder_,
1610  parse_info_tree_, overwrites_policy,
1611  allow_case_insensitive_field_, allow_unknown_field_,
1612  allow_unknown_extension_, allow_unknown_enum_,
1613  allow_field_number_, allow_relaxed_whitespace_,
1614  allow_partial_, recursion_limit_);
1615  return MergeUsingImpl(input, output, &parser);
1616 }
1617 
1619  Message* output) {
1620  DO(CheckParseInputSize(input, error_collector_));
1621  io::ArrayInputStream input_stream(input.data(), input.size());
1622  return Parse(&input_stream, output);
1623 }
1624 
1626  Message* output) {
1627  ParserImpl parser(output->GetDescriptor(), input, error_collector_, finder_,
1628  parse_info_tree_, ParserImpl::ALLOW_SINGULAR_OVERWRITES,
1629  allow_case_insensitive_field_, allow_unknown_field_,
1630  allow_unknown_extension_, allow_unknown_enum_,
1631  allow_field_number_, allow_relaxed_whitespace_,
1632  allow_partial_, recursion_limit_);
1633  return MergeUsingImpl(input, output, &parser);
1634 }
1635 
1637  Message* output) {
1638  DO(CheckParseInputSize(input, error_collector_));
1639  io::ArrayInputStream input_stream(input.data(), input.size());
1640  return Merge(&input_stream, output);
1641 }
1642 
1643 
1645  Message* output,
1646  ParserImpl* parser_impl) {
1647  if (!parser_impl->Parse(output)) return false;
1648  if (!allow_partial_ && !output->IsInitialized()) {
1649  std::vector<std::string> missing_fields;
1650  output->FindInitializationErrors(&missing_fields);
1651  parser_impl->ReportError(-1, 0,
1652  "Message missing required fields: " +
1653  Join(missing_fields, ", "));
1654  return false;
1655  }
1656  return true;
1657 }
1658 
1660  const FieldDescriptor* field,
1661  Message* output) {
1662  io::ArrayInputStream input_stream(input.data(), input.size());
1663  ParserImpl parser(
1664  output->GetDescriptor(), &input_stream, error_collector_, finder_,
1665  parse_info_tree_, ParserImpl::ALLOW_SINGULAR_OVERWRITES,
1666  allow_case_insensitive_field_, allow_unknown_field_,
1667  allow_unknown_extension_, allow_unknown_enum_, allow_field_number_,
1668  allow_relaxed_whitespace_, allow_partial_, recursion_limit_);
1669  return parser.ParseField(field, output);
1670 }
1671 
1673  Message* output) {
1674  return Parser().Parse(input, output);
1675 }
1676 
1678  Message* output) {
1679  return Parser().Merge(input, output);
1680 }
1681 
1683  Message* output) {
1684  return Parser().ParseFromString(input, output);
1685 }
1686 
1688  Message* output) {
1689  return Parser().MergeFromString(input, output);
1690 }
1691 
1692 
1693 #undef DO
1694 
1695 // ===========================================================================
1696 
1698 
1699 namespace {
1700 
1701 // A BaseTextGenerator that writes to a string.
1702 class StringBaseTextGenerator : public TextFormat::BaseTextGenerator {
1703  public:
1704  void Print(const char* text, size_t size) override {
1705  output_.append(text, size);
1706  }
1707 
1708 // Some compilers do not support ref-qualifiers even in C++11 mode.
1709 // Disable the optimization for now and revisit it later.
1710 #if 0 // LANG_CXX11
1711  std::string Consume() && { return std::move(output_); }
1712 #else // !LANG_CXX11
1713  const std::string& Get() { return output_; }
1714 #endif // LANG_CXX11
1715 
1716  private:
1718 };
1719 
1720 } // namespace
1721 
1722 // The default implementation for FieldValuePrinter. We just delegate the
1723 // implementation to the default FastFieldValuePrinter to avoid duplicating the
1724 // logic.
1727 
1728 #if 0 // LANG_CXX11
1729 #define FORWARD_IMPL(fn, ...) \
1730  StringBaseTextGenerator generator; \
1731  delegate_.fn(__VA_ARGS__, &generator); \
1732  return std::move(generator).Consume()
1733 #else // !LANG_CXX11
1734 #define FORWARD_IMPL(fn, ...) \
1735  StringBaseTextGenerator generator; \
1736  delegate_.fn(__VA_ARGS__, &generator); \
1737  return generator.Get()
1738 #endif // LANG_CXX11
1739 
1741  FORWARD_IMPL(PrintBool, val);
1742 }
1744  FORWARD_IMPL(PrintInt32, val);
1745 }
1747  FORWARD_IMPL(PrintUInt32, val);
1748 }
1750  FORWARD_IMPL(PrintInt64, val);
1751 }
1753  FORWARD_IMPL(PrintUInt64, val);
1754 }
1756  FORWARD_IMPL(PrintFloat, val);
1757 }
1759  FORWARD_IMPL(PrintDouble, val);
1760 }
1762  const std::string& val) const {
1763  FORWARD_IMPL(PrintString, val);
1764 }
1766  const std::string& val) const {
1767  return PrintString(val);
1768 }
1770  int32_t val, const std::string& name) const {
1771  FORWARD_IMPL(PrintEnum, val, name);
1772 }
1774  const Message& message, const Reflection* reflection,
1775  const FieldDescriptor* field) const {
1776  FORWARD_IMPL(PrintFieldName, message, reflection, field);
1777 }
1779  const Message& message, int field_index, int field_count,
1780  bool single_line_mode) const {
1781  FORWARD_IMPL(PrintMessageStart, message, field_index, field_count,
1782  single_line_mode);
1783 }
1785  const Message& message, int field_index, int field_count,
1786  bool single_line_mode) const {
1787  FORWARD_IMPL(PrintMessageEnd, message, field_index, field_count,
1788  single_line_mode);
1789 }
1790 #undef FORWARD_IMPL
1791 
1795  bool val, BaseTextGenerator* generator) const {
1796  if (val) {
1797  generator->PrintLiteral("true");
1798  } else {
1799  generator->PrintLiteral("false");
1800  }
1801 }
1803  int32_t val, BaseTextGenerator* generator) const {
1804  generator->PrintString(StrCat(val));
1805 }
1807  uint32_t val, BaseTextGenerator* generator) const {
1808  generator->PrintString(StrCat(val));
1809 }
1811  int64_t val, BaseTextGenerator* generator) const {
1812  generator->PrintString(StrCat(val));
1813 }
1815  uint64_t val, BaseTextGenerator* generator) const {
1816  generator->PrintString(StrCat(val));
1817 }
1819  float val, BaseTextGenerator* generator) const {
1820  generator->PrintString(!std::isnan(val) ? SimpleFtoa(val) : "nan");
1821 }
1823  double val, BaseTextGenerator* generator) const {
1824  generator->PrintString(!std::isnan(val) ? SimpleDtoa(val) : "nan");
1825 }
1827  int32_t /*val*/, const std::string& name,
1828  BaseTextGenerator* generator) const {
1829  generator->PrintString(name);
1830 }
1831 
1833  const std::string& val, BaseTextGenerator* generator) const {
1834  generator->PrintLiteral("\"");
1835  generator->PrintString(CEscape(val));
1836  generator->PrintLiteral("\"");
1837 }
1839  const std::string& val, BaseTextGenerator* generator) const {
1840  PrintString(val, generator);
1841 }
1843  const Message& message, int /*field_index*/, int /*field_count*/,
1844  const Reflection* reflection, const FieldDescriptor* field,
1845  BaseTextGenerator* generator) const {
1846  PrintFieldName(message, reflection, field, generator);
1847 }
1849  const Message& /*message*/, const Reflection* /*reflection*/,
1850  const FieldDescriptor* field, BaseTextGenerator* generator) const {
1851  if (field->is_extension()) {
1852  generator->PrintLiteral("[");
1853  generator->PrintString(field->PrintableNameForExtension());
1854  generator->PrintLiteral("]");
1855  } else if (field->type() == FieldDescriptor::TYPE_GROUP) {
1856  // Groups must be serialized with their original capitalization.
1857  generator->PrintString(field->message_type()->name());
1858  } else {
1859  generator->PrintString(field->name());
1860  }
1861 }
1863  const Message& /*message*/, int /*field_index*/, int /*field_count*/,
1864  bool single_line_mode, BaseTextGenerator* generator) const {
1865  if (single_line_mode) {
1866  generator->PrintLiteral(" { ");
1867  } else {
1868  generator->PrintLiteral(" {\n");
1869  }
1870 }
1872  const Message& /*message*/, int /*field_index*/, int /*field_count*/,
1873  bool /*single_line_mode*/, BaseTextGenerator* /*generator*/) const {
1874  return false; // Use the default printing function.
1875 }
1877  const Message& /*message*/, int /*field_index*/, int /*field_count*/,
1878  bool single_line_mode, BaseTextGenerator* generator) const {
1879  if (single_line_mode) {
1880  generator->PrintLiteral("} ");
1881  } else {
1882  generator->PrintLiteral("}\n");
1883  }
1884 }
1885 
1886 namespace {
1887 
1888 // A legacy compatibility wrapper. Takes ownership of the delegate.
1889 class FieldValuePrinterWrapper : public TextFormat::FastFieldValuePrinter {
1890  public:
1891  explicit FieldValuePrinterWrapper(
1892  const TextFormat::FieldValuePrinter* delegate)
1893  : delegate_(delegate) {}
1894 
1895  void SetDelegate(const TextFormat::FieldValuePrinter* delegate) {
1896  delegate_.reset(delegate);
1897  }
1898 
1899  void PrintBool(bool val,
1900  TextFormat::BaseTextGenerator* generator) const override {
1901  generator->PrintString(delegate_->PrintBool(val));
1902  }
1903  void PrintInt32(int32_t val,
1904  TextFormat::BaseTextGenerator* generator) const override {
1905  generator->PrintString(delegate_->PrintInt32(val));
1906  }
1907  void PrintUInt32(uint32_t val,
1908  TextFormat::BaseTextGenerator* generator) const override {
1909  generator->PrintString(delegate_->PrintUInt32(val));
1910  }
1911  void PrintInt64(int64_t val,
1912  TextFormat::BaseTextGenerator* generator) const override {
1913  generator->PrintString(delegate_->PrintInt64(val));
1914  }
1915  void PrintUInt64(uint64_t val,
1916  TextFormat::BaseTextGenerator* generator) const override {
1917  generator->PrintString(delegate_->PrintUInt64(val));
1918  }
1919  void PrintFloat(float val,
1920  TextFormat::BaseTextGenerator* generator) const override {
1921  generator->PrintString(delegate_->PrintFloat(val));
1922  }
1923  void PrintDouble(double val,
1924  TextFormat::BaseTextGenerator* generator) const override {
1925  generator->PrintString(delegate_->PrintDouble(val));
1926  }
1927  void PrintString(const std::string& val,
1928  TextFormat::BaseTextGenerator* generator) const override {
1929  generator->PrintString(delegate_->PrintString(val));
1930  }
1931  void PrintBytes(const std::string& val,
1932  TextFormat::BaseTextGenerator* generator) const override {
1933  generator->PrintString(delegate_->PrintBytes(val));
1934  }
1935  void PrintEnum(int32_t val, const std::string& name,
1936  TextFormat::BaseTextGenerator* generator) const override {
1937  generator->PrintString(delegate_->PrintEnum(val, name));
1938  }
1939  void PrintFieldName(const Message& message, int /*field_index*/,
1940  int /*field_count*/, const Reflection* reflection,
1941  const FieldDescriptor* field,
1942  TextFormat::BaseTextGenerator* generator) const override {
1943  generator->PrintString(
1944  delegate_->PrintFieldName(message, reflection, field));
1945  }
1946  void PrintFieldName(const Message& message, const Reflection* reflection,
1947  const FieldDescriptor* field,
1948  TextFormat::BaseTextGenerator* generator) const override {
1949  generator->PrintString(
1950  delegate_->PrintFieldName(message, reflection, field));
1951  }
1952  void PrintMessageStart(
1953  const Message& message, int field_index, int field_count,
1954  bool single_line_mode,
1955  TextFormat::BaseTextGenerator* generator) const override {
1956  generator->PrintString(delegate_->PrintMessageStart(
1957  message, field_index, field_count, single_line_mode));
1958  }
1959  void PrintMessageEnd(
1960  const Message& message, int field_index, int field_count,
1961  bool single_line_mode,
1962  TextFormat::BaseTextGenerator* generator) const override {
1963  generator->PrintString(delegate_->PrintMessageEnd(
1964  message, field_index, field_count, single_line_mode));
1965  }
1966 
1967  private:
1968  std::unique_ptr<const TextFormat::FieldValuePrinter> delegate_;
1969 };
1970 
1971 } // namespace
1972 
1973 const char* const TextFormat::Printer::kDoNotParse =
1974  "DO NOT PARSE: fields may be stripped and missing.\n";
1975 
1977  : initial_indent_level_(0),
1984  expand_any_(false),
1986  finder_(nullptr) {
1987  SetUseUtf8StringEscaping(false);
1988 }
1989 
1990 void TextFormat::Printer::SetUseUtf8StringEscaping(bool as_utf8) {
1991  SetDefaultFieldValuePrinter(as_utf8 ? new FastFieldValuePrinterUtf8Escaping()
1992  : new DebugStringFieldValuePrinter());
1993 }
1994 
1995 void TextFormat::Printer::SetDefaultFieldValuePrinter(
1996  const FieldValuePrinter* printer) {
1997  default_field_value_printer_.reset(new FieldValuePrinterWrapper(printer));
1998 }
1999 
2000 void TextFormat::Printer::SetDefaultFieldValuePrinter(
2001  const FastFieldValuePrinter* printer) {
2002  default_field_value_printer_.reset(printer);
2003 }
2004 
2005 bool TextFormat::Printer::RegisterFieldValuePrinter(
2006  const FieldDescriptor* field, const FieldValuePrinter* printer) {
2007  if (field == nullptr || printer == nullptr) {
2008  return false;
2009  }
2010  std::unique_ptr<FieldValuePrinterWrapper> wrapper(
2011  new FieldValuePrinterWrapper(nullptr));
2012  auto pair = custom_printers_.insert(std::make_pair(field, nullptr));
2013  if (pair.second) {
2014  wrapper->SetDelegate(printer);
2015  pair.first->second = std::move(wrapper);
2016  return true;
2017  } else {
2018  return false;
2019  }
2020 }
2021 
2022 bool TextFormat::Printer::RegisterFieldValuePrinter(
2023  const FieldDescriptor* field, const FastFieldValuePrinter* printer) {
2024  if (field == nullptr || printer == nullptr) {
2025  return false;
2026  }
2027  auto pair = custom_printers_.insert(std::make_pair(field, nullptr));
2028  if (pair.second) {
2029  pair.first->second.reset(printer);
2030  return true;
2031  } else {
2032  return false;
2033  }
2034 }
2035 
2036 bool TextFormat::Printer::RegisterMessagePrinter(
2037  const Descriptor* descriptor, const MessagePrinter* printer) {
2038  if (descriptor == nullptr || printer == nullptr) {
2039  return false;
2040  }
2041  auto pair =
2042  custom_message_printers_.insert(std::make_pair(descriptor, nullptr));
2043  if (pair.second) {
2044  pair.first->second.reset(printer);
2045  return true;
2046  } else {
2047  return false;
2048  }
2049 }
2050 
2052  std::string* output) const {
2053  GOOGLE_DCHECK(output) << "output specified is nullptr";
2054 
2055  output->clear();
2056  io::StringOutputStream output_stream(output);
2057 
2058  return Print(message, &output_stream);
2059 }
2060 
2061 bool TextFormat::Printer::PrintUnknownFieldsToString(
2062  const UnknownFieldSet& unknown_fields, std::string* output) const {
2063  GOOGLE_DCHECK(output) << "output specified is nullptr";
2064 
2065  output->clear();
2066  io::StringOutputStream output_stream(output);
2067  return PrintUnknownFields(unknown_fields, &output_stream);
2068 }
2069 
2072  TextGenerator generator(output, insert_silent_marker_, initial_indent_level_);
2073 
2074  Print(message, &generator);
2075 
2076  // Output false if the generator failed internally.
2077  return !generator.failed();
2078 }
2079 
2080 // Maximum recursion depth for heuristically printing out length-delimited
2081 // unknown fields as messages.
2082 static constexpr int kUnknownFieldRecursionLimit = 10;
2083 
2084 bool TextFormat::Printer::PrintUnknownFields(
2085  const UnknownFieldSet& unknown_fields,
2087  TextGenerator generator(output, initial_indent_level_);
2088 
2089  PrintUnknownFields(unknown_fields, &generator, kUnknownFieldRecursionLimit);
2090 
2091  // Output false if the generator failed internally.
2092  return !generator.failed();
2093 }
2094 
2095 namespace {
2096 // Comparison functor for sorting FieldDescriptors by field index.
2097 // Normal fields have higher precedence than extensions.
2098 struct FieldIndexSorter {
2099  bool operator()(const FieldDescriptor* left,
2100  const FieldDescriptor* right) const {
2101  if (left->is_extension() && right->is_extension()) {
2102  return left->number() < right->number();
2103  } else if (left->is_extension()) {
2104  return false;
2105  } else if (right->is_extension()) {
2106  return true;
2107  } else {
2108  return left->index() < right->index();
2109  }
2110  }
2111 };
2112 
2113 } // namespace
2114 
2115 bool TextFormat::Printer::PrintAny(const Message& message,
2116  TextGenerator* generator) const {
2117  const FieldDescriptor* type_url_field;
2118  const FieldDescriptor* value_field;
2119  if (!internal::GetAnyFieldDescriptors(message, &type_url_field,
2120  &value_field)) {
2121  return false;
2122  }
2123 
2124  const Reflection* reflection = message.GetReflection();
2125 
2126  // Extract the full type name from the type_url field.
2127  const std::string& type_url = reflection->GetString(message, type_url_field);
2128  std::string url_prefix;
2129  std::string full_type_name;
2130  if (!internal::ParseAnyTypeUrl(type_url, &url_prefix, &full_type_name)) {
2131  return false;
2132  }
2133 
2134  // Print the "value" in text.
2135  const Descriptor* value_descriptor =
2136  finder_ ? finder_->FindAnyType(message, url_prefix, full_type_name)
2137  : DefaultFinderFindAnyType(message, url_prefix, full_type_name);
2138  if (value_descriptor == nullptr) {
2139  GOOGLE_LOG(WARNING) << "Can't print proto content: proto type " << type_url
2140  << " not found";
2141  return false;
2142  }
2143  DynamicMessageFactory factory;
2144  std::unique_ptr<Message> value_message(
2145  factory.GetPrototype(value_descriptor)->New());
2146  std::string serialized_value = reflection->GetString(message, value_field);
2147  if (!value_message->ParseFromString(serialized_value)) {
2148  GOOGLE_LOG(WARNING) << type_url << ": failed to parse contents";
2149  return false;
2150  }
2151  generator->PrintLiteral("[");
2152  generator->PrintString(type_url);
2153  generator->PrintLiteral("]");
2154  const FastFieldValuePrinter* printer = GetFieldPrinter(value_field);
2155  printer->PrintMessageStart(message, -1, 0, single_line_mode_, generator);
2156  generator->Indent();
2157  Print(*value_message, generator);
2158  generator->Outdent();
2159  printer->PrintMessageEnd(message, -1, 0, single_line_mode_, generator);
2160  return true;
2161 }
2162 
2164  TextGenerator* generator) const {
2165  const Reflection* reflection = message.GetReflection();
2166  if (!reflection) {
2167  // This message does not provide any way to describe its structure.
2168  // Parse it again in an UnknownFieldSet, and display this instead.
2169  UnknownFieldSet unknown_fields;
2170  {
2171  std::string serialized = message.SerializeAsString();
2172  io::ArrayInputStream input(serialized.data(), serialized.size());
2173  unknown_fields.ParseFromZeroCopyStream(&input);
2174  }
2175  PrintUnknownFields(unknown_fields, generator, kUnknownFieldRecursionLimit);
2176  return;
2177  }
2178  const Descriptor* descriptor = message.GetDescriptor();
2179  auto itr = custom_message_printers_.find(descriptor);
2180  if (itr != custom_message_printers_.end()) {
2181  itr->second->Print(message, single_line_mode_, generator);
2182  return;
2183  }
2184  if (descriptor->full_name() == internal::kAnyFullTypeName && expand_any_ &&
2185  PrintAny(message, generator)) {
2186  return;
2187  }
2188  std::vector<const FieldDescriptor*> fields;
2189  if (descriptor->options().map_entry()) {
2190  fields.push_back(descriptor->field(0));
2191  fields.push_back(descriptor->field(1));
2192  } else {
2193  reflection->ListFieldsOmitStripped(message, &fields);
2194  if (reflection->IsMessageStripped(message.GetDescriptor())) {
2195  generator->Print(kDoNotParse, std::strlen(kDoNotParse));
2196  }
2197  }
2198 
2199  if (print_message_fields_in_index_order_) {
2200  std::sort(fields.begin(), fields.end(), FieldIndexSorter());
2201  }
2202  for (const FieldDescriptor* field : fields) {
2203  PrintField(message, reflection, field, generator);
2204  }
2205  if (!hide_unknown_fields_) {
2206  PrintUnknownFields(reflection->GetUnknownFields(message), generator,
2208  }
2209 }
2210 
2211 void TextFormat::Printer::PrintFieldValueToString(const Message& message,
2212  const FieldDescriptor* field,
2213  int index,
2214  std::string* output) const {
2215  GOOGLE_DCHECK(output) << "output specified is nullptr";
2216 
2217  output->clear();
2218  io::StringOutputStream output_stream(output);
2219  TextGenerator generator(&output_stream, initial_indent_level_);
2220 
2221  PrintFieldValue(message, message.GetReflection(), field, index, &generator);
2222 }
2223 
2224 class MapEntryMessageComparator {
2225  public:
2227  : field_(descriptor->field(0)) {}
2228 
2229  bool operator()(const Message* a, const Message* b) {
2230  const Reflection* reflection = a->GetReflection();
2231  switch (field_->cpp_type()) {
2232  case FieldDescriptor::CPPTYPE_BOOL: {
2233  bool first = reflection->GetBool(*a, field_);
2234  bool second = reflection->GetBool(*b, field_);
2235  return first < second;
2236  }
2237  case FieldDescriptor::CPPTYPE_INT32: {
2238  int32_t first = reflection->GetInt32(*a, field_);
2239  int32_t second = reflection->GetInt32(*b, field_);
2240  return first < second;
2241  }
2242  case FieldDescriptor::CPPTYPE_INT64: {
2243  int64_t first = reflection->GetInt64(*a, field_);
2244  int64_t second = reflection->GetInt64(*b, field_);
2245  return first < second;
2246  }
2247  case FieldDescriptor::CPPTYPE_UINT32: {
2248  uint32_t first = reflection->GetUInt32(*a, field_);
2249  uint32_t second = reflection->GetUInt32(*b, field_);
2250  return first < second;
2251  }
2252  case FieldDescriptor::CPPTYPE_UINT64: {
2253  uint64_t first = reflection->GetUInt64(*a, field_);
2254  uint64_t second = reflection->GetUInt64(*b, field_);
2255  return first < second;
2256  }
2257  case FieldDescriptor::CPPTYPE_STRING: {
2258  std::string first = reflection->GetString(*a, field_);
2259  std::string second = reflection->GetString(*b, field_);
2260  return first < second;
2261  }
2262  default:
2263  GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
2264  return true;
2265  }
2266  }
2267 
2268  private:
2269  const FieldDescriptor* field_;
2270 };
2271 
2272 namespace internal {
2273 class MapFieldPrinterHelper {
2274  public:
2275  // DynamicMapSorter::Sort cannot be used because it enfores syncing with
2276  // repeated field.
2277  static bool SortMap(const Message& message, const Reflection* reflection,
2278  const FieldDescriptor* field,
2279  std::vector<const Message*>* sorted_map_field);
2280  static void CopyKey(const MapKey& key, Message* message,
2281  const FieldDescriptor* field_desc);
2282  static void CopyValue(const MapValueRef& value, Message* message,
2283  const FieldDescriptor* field_desc);
2284 };
2285 
2286 // Returns true if elements contained in sorted_map_field need to be released.
2287 bool MapFieldPrinterHelper::SortMap(
2288  const Message& message, const Reflection* reflection,
2289  const FieldDescriptor* field,
2290  std::vector<const Message*>* sorted_map_field) {
2291  bool need_release = false;
2292  const MapFieldBase& base = *reflection->GetMapData(message, field);
2293 
2294  if (base.IsRepeatedFieldValid()) {
2295  const RepeatedPtrField<Message>& map_field =
2297  for (int i = 0; i < map_field.size(); ++i) {
2298  sorted_map_field->push_back(
2299  const_cast<RepeatedPtrField<Message>*>(&map_field)->Mutable(i));
2300  }
2301  } else {
2302  // TODO(teboring): For performance, instead of creating map entry message
2303  // for each element, just store map keys and sort them.
2304  const Descriptor* map_entry_desc = field->message_type();
2305  const Message* prototype =
2306  reflection->GetMessageFactory()->GetPrototype(map_entry_desc);
2307  for (MapIterator iter =
2308  reflection->MapBegin(const_cast<Message*>(&message), field);
2309  iter != reflection->MapEnd(const_cast<Message*>(&message), field);
2310  ++iter) {
2311  Message* map_entry_message = prototype->New();
2312  CopyKey(iter.GetKey(), map_entry_message, map_entry_desc->field(0));
2313  CopyValue(iter.GetValueRef(), map_entry_message,
2314  map_entry_desc->field(1));
2315  sorted_map_field->push_back(map_entry_message);
2316  }
2317  need_release = true;
2318  }
2319 
2320  MapEntryMessageComparator comparator(field->message_type());
2321  std::stable_sort(sorted_map_field->begin(), sorted_map_field->end(),
2322  comparator);
2323  return need_release;
2324 }
2325 
2326 void MapFieldPrinterHelper::CopyKey(const MapKey& key, Message* message,
2327  const FieldDescriptor* field_desc) {
2328  const Reflection* reflection = message->GetReflection();
2329  switch (field_desc->cpp_type()) {
2330  case FieldDescriptor::CPPTYPE_DOUBLE:
2331  case FieldDescriptor::CPPTYPE_FLOAT:
2332  case FieldDescriptor::CPPTYPE_ENUM:
2333  case FieldDescriptor::CPPTYPE_MESSAGE:
2334  GOOGLE_LOG(ERROR) << "Not supported.";
2335  break;
2336  case FieldDescriptor::CPPTYPE_STRING:
2337  reflection->SetString(message, field_desc, key.GetStringValue());
2338  return;
2339  case FieldDescriptor::CPPTYPE_INT64:
2340  reflection->SetInt64(message, field_desc, key.GetInt64Value());
2341  return;
2342  case FieldDescriptor::CPPTYPE_INT32:
2343  reflection->SetInt32(message, field_desc, key.GetInt32Value());
2344  return;
2345  case FieldDescriptor::CPPTYPE_UINT64:
2346  reflection->SetUInt64(message, field_desc, key.GetUInt64Value());
2347  return;
2348  case FieldDescriptor::CPPTYPE_UINT32:
2349  reflection->SetUInt32(message, field_desc, key.GetUInt32Value());
2350  return;
2351  case FieldDescriptor::CPPTYPE_BOOL:
2352  reflection->SetBool(message, field_desc, key.GetBoolValue());
2353  return;
2354  }
2355 }
2356 
2357 void MapFieldPrinterHelper::CopyValue(const MapValueRef& value,
2358  Message* message,
2359  const FieldDescriptor* field_desc) {
2360  const Reflection* reflection = message->GetReflection();
2361  switch (field_desc->cpp_type()) {
2362  case FieldDescriptor::CPPTYPE_DOUBLE:
2363  reflection->SetDouble(message, field_desc, value.GetDoubleValue());
2364  return;
2365  case FieldDescriptor::CPPTYPE_FLOAT:
2366  reflection->SetFloat(message, field_desc, value.GetFloatValue());
2367  return;
2368  case FieldDescriptor::CPPTYPE_ENUM:
2369  reflection->SetEnumValue(message, field_desc, value.GetEnumValue());
2370  return;
2371  case FieldDescriptor::CPPTYPE_MESSAGE: {
2372  Message* sub_message = value.GetMessageValue().New();
2373  sub_message->CopyFrom(value.GetMessageValue());
2374  reflection->SetAllocatedMessage(message, sub_message, field_desc);
2375  return;
2376  }
2377  case FieldDescriptor::CPPTYPE_STRING:
2378  reflection->SetString(message, field_desc, value.GetStringValue());
2379  return;
2380  case FieldDescriptor::CPPTYPE_INT64:
2381  reflection->SetInt64(message, field_desc, value.GetInt64Value());
2382  return;
2383  case FieldDescriptor::CPPTYPE_INT32:
2384  reflection->SetInt32(message, field_desc, value.GetInt32Value());
2385  return;
2386  case FieldDescriptor::CPPTYPE_UINT64:
2387  reflection->SetUInt64(message, field_desc, value.GetUInt64Value());
2388  return;
2389  case FieldDescriptor::CPPTYPE_UINT32:
2390  reflection->SetUInt32(message, field_desc, value.GetUInt32Value());
2391  return;
2392  case FieldDescriptor::CPPTYPE_BOOL:
2393  reflection->SetBool(message, field_desc, value.GetBoolValue());
2394  return;
2395  }
2396 }
2397 } // namespace internal
2398 
2400  const Reflection* reflection,
2401  const FieldDescriptor* field,
2402  TextGenerator* generator) const {
2403  if (use_short_repeated_primitives_ && field->is_repeated() &&
2404  field->cpp_type() != FieldDescriptor::CPPTYPE_STRING &&
2405  field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
2406  PrintShortRepeatedField(message, reflection, field, generator);
2407  return;
2408  }
2409 
2410  int count = 0;
2411 
2412  if (field->is_repeated()) {
2413  count = reflection->FieldSize(message, field);
2414  } else if (reflection->HasField(message, field) ||
2415  field->containing_type()->options().map_entry()) {
2416  count = 1;
2417  }
2418 
2419  std::vector<const Message*> sorted_map_field;
2420  bool need_release = false;
2421  bool is_map = field->is_map();
2422  if (is_map) {
2423  need_release = internal::MapFieldPrinterHelper::SortMap(
2424  message, reflection, field, &sorted_map_field);
2425  }
2426 
2427  for (int j = 0; j < count; ++j) {
2428  const int field_index = field->is_repeated() ? j : -1;
2429 
2430  PrintFieldName(message, field_index, count, reflection, field, generator);
2431 
2432  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
2433  const FastFieldValuePrinter* printer = GetFieldPrinter(field);
2434  const Message& sub_message =
2435  field->is_repeated()
2436  ? (is_map ? *sorted_map_field[j]
2437  : reflection->GetRepeatedMessage(message, field, j))
2438  : reflection->GetMessage(message, field);
2439  printer->PrintMessageStart(sub_message, field_index, count,
2440  single_line_mode_, generator);
2441  generator->Indent();
2442  if (!printer->PrintMessageContent(sub_message, field_index, count,
2443  single_line_mode_, generator)) {
2444  Print(sub_message, generator);
2445  }
2446  generator->Outdent();
2447  printer->PrintMessageEnd(sub_message, field_index, count,
2448  single_line_mode_, generator);
2449  } else {
2450  generator->PrintMaybeWithMarker(": ");
2451  // Write the field value.
2452  PrintFieldValue(message, reflection, field, field_index, generator);
2453  if (single_line_mode_) {
2454  generator->PrintLiteral(" ");
2455  } else {
2456  generator->PrintLiteral("\n");
2457  }
2458  }
2459  }
2460 
2461  if (need_release) {
2462  for (const Message* message_to_delete : sorted_map_field) {
2463  delete message_to_delete;
2464  }
2465  }
2466 }
2467 
2468 void TextFormat::Printer::PrintShortRepeatedField(
2469  const Message& message, const Reflection* reflection,
2470  const FieldDescriptor* field, TextGenerator* generator) const {
2471  // Print primitive repeated field in short form.
2472  int size = reflection->FieldSize(message, field);
2473  PrintFieldName(message, /*field_index=*/-1, /*field_count=*/size, reflection,
2474  field, generator);
2475  generator->PrintMaybeWithMarker(": ", "[");
2476  for (int i = 0; i < size; i++) {
2477  if (i > 0) generator->PrintLiteral(", ");
2478  PrintFieldValue(message, reflection, field, i, generator);
2479  }
2480  if (single_line_mode_) {
2481  generator->PrintLiteral("] ");
2482  } else {
2483  generator->PrintLiteral("]\n");
2484  }
2485 }
2486 
2487 void TextFormat::Printer::PrintFieldName(const Message& message,
2488  int field_index, int field_count,
2489  const Reflection* reflection,
2490  const FieldDescriptor* field,
2491  TextGenerator* generator) const {
2492  // if use_field_number_ is true, prints field number instead
2493  // of field name.
2494  if (use_field_number_) {
2495  generator->PrintString(StrCat(field->number()));
2496  return;
2497  }
2498 
2499  const FastFieldValuePrinter* printer = GetFieldPrinter(field);
2500  printer->PrintFieldName(message, field_index, field_count, reflection, field,
2501  generator);
2502 }
2503 
2505  const Reflection* reflection,
2506  const FieldDescriptor* field,
2507  int index,
2508  TextGenerator* generator) const {
2509  GOOGLE_DCHECK(field->is_repeated() || (index == -1))
2510  << "Index must be -1 for non-repeated fields";
2511 
2512  const FastFieldValuePrinter* printer = GetFieldPrinter(field);
2513 
2514  switch (field->cpp_type()) {
2515 #define OUTPUT_FIELD(CPPTYPE, METHOD) \
2516  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
2517  printer->Print##METHOD( \
2518  field->is_repeated() \
2519  ? reflection->GetRepeated##METHOD(message, field, index) \
2520  : reflection->Get##METHOD(message, field), \
2521  generator); \
2522  break
2523 
2524  OUTPUT_FIELD(INT32, Int32);
2525  OUTPUT_FIELD(INT64, Int64);
2526  OUTPUT_FIELD(UINT32, UInt32);
2527  OUTPUT_FIELD(UINT64, UInt64);
2528  OUTPUT_FIELD(FLOAT, Float);
2529  OUTPUT_FIELD(DOUBLE, Double);
2531 #undef OUTPUT_FIELD
2532 
2533  case FieldDescriptor::CPPTYPE_STRING: {
2535  const std::string& value =
2536  field->is_repeated()
2537  ? reflection->GetRepeatedStringReference(message, field, index,
2538  &scratch)
2539  : reflection->GetStringReference(message, field, &scratch);
2540  const std::string* value_to_print = &value;
2541  std::string truncated_value;
2542  if (truncate_string_field_longer_than_ > 0 &&
2543  static_cast<size_t>(truncate_string_field_longer_than_) <
2544  value.size()) {
2545  truncated_value = value.substr(0, truncate_string_field_longer_than_) +
2546  "...<truncated>...";
2547  value_to_print = &truncated_value;
2548  }
2549  if (field->type() == FieldDescriptor::TYPE_STRING) {
2550  printer->PrintString(*value_to_print, generator);
2551  } else {
2552  GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
2553  printer->PrintBytes(*value_to_print, generator);
2554  }
2555  break;
2556  }
2557 
2558  case FieldDescriptor::CPPTYPE_ENUM: {
2559  int enum_value =
2560  field->is_repeated()
2561  ? reflection->GetRepeatedEnumValue(message, field, index)
2562  : reflection->GetEnumValue(message, field);
2563  const EnumValueDescriptor* enum_desc =
2564  field->enum_type()->FindValueByNumber(enum_value);
2565  if (enum_desc != nullptr) {
2566  printer->PrintEnum(enum_value, enum_desc->name(), generator);
2567  } else {
2568  // Ordinarily, enum_desc should not be null, because proto2 has the
2569  // invariant that set enum field values must be in-range, but with the
2570  // new integer-based API for enums (or the RepeatedField<int> loophole),
2571  // it is possible for the user to force an unknown integer value. So we
2572  // simply use the integer value itself as the enum value name in this
2573  // case.
2574  printer->PrintEnum(enum_value, StrCat(enum_value), generator);
2575  }
2576  break;
2577  }
2578 
2579  case FieldDescriptor::CPPTYPE_MESSAGE:
2580  Print(field->is_repeated()
2581  ? reflection->GetRepeatedMessage(message, field, index)
2582  : reflection->GetMessage(message, field),
2583  generator);
2584  break;
2585  }
2586 }
2587 
2588 /* static */ bool TextFormat::Print(const Message& message,
2590  return Printer().Print(message, output);
2591 }
2592 
2593 /* static */ bool TextFormat::PrintUnknownFields(
2594  const UnknownFieldSet& unknown_fields, io::ZeroCopyOutputStream* output) {
2595  return Printer().PrintUnknownFields(unknown_fields, output);
2596 }
2597 
2598 /* static */ bool TextFormat::PrintToString(const Message& message,
2599  std::string* output) {
2600  return Printer().PrintToString(message, output);
2601 }
2602 
2603 /* static */ bool TextFormat::PrintUnknownFieldsToString(
2604  const UnknownFieldSet& unknown_fields, std::string* output) {
2605  return Printer().PrintUnknownFieldsToString(unknown_fields, output);
2606 }
2607 
2608 /* static */ void TextFormat::PrintFieldValueToString(
2609  const Message& message, const FieldDescriptor* field, int index,
2610  std::string* output) {
2611  return Printer().PrintFieldValueToString(message, field, index, output);
2612 }
2613 
2614 /* static */ bool TextFormat::ParseFieldValueFromString(
2616  return Parser().ParseFieldValueFromString(input, field, message);
2617 }
2618 
2619 void TextFormat::Printer::PrintUnknownFields(
2620  const UnknownFieldSet& unknown_fields, TextGenerator* generator,
2621  int recursion_budget) const {
2622  for (int i = 0; i < unknown_fields.field_count(); i++) {
2623  const UnknownField& field = unknown_fields.field(i);
2624  std::string field_number = StrCat(field.number());
2625 
2626  switch (field.type()) {
2627  case UnknownField::TYPE_VARINT:
2628  generator->PrintString(field_number);
2629  generator->PrintMaybeWithMarker(": ");
2630  generator->PrintString(StrCat(field.varint()));
2631  if (single_line_mode_) {
2632  generator->PrintLiteral(" ");
2633  } else {
2634  generator->PrintLiteral("\n");
2635  }
2636  break;
2637  case UnknownField::TYPE_FIXED32: {
2638  generator->PrintString(field_number);
2639  generator->PrintMaybeWithMarker(": ", "0x");
2640  generator->PrintString(
2642  if (single_line_mode_) {
2643  generator->PrintLiteral(" ");
2644  } else {
2645  generator->PrintLiteral("\n");
2646  }
2647  break;
2648  }
2649  case UnknownField::TYPE_FIXED64: {
2650  generator->PrintString(field_number);
2651  generator->PrintMaybeWithMarker(": ", "0x");
2652  generator->PrintString(
2654  if (single_line_mode_) {
2655  generator->PrintLiteral(" ");
2656  } else {
2657  generator->PrintLiteral("\n");
2658  }
2659  break;
2660  }
2661  case UnknownField::TYPE_LENGTH_DELIMITED: {
2662  generator->PrintString(field_number);
2663  const std::string& value = field.length_delimited();
2664  // We create a CodedInputStream so that we can adhere to our recursion
2665  // budget when we attempt to parse the data. UnknownFieldSet parsing is
2666  // recursive because of groups.
2667  io::CodedInputStream input_stream(
2668  reinterpret_cast<const uint8_t*>(value.data()), value.size());
2669  input_stream.SetRecursionLimit(recursion_budget);
2670  UnknownFieldSet embedded_unknown_fields;
2671  if (!value.empty() && recursion_budget > 0 &&
2672  embedded_unknown_fields.ParseFromCodedStream(&input_stream)) {
2673  // This field is parseable as a Message.
2674  // So it is probably an embedded message.
2675  if (single_line_mode_) {
2676  generator->PrintMaybeWithMarker(" ", "{ ");
2677  } else {
2678  generator->PrintMaybeWithMarker(" ", "{\n");
2679  generator->Indent();
2680  }
2681  PrintUnknownFields(embedded_unknown_fields, generator,
2682  recursion_budget - 1);
2683  if (single_line_mode_) {
2684  generator->PrintLiteral("} ");
2685  } else {
2686  generator->Outdent();
2687  generator->PrintLiteral("}\n");
2688  }
2689  } else {
2690  // This field is not parseable as a Message (or we ran out of
2691  // recursion budget). So it is probably just a plain string.
2692  generator->PrintMaybeWithMarker(": ", "\"");
2693  generator->PrintString(CEscape(value));
2694  if (single_line_mode_) {
2695  generator->PrintLiteral("\" ");
2696  } else {
2697  generator->PrintLiteral("\"\n");
2698  }
2699  }
2700  break;
2701  }
2702  case UnknownField::TYPE_GROUP:
2703  generator->PrintString(field_number);
2704  if (single_line_mode_) {
2705  generator->PrintMaybeWithMarker(" ", "{ ");
2706  } else {
2707  generator->PrintMaybeWithMarker(" ", "{\n");
2708  generator->Indent();
2709  }
2710  // For groups, we recurse without checking the budget. This is OK,
2711  // because if the groups were too deeply nested then we would have
2712  // already rejected the message when we originally parsed it.
2713  PrintUnknownFields(field.group(), generator, recursion_budget - 1);
2714  if (single_line_mode_) {
2715  generator->PrintLiteral("} ");
2716  } else {
2717  generator->Outdent();
2718  generator->PrintLiteral("}\n");
2719  }
2720  break;
2721  }
2722  }
2723 }
2724 
2725 } // namespace protobuf
2726 } // namespace google
2727 
2728 #include <google/protobuf/port_undef.inc>
google::protobuf::Descriptor::full_name
const std::string & full_name() const
xds_interop_client.str
str
Definition: xds_interop_client.py:487
google::protobuf::TextFormat::FieldValuePrinter::PrintInt64
virtual std::string PrintInt64(int64_t val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1552
google::protobuf::TextFormat::ParseInfoTree::RecordLocation
void RecordLocation(const FieldDescriptor *field, ParseLocation location)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:128
google::protobuf::Reflection::GetString
std::string GetString(const Message &message, const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1151
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
google::protobuf::io::Printer::TextGenerator::TextGenerator
TextGenerator(io::ZeroCopyOutputStream *output, bool insert_silent_marker, int initial_indent_level)
Definition: protobuf/src/google/protobuf/text_format.cc:1334
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeTypeUrlOrFullTypeName
bool ConsumeTypeUrlOrFullTypeName()
Definition: protobuf/src/google/protobuf/text_format.cc:1021
google::protobuf::TextFormat::Parser::Parse
bool Parse(io::ZeroCopyInputStream *input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1403
google::protobuf::io::Printer::TextGenerator::Write
void Write(const char *data, size_t size)
Definition: protobuf/src/google/protobuf/text_format.cc:1423
google::protobuf::RepeatedPtrField
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h:62
google::protobuf::TextFormat::FastFieldValuePrinter::PrintDouble
virtual void PrintDouble(double val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1625
google::protobuf::io::Printer::TextGenerator::Outdent
void Outdent() override
Definition: protobuf/src/google/protobuf/text_format.cc:1360
google::protobuf::TextFormat::Printer::FastFieldValuePrinterUtf8Escaping::PrintString
void PrintString(const std::string &val, TextFormat::BaseTextGenerator *generator) const override
Definition: protobuf/src/google/protobuf/text_format.cc:1529
google::protobuf::TextFormat::FastFieldValuePrinter::PrintFieldName
virtual void PrintFieldName(const Message &message, int field_index, int field_count, const Reflection *reflection, const FieldDescriptor *field, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1644
regen-readme.it
it
Definition: regen-readme.py:15
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::TextFormat::Parser::ParserImpl::TryConsumeBeforeWhitespace
bool TryConsumeBeforeWhitespace(const std::string &value)
Definition: protobuf/src/google/protobuf/text_format.cc:1259
google::protobuf::FieldDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:515
google::protobuf::TextFormat::Printer::insert_silent_marker_
bool insert_silent_marker_
Definition: protobuf/src/google/protobuf/text_format.h:437
absl::str_format_internal::LengthMod::j
@ j
pos
int pos
Definition: libuv/docs/code/tty-gravity/main.c:11
google::protobuf::TextFormat::Print
static bool Print(const Message &message, io::ZeroCopyOutputStream *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:2385
google::protobuf::Reflection::SetBool
void SetBool(Message *message, const FieldDescriptor *field, bool value) const
OUTPUT_FIELD
#define OUTPUT_FIELD(CPPTYPE, METHOD)
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
testing::internal::Int32
TypeWithSize< 4 >::Int Int32
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2159
memset
return memset(p, 0, total)
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:562
google::protobuf::io::Tokenizer::TokenType
TokenType
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:101
google::protobuf::io::CodedInputStream::SetRecursionLimit
void SetRecursionLimit(int limit)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1493
google::protobuf::TextFormat::Printer::kDoNotParse
static const char *const kDoNotParse
Definition: protobuf/src/google/protobuf/text_format.h:385
Bool
Definition: bloaty/third_party/googletest/googletest/test/gtest_pred_impl_unittest.cc:56
google::protobuf::safe_strto32
bool safe_strto32(const string &str, int32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1366
tests.google.protobuf.internal.message_test.isnan
def isnan(val)
Definition: bloaty/third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py:65
grpc::protobuf::io::ZeroCopyInputStream
GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:101
google::protobuf::TextFormat::Printer::DebugStringFieldValuePrinter
Definition: protobuf/src/google/protobuf/text_format.cc:1507
false
#define false
Definition: setup_once.h:323
google::protobuf::StringPiece::data
const char * data() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:247
google::protobuf::TextFormat::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat)
google::protobuf::io::Tokenizer::ParseInteger
static bool ParseInteger(const std::string &text, uint64 max_value, uint64 *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.cc:863
capstone.range
range
Definition: third_party/bloaty/third_party/capstone/bindings/python/capstone/__init__.py:6
google::protobuf::Reflection::GetRepeatedPtrFieldInternal
const RepeatedPtrField< T > & GetRepeatedPtrFieldInternal(const Message &message, const FieldDescriptor *field) const
google::protobuf::kUnknownFieldRecursionLimit
static constexpr int kUnknownFieldRecursionLimit
Definition: protobuf/src/google/protobuf/text_format.cc:2082
google::protobuf::Reflection::GetUInt32
uint32 GetUInt32(const Message &message, const FieldDescriptor *field) const
google::protobuf.internal::ParseAnyTypeUrl
bool ParseAnyTypeUrl(const std::string &type_url, std::string *full_type_name)
Definition: bloaty/third_party/protobuf/src/google/protobuf/any_lite.cc:116
google::protobuf::io::Tokenizer
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:93
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
google::protobuf::TextFormat::Parser::ParserImpl::TryConsumeWhitespace
bool TryConsumeWhitespace(const std::string &message_type, const char *field_type)
Definition: protobuf/src/google/protobuf/text_format.cc:1267
phone_pb2.message_type
message_type
Definition: phone_pb2.py:200
google::protobuf::TextFormat::Printer::single_line_mode_
bool single_line_mode_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:404
google::protobuf::TextFormat::BaseTextGenerator::PrintLiteral
void PrintLiteral(const char(&text)[n])
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:115
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeField
bool ConsumeField(Message *message)
Definition: protobuf/src/google/protobuf/text_format.cc:412
testing::gtest_printers_test::Print
std::string Print(const T &value)
Definition: bloaty/third_party/googletest/googletest/test/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: bloaty/third_party/protobuf/python/google/protobuf/text_format.py:236
google::protobuf::io::Tokenizer::TYPE_IDENTIFIER
@ TYPE_IDENTIFIER
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:105
google::protobuf::TextFormat::Printer::PrintToString
bool PrintToString(const Message &message, std::string *output) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1860
absl::cord_internal::Consume
void Consume(CordRep *rep, ConsumeFn consume_fn)
Definition: cord_rep_consume.cc:45
google::protobuf::io::SafeDoubleToFloat
float SafeDoubleToFloat(double value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/strtod.cc:116
printf
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
Definition: cs_driver.c:91
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeIdentifier
bool ConsumeIdentifier(std::string *identifier)
Definition: protobuf/src/google/protobuf/text_format.cc:979
google::protobuf::TextFormat::FastFieldValuePrinter::PrintUInt64
virtual void PrintUInt64(uint64 val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1617
google::protobuf::TextFormat::ParseInfoTree::locations_
LocationMap locations_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:506
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf.internal::kAnyFullTypeName
const char kAnyFullTypeName[]
Definition: bloaty/third_party/protobuf/src/google/protobuf/any_lite.cc:52
google::protobuf::TextFormat::Printer::initial_indent_level_
int initial_indent_level_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:403
google::protobuf::UnknownField
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.h:216
google::protobuf::CEscape
string CEscape(const string &src)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:615
grpc::protobuf::io::Printer
GRPC_CUSTOM_PRINTER Printer
Definition: src/compiler/config.h:54
testing::internal::UInt64
TypeWithSize< 8 >::UInt UInt64
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2162
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::Reflection::GetMessageFactory
MessageFactory * GetMessageFactory() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:2186
grpc::protobuf::DynamicMessageFactory
GRPC_CUSTOM_DYNAMICMESSAGEFACTORY DynamicMessageFactory
Definition: config_grpc_cli.h:54
EnumValueDescriptor::name
const char * name
Definition: protobuf/php/ext/google/protobuf/def.c:65
google::protobuf::TextFormat::Parser::ParserImpl::ReportWarning
void ReportWarning(int line, int col, const std::string &message)
Definition: protobuf/src/google/protobuf/text_format.cc:347
google::protobuf::MessageFactory::GetPrototype
virtual const Message * GetPrototype(const Descriptor *type)=0
google::protobuf::TextFormat::FieldValuePrinter::FieldValuePrinter
FieldValuePrinter()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1528
google::protobuf::Reflection::SupportsUnknownEnumValues
bool SupportsUnknownEnumValues() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1824
google::protobuf::OneofDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:843
google::protobuf::TextFormat::Parser::ParserImpl::~ParserImpl
~ParserImpl()
Definition: protobuf/src/google/protobuf/text_format.cc:295
setup.name
name
Definition: setup.py:542
grpc::protobuf::io::ZeroCopyOutputStream
GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:100
google::protobuf::TextFormat::FastFieldValuePrinter::PrintMessageStart
virtual void PrintMessageStart(const Message &message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1664
google::protobuf::strings::Hex
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:594
google::protobuf::strings::ZERO_PAD_8
@ ZERO_PAD_8
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:583
google::protobuf::TextFormat::Parser::ParserImpl::ReportError
void ReportError(const std::string &message)
Definition: protobuf/src/google/protobuf/text_format.cc:373
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
google::protobuf::TextFormat::CreateNested
static ParseInfoTree * CreateNested(ParseInfoTree *info_tree, const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:621
google::protobuf::TextFormat::FieldValuePrinter::PrintMessageStart
virtual std::string PrintMessageStart(const Message &message, int field_index, int field_count, bool single_line_mode) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1581
google::protobuf::Reflection::SetInt64
void SetInt64(Message *message, const FieldDescriptor *field, int64 value) const
google::protobuf::io::Printer::TextGenerator::failed
bool failed() const
Definition: protobuf/src/google/protobuf/text_format.cc:1402
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeFieldValue
bool ConsumeFieldValue(Message *message, const Reflection *reflection, const FieldDescriptor *field)
Definition: protobuf/src/google/protobuf/text_format.cc:745
absl::CEscape
std::string CEscape(absl::string_view src)
Definition: abseil-cpp/absl/strings/escaping.cc:854
google::protobuf::TextFormat::ParseLocation
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:458
google::protobuf::io::Tokenizer::SH_COMMENT_STYLE
@ SH_COMMENT_STYLE
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:236
second
StrT second
Definition: cxa_demangle.cpp:4885
google::protobuf::TextFormat::Parser::ParserImpl::SkipFieldValue
bool SkipFieldValue()
Definition: protobuf/src/google/protobuf/text_format.cc:885
testing::internal::UInt32
TypeWithSize< 4 >::UInt UInt32
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2160
google::protobuf::kint64min
static const int64 kint64min
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:162
google::protobuf::FieldDescriptor::TYPE_GROUP
@ TYPE_GROUP
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:535
google::protobuf::Reflection
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:397
google::protobuf::io::Printer::TextGenerator::insert_silent_marker_
bool insert_silent_marker_
Definition: protobuf/src/google/protobuf/text_format.cc:1498
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf::OneofDescriptor::name
const std::string & name() const
google::protobuf::TextFormat::Parser::Parser
Parser()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1371
google::protobuf::TextFormat::FieldValuePrinter::PrintUInt64
virtual std::string PrintUInt64(uint64_t val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1555
google::protobuf::Reflection::HasField
bool HasField(const Message &message, const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:728
EnumValue
Definition: bloaty/third_party/protobuf/src/google/protobuf/type.pb.h:1105
google::protobuf::strings::ZERO_PAD_16
@ ZERO_PAD_16
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:591
google::protobuf::TextFormat::FieldValuePrinter::PrintBytes
virtual std::string PrintBytes(const std::string &val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1568
google::protobuf::Reflection::GetBool
bool GetBool(const Message &message, const FieldDescriptor *field) const
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeAnyValue
bool ConsumeAnyValue(const Descriptor *value_descriptor, std::string *serialized_value)
Definition: protobuf/src/google/protobuf/text_format.cc:1193
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:2512
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeSignedInteger
bool ConsumeSignedInteger(int64_t *value, uint64_t max_value)
Definition: protobuf/src/google/protobuf/text_format.cc:1071
google::protobuf::MessageFactory
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:1066
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
BOOL
int BOOL
Definition: undname.c:46
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1482
google::protobuf::CheckFieldIndex
void CheckFieldIndex(const FieldDescriptor *field, int index)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:141
Enum
Definition: bloaty/third_party/protobuf/src/google/protobuf/type.pb.h:867
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
google::protobuf::io::Printer::TextGenerator::ConsumeInsertSilentMarker
bool ConsumeInsertSilentMarker()
Definition: protobuf/src/google/protobuf/text_format.cc:1483
true
#define true
Definition: setup_once.h:324
google::protobuf::TextFormat::Parser::ParserImpl::ReportWarning
void ReportWarning(const std::string &message)
Definition: protobuf/src/google/protobuf/text_format.cc:380
google::protobuf::Reflection::GetOneofFieldDescriptor
const FieldDescriptor * GetOneofFieldDescriptor(const Message &message, const OneofDescriptor *oneof_descriptor) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1753
google::protobuf::TextFormat::FastFieldValuePrinter::PrintInt64
virtual void PrintInt64(int64 val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1613
google::protobuf::TextFormat::Printer::truncate_string_field_longer_than_
int64 truncate_string_field_longer_than_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:410
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeIdentifierBeforeWhitespace
bool ConsumeIdentifierBeforeWhitespace(std::string *identifier)
Definition: protobuf/src/google/protobuf/text_format.cc:1002
google::protobuf::TextFormat::Parser::ParserImpl::Consume
bool Consume(const std::string &value)
Definition: protobuf/src/google/protobuf/text_format.cc:1222
google::protobuf::RepeatedPtrField::Mutable
Element * Mutable(int index)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:2020
google::protobuf::TextFormat::FieldValuePrinter::PrintMessageEnd
virtual std::string PrintMessageEnd(const Message &message, int field_index, int field_count, bool single_line_mode) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1587
google::protobuf::Message::ShortDebugString
std::string ShortDebugString() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:95
google::protobuf::UnknownFieldSet::field_count
int field_count() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.h:308
absl::synchronization_internal::Get
static GraphId Get(const IdMap &id, int num)
Definition: abseil-cpp/absl/synchronization/internal/graphcycles_test.cc:44
google::protobuf::Message::Utf8DebugString
std::string Utf8DebugString() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:111
google::protobuf::Reflection::SetUInt64
void SetUInt64(Message *message, const FieldDescriptor *field, uint64 value) const
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf::TextFormat::FastFieldValuePrinter::PrintMessageEnd
virtual void PrintMessageEnd(const Message &message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1673
grpc::protobuf::io::StringOutputStream
GRPC_CUSTOM_STRINGOUTPUTSTREAM StringOutputStream
Definition: src/compiler/config.h:56
google::protobuf::TextFormat::Parser::ParserImpl::LookingAt
bool LookingAt(const std::string &text)
Definition: protobuf/src/google/protobuf/text_format.cc:968
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::TextFormat::Parser::ParseFromString
bool ParseFromString(const std::string &input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1420
setup.url
url
Definition: setup.py:547
buffer_
static uint8 buffer_[kBufferSize]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:136
google::protobuf::Descriptor::field
const FieldDescriptor * field(int index) const
google::protobuf::TextFormat::Printer::finder_
const Finder * finder_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:422
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
SET_FIELD
#define SET_FIELD(CPPTYPE, VALUE)
google::protobuf::io::Printer::TextGenerator::TextGenerator
TextGenerator(io::ZeroCopyOutputStream *output, int initial_indent_level)
Definition: protobuf/src/google/protobuf/text_format.cc:1323
google::protobuf::TextFormat::Parser::ParserImpl::ReportError
void ReportError(int line, int col, const std::string &message)
Definition: protobuf/src/google/protobuf/text_format.cc:331
google::protobuf::TextFormat::ParseInfoTree::GetTreeForNested
ParseInfoTree * GetTreeForNested(const FieldDescriptor *field, int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:171
asyncio_get_stats.parser
parser
Definition: asyncio_get_stats.py:34
gen_server_registered_method_bad_client_test_body.text
def text
Definition: gen_server_registered_method_bad_client_test_body.py:50
google::protobuf::ConstStringParam
const std::string & ConstStringParam
Definition: third_party/protobuf/src/google/protobuf/stubs/port.h:129
google::protobuf::TextFormat::Finder::FindExtension
virtual const FieldDescriptor * FindExtension(Message *message, const std::string &name) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1348
xds_interop_client.int
int
Definition: xds_interop_client.py:113
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeFullTypeName
bool ConsumeFullTypeName(std::string *name)
Definition: protobuf/src/google/protobuf/text_format.cc:1010
google::protobuf::TextFormat::Parser::ParserImpl::ParserErrorCollector::~ParserErrorCollector
~ParserErrorCollector() override
Definition: protobuf/src/google/protobuf/text_format.cc:1284
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
google::protobuf::TextFormat::ParseInfoTree
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:469
google::protobuf::TextFormat::Parser::MergeUsingImpl
bool MergeUsingImpl(io::ZeroCopyInputStream *input, Message *output, ParserImpl *parser_impl)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1447
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
google::protobuf::TextFormat::RecordLocation
static void RecordLocation(ParseInfoTree *info_tree, const FieldDescriptor *field, ParseLocation location)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:615
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
google::protobuf::TextFormat::FastFieldValuePrinter::PrintBool
virtual void PrintBool(bool val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1597
google::protobuf::TextFormat::Finder::FindExtensionByNumber
virtual const FieldDescriptor * FindExtensionByNumber(const Descriptor *descriptor, int number) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1353
google::protobuf.internal::kTypeGoogleApisComPrefix
const char kTypeGoogleApisComPrefix[]
Definition: bloaty/third_party/protobuf/src/google/protobuf/any_lite.cc:53
google::protobuf::TextFormat::BaseTextGenerator
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:100
google::protobuf::Message::DebugString
std::string DebugString() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:84
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeBeforeWhitespace
bool ConsumeBeforeWhitespace(const std::string &value)
Definition: protobuf/src/google/protobuf/text_format.cc:1238
google::protobuf::Reflection::HasOneof
bool HasOneof(const Message &message, const OneofDescriptor *oneof_descriptor) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:2022
testing::internal::Float
FloatingPoint< float > Float
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:396
google::protobuf::StringPiece
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:180
google::protobuf::io::Printer::TextGenerator
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1202
google::protobuf::TextFormat::ParseFromString
static bool ParseFromString(const std::string &input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1485
google::protobuf::TextFormat::Printer::use_field_number_
bool use_field_number_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:405
google::protobuf::SimpleFtoa
string SimpleFtoa(float value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1226
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf::TextFormat::Printer
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:236
google::protobuf::TextFormat::FastFieldValuePrinter::PrintBytes
virtual void PrintBytes(const std::string &val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1640
google::protobuf::TextFormat::Printer::DebugStringFieldValuePrinter::PrintMessageStart
void PrintMessageStart(const Message &, int, int, bool single_line_mode, BaseTextGenerator *generator) const override
Definition: protobuf/src/google/protobuf/text_format.cc:1510
google::protobuf::TextFormat::Parser::ParserImpl::initial_recursion_limit_
const int initial_recursion_limit_
Definition: protobuf/src/google/protobuf/text_format.cc:1312
google::protobuf::io::Tokenizer::ParseFloat
static double ParseFloat(const std::string &text)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.cc:902
google::protobuf.internal::GetAnyFieldDescriptors
bool GetAnyFieldDescriptors(const Message &message, const FieldDescriptor **type_url_field, const FieldDescriptor **value_field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/any.cc:64
google::protobuf::Reflection::SetInt32
void SetInt32(Message *message, const FieldDescriptor *field, int32 value) const
google::protobuf::TextFormat::Printer::SetExpandAny
void SetExpandAny(bool expand)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:321
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
google::protobuf::TextFormat::ParseLocationRange
Definition: protobuf/src/google/protobuf/text_format.h:500
google::protobuf::io::Tokenizer::TYPE_INTEGER
@ TYPE_INTEGER
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:109
google::protobuf::TextFormat::FastFieldValuePrinter::PrintString
virtual void PrintString(const std::string &val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1634
google::protobuf::io::Printer::TextGenerator::Print
void Print(const char *text, size_t size) override
Definition: protobuf/src/google/protobuf/text_format.cc:1374
EnumValueDescriptor
Definition: protobuf/php/ext/google/protobuf/def.c:63
negative
static uint8_t negative(signed char b)
Definition: curve25519.c:786
google::protobuf::TextFormat::Parser::MergeFromString
bool MergeFromString(const std::string &input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1439
google::protobuf::TextFormat::Parser::~Parser
~Parser()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1385
google::protobuf::Reflection::MapBegin
MapIterator MapBegin(Message *message, const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1788
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeUnsignedDecimalAsDouble
bool ConsumeUnsignedDecimalAsDouble(double *value, uint64_t max_value)
Definition: protobuf/src/google/protobuf/text_format.cc:1100
google::protobuf::TextFormat::Printer::SetInsertSilentMarker
void SetInsertSilentMarker(bool v)
Definition: protobuf/src/google/protobuf/text_format.h:373
PrintString
static void PrintString(int max_cols, absl::string_view *str, protobuf::io::Printer *printer)
Definition: upbc.cc:72
google::protobuf::TextFormat::FastFieldValuePrinter::PrintInt32
virtual void PrintInt32(int32 val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1605
google::protobuf::TextFormat::Printer::FastFieldValuePrinterUtf8Escaping::PrintBytes
void PrintBytes(const std::string &val, TextFormat::BaseTextGenerator *generator) const override
Definition: protobuf/src/google/protobuf/text_format.cc:1535
gen_build_yaml.load
def load(*args)
Definition: test/core/end2end/gen_build_yaml.py:25
google::protobuf::TextFormat::Finder::FindExtensionFactory
virtual MessageFactory * FindExtensionFactory(const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1364
google::protobuf::io::Printer::TextGenerator::PrintMaybeWithMarker
void PrintMaybeWithMarker(StringPiece text)
Definition: protobuf/src/google/protobuf/text_format.cc:1404
google::protobuf::Reflection::SetString
void SetString(Message *message, const FieldDescriptor *field, std::string value) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1193
google::protobuf::WARNING
static const LogLevel WARNING
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:71
gen_synthetic_protos.base
base
Definition: gen_synthetic_protos.py:31
google::protobuf::io::Printer::TextGenerator::GetCurrentIndentationSize
size_t GetCurrentIndentationSize() const override
Definition: protobuf/src/google/protobuf/text_format.cc:1369
google::protobuf::TextFormat::Parser::ParserImpl::TryConsume
bool TryConsume(const std::string &value)
Definition: protobuf/src/google/protobuf/text_format.cc:1248
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
google::protobuf::TextFormat::ParseInfoTree::CreateNested
ParseInfoTree * CreateNested(const FieldDescriptor *field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:133
wrapper
grpc_channel_wrapper * wrapper
Definition: src/php/ext/grpc/channel.h:48
google::protobuf::TextFormat::FieldValuePrinter::PrintInt32
virtual std::string PrintInt32(int32_t val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1546
google::protobuf::FieldDescriptor::CPPTYPE_UINT64
@ CPPTYPE_UINT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:557
min
#define min(a, b)
Definition: qsort.h:83
google::protobuf::io::Tokenizer::ParseStringAppend
static void ParseStringAppend(const std::string &text, std::string *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.cc:1035
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeDouble
bool ConsumeDouble(double *value)
Definition: protobuf/src/google/protobuf/text_format.cc:1129
google::protobuf::TextFormat::Finder
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:203
google::protobuf::ERROR
static const LogLevel ERROR
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:70
google::protobuf::TextFormat::Parser::ParserImpl::ParserErrorCollector
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1162
google::protobuf::io::Tokenizer::TYPE_FLOAT
@ TYPE_FLOAT
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:115
google::protobuf::Reflection::GetInt32
int32 GetInt32(const Message &message, const FieldDescriptor *field) const
google::protobuf::LowerString
void LowerString(string *s)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:177
google::protobuf::UnknownFieldSet::ParseFromCodedStream
bool ParseFromCodedStream(io::CodedInputStream *input)
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.cc:225
google::protobuf::TextFormat::Finder::~Finder
virtual ~Finder()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1346
google::protobuf::Reflection::MutableMessage
Message * MutableMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1461
google::protobuf::TextFormat::Parser::ParserImpl::ParserErrorCollector::AddError
void AddError(int line, int column, const std::string &message) override
Definition: protobuf/src/google/protobuf/text_format.cc:1286
google::protobuf::TextFormat::Parser::ParserImpl::ParserErrorCollector::AddWarning
void AddWarning(int line, int column, const std::string &message) override
Definition: protobuf/src/google/protobuf/text_format.cc:1290
google::protobuf::TextFormat::FastFieldValuePrinter::PrintMessageContent
virtual bool PrintMessageContent(const Message &message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator *generator) const
Definition: protobuf/src/google/protobuf/text_format.cc:1871
google::protobuf::TextFormat::Printer::expand_any_
bool expand_any_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:409
google::protobuf::strings::Utf8SafeCEscape
string Utf8SafeCEscape(const string &src)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:623
google::protobuf::TextFormat::FastFieldValuePrinter
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:124
value
const char * value
Definition: hpack_parser_table.cc:165
google::protobuf::io::ZeroCopyInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h:126
google::protobuf::io::Printer::TextGenerator::~TextGenerator
~TextGenerator()
Definition: protobuf/src/google/protobuf/text_format.cc:1345
google::protobuf::RepeatedPtrField::size
int size() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1999
google::protobuf::kuint32max
static const uint32 kuint32max
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:163
google::protobuf::TextFormat::Parser::ParserImpl::SingularOverwritePolicy
SingularOverwritePolicy
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:234
google::protobuf::io::Printer::TextGenerator::Indent
void Indent() override
Definition: protobuf/src/google/protobuf/text_format.cc:1356
google::protobuf::FieldDescriptor::CPPTYPE_INT64
@ CPPTYPE_INT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:555
google::protobuf::TextFormat::Parser::ParseFieldValueFromString
bool ParseFieldValueFromString(const std::string &input, const FieldDescriptor *field, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1462
google::protobuf::DynamicMessageFactory
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:80
google::protobuf::MapEntryMessageComparator
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:2024
FATAL
#define FATAL(msg)
Definition: task.h:88
FORWARD_IMPL
#define FORWARD_IMPL(fn,...)
Definition: protobuf/src/google/protobuf/text_format.cc:1734
google::protobuf::io::Tokenizer::TYPE_WHITESPACE
@ TYPE_WHITESPACE
Definition: protobuf/src/google/protobuf/io/tokenizer.h:125
google::protobuf::SimpleDtoa
string SimpleDtoa(double value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1221
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeFieldMessage
bool ConsumeFieldMessage(Message *message, const Reflection *reflection, const FieldDescriptor *field)
Definition: protobuf/src/google/protobuf/text_format.cc:688
google::protobuf::TextFormat::Printer::use_short_repeated_primitives_
bool use_short_repeated_primitives_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:406
google::protobuf.internal::enable_debug_text_format_marker
PROTOBUF_EXPORT std::atomic< bool > enable_debug_text_format_marker
Definition: protobuf/src/google/protobuf/text_format.cc:90
google::protobuf.internal::kTypeGoogleProdComPrefix
const char kTypeGoogleProdComPrefix[]
Definition: bloaty/third_party/protobuf/src/google/protobuf/any_lite.cc:54
google::protobuf::UnknownFieldSet::field
const UnknownField & field(int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.h:311
google::protobuf::Message
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:205
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
google::protobuf::io::Printer::TextGenerator::PrintMaybeWithMarker
void PrintMaybeWithMarker(StringPiece text_head, StringPiece text_tail)
Definition: protobuf/src/google/protobuf/text_format.cc:1411
key
const char * key
Definition: hpack_parser_table.cc:164
testing::internal::posix::Write
int Write(int fd, const void *buf, unsigned int count)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2047
scratch
static char scratch[256]
Definition: test-random.c:27
google::protobuf::FieldDescriptor::CPPTYPE_UINT32
@ CPPTYPE_UINT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:556
google::protobuf::FieldDescriptor::CPPTYPE_FLOAT
@ CPPTYPE_FLOAT
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:559
google::protobuf::MapEntryMessageComparator::MapEntryMessageComparator
MapEntryMessageComparator(const Descriptor *descriptor)
Definition: protobuf/src/google/protobuf/text_format.cc:2226
google::protobuf::kint32max
static const int32 kint32max
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:159
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeUnsignedInteger
bool ConsumeUnsignedInteger(uint64_t *value, uint64_t max_value)
Definition: protobuf/src/google/protobuf/text_format.cc:1050
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeMessageDelimiter
bool ConsumeMessageDelimiter(std::string *delimiter)
Definition: protobuf/src/google/protobuf/text_format.cc:399
google::protobuf::FieldDescriptor::name
const std::string & name() const
google::protobuf.internal.decoder.SkipField
def SkipField
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/decoder.py:1036
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeAnyTypeUrl
bool ConsumeAnyTypeUrl(std::string *full_type_name, std::string *prefix)
Definition: protobuf/src/google/protobuf/text_format.cc:1175
google::protobuf::TextFormat::BaseTextGenerator::PrintString
void PrintString(const std::string &str)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:112
google::protobuf::TextFormat::Finder::FindAnyType
virtual const Descriptor * FindAnyType(const Message &message, const std::string &prefix, const std::string &name) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1358
google::protobuf::TextFormat::FieldValuePrinter::PrintFieldName
virtual std::string PrintFieldName(const Message &message, const Reflection *reflection, const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1576
google::protobuf::FieldDescriptor::CPPTYPE_BOOL
@ CPPTYPE_BOOL
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:560
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
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: bloaty/third_party/protobuf/python/google/protobuf/text_format.py:258
google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE
@ CPPTYPE_DOUBLE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:558
google::protobuf::MapEntryMessageComparator::operator()
bool operator()(const Message *a, const Message *b)
Definition: protobuf/src/google/protobuf/text_format.cc:2229
google::protobuf::MapKey
Definition: bloaty/third_party/protobuf/src/google/protobuf/map_field.h:371
google::protobuf::io::ErrorCollector
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:66
google::protobuf::TextFormat::Parser::Merge
bool Merge(io::ZeroCopyInputStream *input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1428
google::protobuf::Message::PrintDebugString
void PrintDebugString() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:123
profile_analyzer.fields
list fields
Definition: profile_analyzer.py:266
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
DEBUG_STRING_SILENT_MARKER
#define DEBUG_STRING_SILENT_MARKER
Definition: protobuf/src/google/protobuf/text_format.cc:69
first
StrT first
Definition: cxa_demangle.cpp:4884
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeMessage
bool ConsumeMessage(Message *message, const std::string delimiter)
Definition: protobuf/src/google/protobuf/text_format.cc:388
google::protobuf::TextFormat::Parser::ParserImpl::ParserErrorCollector::ParserErrorCollector
ParserErrorCollector(TextFormat::Parser::ParserImpl *parser)
Definition: protobuf/src/google/protobuf/text_format.cc:1281
google::protobuf::FieldDescriptor::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:561
google::protobuf::UnknownFieldSet
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.h:81
testing::internal::Double
FloatingPoint< double > Double
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:397
google::protobuf::io::ZeroCopyOutputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h:183
google::protobuf::io::CodedInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:180
field_type
zend_class_entry * field_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/message.c:2030
google::protobuf::TextFormat::Printer::Print
bool Print(const Message &message, io::ZeroCopyOutputStream *output) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1879
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
google::protobuf::MessageLite::ParseFromString
bool ParseFromString(const std::string &data)
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.cc:284
google::protobuf::TextFormat::Parse
static bool Parse(io::ZeroCopyInputStream *input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1475
regen-readme.line
line
Definition: regen-readme.py:30
google::protobuf::TextFormat::FieldValuePrinter::~FieldValuePrinter
virtual ~FieldValuePrinter()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1529
type_url
string * type_url
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:72
google::protobuf::EnumValueDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1075
google::protobuf::TextFormat::Printer::FastFieldValuePrinterUtf8Escaping
Definition: protobuf/src/google/protobuf/text_format.cc:1526
google::protobuf::TextFormat::FieldValuePrinter::PrintString
virtual std::string PrintString(const std::string &val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1564
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:153
google::protobuf::Descriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:231
google::protobuf::TextFormat::Parser::ParserImpl::SkipField
bool SkipField()
Definition: protobuf/src/google/protobuf/text_format.cc:655
google::protobuf::TextFormat::FieldValuePrinter::PrintUInt32
virtual std::string PrintUInt32(uint32_t val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1549
google::protobuf::TextFormat::Parser::ParserImpl::ConsumeString
bool ConsumeString(std::string *text)
Definition: protobuf/src/google/protobuf/text_format.cc:1032
google::protobuf::TextFormat::FastFieldValuePrinter::PrintUInt32
virtual void PrintUInt32(uint32 val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1609
GOOGLE_DCHECK_EQ
#define GOOGLE_DCHECK_EQ
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:196
google::protobuf::Reflection::GetInt64
int64 GetInt64(const Message &message, const FieldDescriptor *field) const
google::protobuf::Message::New
Message * New() const override=0
google::protobuf::TextFormat::BaseTextGenerator::~BaseTextGenerator
virtual ~BaseTextGenerator()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1500
google::protobuf::TextFormat::Parser::ParserImpl
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:228
google::protobuf::TextFormat::Parser::ParserImpl::LookingAtType
bool LookingAtType(io::Tokenizer::TokenType token_type)
Definition: protobuf/src/google/protobuf/text_format.cc:973
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
google::protobuf::TextFormat::Parser::ParserImpl::Parse
bool Parse(Message *output)
Definition: protobuf/src/google/protobuf/text_format.cc:301
google::protobuf::TextFormat::FastFieldValuePrinter::PrintFloat
virtual void PrintFloat(float val, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1621
google::protobuf::TextFormat::FastFieldValuePrinter::PrintEnum
virtual void PrintEnum(int32 val, const std::string &name, BaseTextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1629
google::protobuf::kint64max
static const int64 kint64max
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:161
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf.internal::MapFieldBase
Definition: bloaty/third_party/protobuf/src/google/protobuf/map_field.h:69
google::protobuf::TextFormat::Printer::PrintFieldName
void PrintFieldName(const Message &message, int field_index, int field_count, const Reflection *reflection, const FieldDescriptor *field, TextGenerator *generator) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:2284
google::protobuf::TextFormat::Parser::ParserImpl::ParseField
bool ParseField(const FieldDescriptor *field, Message *output)
Definition: protobuf/src/google/protobuf/text_format.cc:321
iter
Definition: test_winkernel.cpp:47
google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:563
testing::internal::Int64
TypeWithSize< 8 >::Int Int64
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2161
google::protobuf::TextFormat::FieldValuePrinter::PrintBool
virtual std::string PrintBool(bool val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1543
google::protobuf::TextFormat::FieldValuePrinter::PrintEnum
virtual std::string PrintEnum(int32_t val, const std::string &name) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1572
google::protobuf::Join
void Join(Iterator start, Iterator end, const char *delim, string *result)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:769
google::protobuf::io::Tokenizer::TYPE_END
@ TYPE_END
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:103
google::protobuf::kuint64max
static const uint64 kuint64max
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:164
google::protobuf::TextFormat::Merge
static bool Merge(io::ZeroCopyInputStream *input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1480
google::protobuf::Reflection::GetMapData
const internal::MapFieldBase * GetMapData(const Message &message, const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:2219
delegate_
std::unique_ptr< const TextFormat::FieldValuePrinter > delegate_
Definition: protobuf/src/google/protobuf/text_format.cc:1968
google::protobuf::TextFormat::Parser::ParserImpl::ParserImpl
ParserImpl(const Descriptor *root_message_type, io::ZeroCopyInputStream *input_stream, io::ErrorCollector *error_collector, const TextFormat::Finder *finder, ParseInfoTree *parse_info_tree, SingularOverwritePolicy singular_overwrite_policy, bool allow_case_insensitive_field, bool allow_unknown_field, bool allow_unknown_extension, bool allow_unknown_enum, bool allow_field_number, bool allow_relaxed_whitespace, bool allow_partial, int recursion_limit)
Definition: protobuf/src/google/protobuf/text_format.cc:255
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
absl::ReportError
static std::string ReportError(CordRep *root, CordRep *node)
Definition: abseil-cpp/absl/strings/cord.cc:1258
google::protobuf::TextFormat::ParseInfoTree::GetLocationRange
ParseLocationRange GetLocationRange(const FieldDescriptor *field, int index) const
Definition: protobuf/src/google/protobuf/text_format.cc:170
google::protobuf::Reflection::AddMessage
Message * AddMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1637
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf::TextFormat::FastFieldValuePrinter::FastFieldValuePrinter
FastFieldValuePrinter()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1595
google::protobuf::MapIterator
Definition: bloaty/third_party/protobuf/src/google/protobuf/map_field.h:712
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
google::protobuf::EnumDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:918
google::protobuf::io::Printer::TextGenerator::WriteIndent
void WriteIndent()
Definition: protobuf/src/google/protobuf/text_format.cc:1454
google::protobuf::StringPiece::size
stringpiece_ssize_type size() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:248
parser_
std::unique_ptr< Parser > parser_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:185
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
google::protobuf::TextFormat::FastFieldValuePrinter::~FastFieldValuePrinter
virtual ~FastFieldValuePrinter()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1596
phone_pb2.enum_type
enum_type
Definition: phone_pb2.py:198
google::protobuf::TextFormat::FieldValuePrinter::PrintDouble
virtual std::string PrintDouble(double val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1561
google::protobuf::TextFormat::MergeFromString
static bool MergeFromString(const std::string &input, Message *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1490
google::protobuf::TextFormat::Parser::ParserImpl::SkipFieldMessage
bool SkipFieldMessage()
Definition: protobuf/src/google/protobuf/text_format.cc:725
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
google::protobuf::FieldDescriptor::is_repeated
bool is_repeated() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2067
pair
std::pair< std::string, std::string > pair
Definition: abseil-cpp/absl/container/internal/raw_hash_set_benchmark.cc:78
error_collector_
MockErrorCollector error_collector_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/importer_unittest.cc:129
google::protobuf::FindOrNull
const Collection::value_type::second_type * FindOrNull(const Collection &collection, const typename Collection::value_type::first_type &key)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/map_util.h:137
google::protobuf::FieldDescriptor::cpp_type
CppType cpp_type() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2139
google::protobuf::io::Tokenizer::TYPE_STRING
@ TYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer.h:118
DO
#define DO(STATEMENT)
Definition: protobuf/src/google/protobuf/text_format.cc:238
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf::TextFormat::Printer::hide_unknown_fields_
bool hide_unknown_fields_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:407
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
google::protobuf::DynamicMessageFactory::GetPrototype
const Message * GetPrototype(const Descriptor *type) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:653
google::protobuf::Reflection::GetUInt64
uint64 GetUInt64(const Message &message, const FieldDescriptor *field) const
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
output_
std::string output_
Definition: protobuf/src/google/protobuf/text_format.cc:1717
google::protobuf::TextFormat::Printer::Printer
Printer()
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1786
LL
#define LL(x)
google::protobuf::TextFormat::FieldValuePrinter::PrintFloat
virtual std::string PrintFloat(float val) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.cc:1558
google::protobuf::TextFormat::Printer::print_message_fields_in_index_order_
bool print_message_fields_in_index_order_
Definition: bloaty/third_party/protobuf/src/google/protobuf/text_format.h:408
google::protobuf::FieldDescriptor::CPPTYPE_INT32
@ CPPTYPE_INT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:554
testing::PrintToString
::std::string PrintToString(const T &value)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-printers.h:915
google::protobuf::Reflection::MapEnd
MapIterator MapEnd(Message *message, const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc:1796
google::protobuf::Reflection::SetUInt32
void SetUInt32(Message *message, const FieldDescriptor *field, uint32 value) const


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:34