cpp_helpers.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
36 #define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
37 
38 #include <algorithm>
39 #include <iterator>
40 #include <map>
41 #include <string>
42 
49 #include <google/protobuf/port.h>
51 
52 
53 #include <google/protobuf/port_def.inc>
54 
55 namespace google {
56 namespace protobuf {
57 namespace compiler {
58 namespace cpp {
59 
61  return "PROTOBUF_NAMESPACE_ID";
62 }
63 
65  return options.opensource_runtime ? "GOOGLE_PROTOBUF" : "GOOGLE_PROTOBUF";
66 }
67 
69  bool deprecated) {
70  return deprecated ? "PROTOBUF_DEPRECATED " : "";
71 }
72 
73 // Commonly-used separator comments. Thick is a line of '=', thin is a line
74 // of '-'.
75 extern const char kThickSeparator[];
76 extern const char kThinSeparator[];
77 
78 void SetCommonVars(const Options& options,
79  std::map<std::string, std::string>* variables);
80 
81 bool GetBootstrapBasename(const Options& options, const std::string& basename,
82  std::string* bootstrap_basename);
83 bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context,
84  bool bootstrap_flag, std::string* basename);
85 bool IsBootstrapProto(const Options& options, const FileDescriptor* file);
86 
87 // Name space of the proto file. This namespace is such that the string
88 // "<namespace>::some_name" is the correct fully qualified namespace.
89 // This means if the package is empty the namespace is "", and otherwise
90 // the namespace is "::foo::bar::...::baz" without trailing semi-colons.
91 std::string Namespace(const FileDescriptor* d, const Options& options);
92 std::string Namespace(const Descriptor* d, const Options& options);
93 std::string Namespace(const FieldDescriptor* d, const Options& options);
94 std::string Namespace(const EnumDescriptor* d, const Options& options);
95 
96 // Returns true if it's safe to reset "field" to zero.
98 
101 
102 std::string QualifiedClassName(const Descriptor* d, const Options& options);
103 std::string QualifiedClassName(const EnumDescriptor* d, const Options& options);
104 
107 
108 // DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
109 // unreadable at the callsite.
110 // Returns the non-nested type name for the given type. If "qualified" is
111 // true, prefix the type with the full namespace. For example, if you had:
112 // package foo.bar;
113 // message Baz { message Qux {} }
114 // Then the qualified ClassName for Qux would be:
115 // ::foo::bar::Baz_Qux
116 // While the non-qualified version would be:
117 // Baz_Qux
118 inline std::string ClassName(const Descriptor* descriptor, bool qualified) {
119  return qualified ? QualifiedClassName(descriptor, Options())
121 }
122 
123 inline std::string ClassName(const EnumDescriptor* descriptor, bool qualified) {
124  return qualified ? QualifiedClassName(descriptor, Options())
126 }
127 
128 // Type name of default instance.
130  const Options& options);
131 
132 // Non-qualified name of the default_instance of this message.
134  const Options& options);
135 
136 // Fully qualified name of the default_instance of this message.
138  const Options& options);
139 
140 // DescriptorTable variable name.
142  const Options& options);
143 
144 // When declaring symbol externs from another file, this macro will supply the
145 // dllexport needed for the target file, if any.
146 std::string FileDllExport(const FileDescriptor* file, const Options& options);
147 
148 // Returns the name of a no-op function that we can call to introduce a linker
149 // dependency on the given message type. This is used to implement implicit weak
150 // fields.
152  const Options& options);
153 
154 // Name of the base class: google::protobuf::Message or google::protobuf::MessageLite.
156  const Options& options);
157 
158 // Adds an underscore if necessary to prevent conflicting with a keyword.
159 std::string ResolveKeyword(const string& name);
160 
161 // Get the (unqualified) name that should be used for this field in C++ code.
162 // The name is coerced to lower-case to emulate proto1 behavior. People
163 // should be using lowercase-with-underscores style for proto field names
164 // anyway, so normally this just returns field->name().
166 
167 // Get the sanitized name that should be used for the given enum in C++ code.
169 
170 // Returns an estimate of the compiler's alignment for the field. This
171 // can't guarantee to be correct because the generated code could be compiled on
172 // different systems with different alignment rules. The estimates below assume
173 // 64-bit pointers.
175 
176 // Get the unqualified name that should be used for a field's field
177 // number constant.
179 
180 // Returns the scope where the field was defined (for extensions, this is
181 // different from the message type to which the field applies).
183  return field->is_extension() ? field->extension_scope()
184  : field->containing_type();
185 }
186 
187 // Returns the fully-qualified type name field->message_type(). Usually this
188 // is just ClassName(field->message_type(), true);
190  const Options& options);
191 
192 // Strips ".proto" or ".protodevel" from the end of a filename.
193 PROTOC_EXPORT std::string StripProto(const std::string& filename);
194 
195 // Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
197 std::string PrimitiveTypeName(const Options& options,
199 
200 // Get the declared type name in CamelCase format, as is used e.g. for the
201 // methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
203 
204 // Return the code that evaluates to the number when compiled.
206 
207 // Return the code that evaluates to the number when compiled.
208 std::string Int64ToString(const Options& options, int64 number);
209 
210 // Get code that evaluates to the field's default value.
211 std::string DefaultValue(const Options& options, const FieldDescriptor* field);
212 
213 // Compatibility function for callers outside proto2.
215 
216 // Convert a file name into a valid identifier.
218 
219 // For each .proto file generates a unique name. To prevent collisions of
220 // symbols in the global namespace
221 std::string UniqueName(const std::string& name, const std::string& filename,
222  const Options& options);
224  const Options& options) {
225  return UniqueName(name, d->name(), options);
226 }
228  const Options& options) {
229  return UniqueName(name, d->file(), options);
230 }
232  const Options& options) {
233  return UniqueName(name, d->file(), options);
234 }
236  const ServiceDescriptor* d,
237  const Options& options) {
238  return UniqueName(name, d->file(), options);
239 }
240 
241 // Versions for call sites that only support the internal runtime (like proto1
242 // support).
245  options.opensource_runtime = false;
246  return options;
247 }
249  const std::string& filename) {
250  return UniqueName(name, filename, InternalRuntimeOptions());
251 }
253  const FileDescriptor* d) {
254  return UniqueName(name, d->name(), InternalRuntimeOptions());
255 }
257  return UniqueName(name, d->file(), InternalRuntimeOptions());
258 }
260  const EnumDescriptor* d) {
261  return UniqueName(name, d->file(), InternalRuntimeOptions());
262 }
264  const ServiceDescriptor* d) {
265  return UniqueName(name, d->file(), InternalRuntimeOptions());
266 }
267 
268 // Return the qualified C++ name for a file level symbol.
270  const std::string& name,
271  const Options& options);
272 
273 // Escape C++ trigraphs by escaping question marks to \?
274 std::string EscapeTrigraphs(const std::string& to_escape);
275 
276 // Escaped function name to eliminate naming conflict.
278  const FieldDescriptor* field,
279  const std::string& prefix);
280 
281 // Returns true if generated messages have public unknown fields accessors
283  return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
284 }
285 
286 // Returns the optimize mode for <file>, respecting <options.enforce_lite>.
288  const Options& options);
289 
290 // Determines whether unknown fields will be stored in an UnknownFieldSet or
291 // a string.
292 inline bool UseUnknownFieldSet(const FileDescriptor* file,
293  const Options& options) {
295 }
296 
297 inline bool IsWeak(const FieldDescriptor* field, const Options& options) {
298  if (field->options().weak()) {
299  GOOGLE_CHECK(!options.opensource_runtime);
300  return true;
301  }
302  return false;
303 }
304 
305 bool IsStringInlined(const FieldDescriptor* descriptor, const Options& options);
306 
307 // For a string field, returns the effective ctype. If the actual ctype is
308 // not supported, returns the default of STRING.
310  const Options& options);
311 
312 inline bool IsCord(const FieldDescriptor* field, const Options& options) {
313  return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
315 }
316 
318  const Options& options) {
319  return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
321 }
322 
323 // Does the given FileDescriptor use lazy fields?
324 bool HasLazyFields(const FileDescriptor* file, const Options& options);
325 
326 // Is the given field a supported lazy field?
327 inline bool IsLazy(const FieldDescriptor* field, const Options& options) {
328  return field->options().lazy() && !field->is_repeated() &&
331  !options.opensource_runtime;
332 }
333 
334 // Does the file contain any definitions that need extension_set.h?
336 
337 // Does the file have any repeated fields, necessitating the file to include
338 // repeated_field.h? This does not include repeated extensions, since those are
339 // all stored internally in an ExtensionSet, not a separate RepeatedField*.
340 bool HasRepeatedFields(const FileDescriptor* file);
341 
342 // Does the file have any string/bytes fields with ctype=STRING_PIECE? This
343 // does not include extensions, since ctype is ignored for extensions.
344 bool HasStringPieceFields(const FileDescriptor* file, const Options& options);
345 
346 // Does the file have any string/bytes fields with ctype=CORD? This does not
347 // include extensions, since ctype is ignored for extensions.
348 bool HasCordFields(const FileDescriptor* file, const Options& options);
349 
350 // Does the file have any map fields, necessitating the file to include
351 // map_field_inl.h and map.h.
352 bool HasMapFields(const FileDescriptor* file);
353 
354 // Does this file have any enum type definitions?
355 bool HasEnumDefinitions(const FileDescriptor* file);
356 
357 // Does this file have generated parsing, serialization, and other
358 // standard methods for which reflection-based fallback implementations exist?
359 inline bool HasGeneratedMethods(const FileDescriptor* file,
360  const Options& options) {
362 }
363 
364 // Do message classes in this file have descriptor and reflection methods?
365 inline bool HasDescriptorMethods(const FileDescriptor* file,
366  const Options& options) {
368 }
369 
370 // Should we generate generic services for this file?
371 inline bool HasGenericServices(const FileDescriptor* file,
372  const Options& options) {
373  return file->service_count() > 0 &&
375  file->options().cc_generic_services();
376 }
377 
378 // Should we generate a separate, super-optimized code path for serializing to
379 // flat arrays? We don't do this in Lite mode because we'd rather reduce code
380 // size.
382  const Options& options) {
383  return GetOptimizeFor(file, options) == FileOptions::SPEED;
384 }
385 
387  const Options& options) {
388  return !options.opensource_runtime &&
389  options.enforce_mode != EnforceOptimizeMode::kLiteRuntime &&
390  !options.lite_implicit_weak_fields &&
391  descriptor->options().message_set_wire_format() &&
392  descriptor->full_name() == "google.protobuf.bridge.MessageSet";
393 }
394 
395 inline bool IsProto2MessageSetFile(const FileDescriptor* file,
396  const Options& options) {
397  return !options.opensource_runtime &&
398  options.enforce_mode != EnforceOptimizeMode::kLiteRuntime &&
399  !options.lite_implicit_weak_fields &&
400  file->name() == "net/proto2/bridge/proto/message_set.proto";
401 }
402 
404  return descriptor->options().map_entry();
405 }
406 
407 // Returns true if the field's CPPTYPE is string or message.
409 
411  bool cap_next_letter);
412 
413 inline bool HasFieldPresence(const FileDescriptor* file) {
414  return file->syntax() != FileDescriptor::SYNTAX_PROTO3;
415 }
416 
417 // Returns true if 'enum' semantics are such that unknown values are preserved
418 // in the enum field itself, rather than going to the UnknownFieldSet.
420  return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
421 }
422 
423 inline bool SupportsArenas(const FileDescriptor* file) {
424  return file->options().cc_enable_arenas();
425 }
426 
427 inline bool SupportsArenas(const Descriptor* desc) {
428  return SupportsArenas(desc->file());
429 }
430 
431 inline bool SupportsArenas(const FieldDescriptor* field) {
432  return SupportsArenas(field->file());
433 }
434 
436  return field->type() == FieldDescriptor::TYPE_MESSAGE &&
437  field->message_type()->file() != field->file();
438 }
439 
441  return SupportsArenas(d) ? "CreateMessage" : "Create";
442 }
443 
445  return "_i_give_permission_to_break_this_code_default_" + FieldName(field) +
446  "_";
447 }
448 
449 bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
450 bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
451 
453 
454 inline std::string IncludeGuard(const FileDescriptor* file, bool pb_h,
455  const Options& options) {
456  // If we are generating a .pb.h file and the proto_h option is enabled, then
457  // the .pb.h gets an extra suffix.
458  std::string filename_identifier = FilenameIdentifier(
459  file->name() + (pb_h && options.proto_h ? ".pb.h" : ""));
460 
461  if (IsWellKnownMessage(file)) {
462  // For well-known messages we need third_party/protobuf and net/proto2 to
463  // have distinct include guards, because some source files include both and
464  // both need to be defined (the third_party copies will be in the
465  // google::protobuf_opensource namespace).
466  return MacroPrefix(options) + "_INCLUDED_" + filename_identifier;
467  } else {
468  // Ideally this case would use distinct include guards for opensource and
469  // google3 protos also. (The behavior of "first #included wins" is not
470  // ideal). But unfortunately some legacy code includes both and depends on
471  // the identical include guards to avoid compile errors.
472  //
473  // We should clean this up so that this case can be removed.
474  return "GOOGLE_PROTOBUF_INCLUDED_" + filename_identifier;
475  }
476 }
477 
479  const Options& options) {
480  switch (options.enforce_mode) {
482  return FileOptions::SPEED;
486  default:
487  return file->options().optimize_for();
488  }
489 }
490 
491 // This orders the messages in a .pb.cc as it's outputted by file.cc
492 void FlattenMessagesInFile(const FileDescriptor* file,
493  std::vector<const Descriptor*>* result);
494 inline std::vector<const Descriptor*> FlattenMessagesInFile(
495  const FileDescriptor* file) {
496  std::vector<const Descriptor*> result;
497  FlattenMessagesInFile(file, &result);
498  return result;
499 }
500 
501 bool HasWeakFields(const Descriptor* desc, const Options& options);
502 bool HasWeakFields(const FileDescriptor* desc, const Options& options);
503 
504 // Returns true if the "required" restriction check should be ignored for the
505 // given field.
507  const Options& options) {
508  // Do not check "required" for lazy fields.
509  return IsLazy(field, options);
510 }
511 
518 };
519 
520 // This class is used in FileGenerator, to ensure linear instead of
521 // quadratic performance, if we do this per message we would get O(V*(V+E)).
522 // Logically this is just only used in message.cc, but in the header for
523 // FileGenerator to help share it.
524 class PROTOC_EXPORT MessageSCCAnalyzer {
525  public:
527 
528  MessageAnalysis GetSCCAnalysis(const SCC* scc);
529 
531  MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor));
532  return result.contains_required || result.contains_extension;
533  }
534  const SCC* GetSCC(const Descriptor* descriptor) {
535  return analyzer_.GetSCC(descriptor);
536  }
537 
538  private:
539  struct DepsGenerator {
540  std::vector<const Descriptor*> operator()(const Descriptor* desc) const {
541  std::vector<const Descriptor*> deps;
542  for (int i = 0; i < desc->field_count(); i++) {
543  if (desc->field(i)->message_type()) {
544  deps.push_back(desc->field(i)->message_type());
545  }
546  }
547  return deps;
548  }
549  };
552  std::map<const SCC*, MessageAnalysis> analysis_cache_;
553 };
554 
555 inline std::string SccInfoSymbol(const SCC* scc, const Options& options) {
556  return UniqueName("scc_info_" + ClassName(scc->GetRepresentative()),
557  scc->GetRepresentative(), options);
558 }
559 
560 void ListAllFields(const Descriptor* d,
561  std::vector<const FieldDescriptor*>* fields);
562 void ListAllFields(const FileDescriptor* d,
563  std::vector<const FieldDescriptor*>* fields);
564 
565 template <class T>
566 void ForEachField(const Descriptor* d, T&& func) {
567  for (int i = 0; i < d->nested_type_count(); i++) {
568  ForEachField(d->nested_type(i), std::forward<T&&>(func));
569  }
570  for (int i = 0; i < d->extension_count(); i++) {
571  func(d->extension(i));
572  }
573  for (int i = 0; i < d->field_count(); i++) {
574  func(d->field(i));
575  }
576 }
577 
578 template <class T>
579 void ForEachField(const FileDescriptor* d, T&& func) {
580  for (int i = 0; i < d->message_type_count(); i++) {
581  ForEachField(d->message_type(i), std::forward<T&&>(func));
582  }
583  for (int i = 0; i < d->extension_count(); i++) {
584  func(d->extension(i));
585  }
586 }
587 
589  std::vector<const Descriptor*>* types);
590 
591 // Indicates whether we should use implicit weak fields for this file.
592 bool UsingImplicitWeakFields(const FileDescriptor* file,
593  const Options& options);
594 
595 // Indicates whether to treat this field as implicitly weak.
596 bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
597  MessageSCCAnalyzer* scc_analyzer);
598 
599 // Formatter is a functor class which acts as a closure around printer and
600 // the variable map. It's much like printer->Print except it supports both named
601 // variables that are substituted using a key value map and direct arguments. In
602 // the format string $1$, $2$, etc... are substituted for the first, second, ...
603 // direct argument respectively in the format call, it accepts both strings and
604 // integers. The implementation verifies all arguments are used and are "first"
605 // used in order of appearance in the argument list. For example,
606 //
607 // Format("return array[$1$];", 3) -> "return array[3];"
608 // Format("array[$2$] = $1$;", "Bla", 3) -> FATAL error (wrong order)
609 // Format("array[$1$] = $2$;", 3, "Bla") -> "array[3] = Bla;"
610 //
611 // The arguments can be used more than once like
612 //
613 // Format("array[$1$] = $2$; // Index = $1$", 3, "Bla") ->
614 // "array[3] = Bla; // Index = 3"
615 //
616 // If you use more arguments use the following style to help the reader,
617 //
618 // Format("int $1$() {\n"
619 // " array[$2$] = $3$;\n"
620 // " return $4$;"
621 // "}\n",
622 // funname, // 1
623 // idx, // 2
624 // varname, // 3
625 // retval); // 4
626 //
627 // but consider using named variables. Named variables like $foo$, with some
628 // identifier foo, are looked up in the map. One additional feature is that
629 // spaces are accepted between the '$' delimiters, $ foo$ will
630 // substiture to " bar" if foo stands for "bar", but in case it's empty
631 // will substitute to "". Hence, for example,
632 //
633 // Format(vars, "$dllexport $void fun();") -> "void fun();"
634 // "__declspec(export) void fun();"
635 //
636 // which is convenient to prevent double, leading or trailing spaces.
637 class PROTOC_EXPORT Formatter {
638  public:
639  explicit Formatter(io::Printer* printer) : printer_(printer) {}
641  const std::map<std::string, std::string>& vars)
642  : printer_(printer), vars_(vars) {}
643 
644  template <typename T>
645  void Set(const std::string& key, const T& value) {
646  vars_[key] = ToString(value);
647  }
648 
649  void AddMap(const std::map<std::string, std::string>& vars) {
650  for (const auto& keyval : vars) vars_[keyval.first] = keyval.second;
651  }
652 
653  template <typename... Args>
654  void operator()(const char* format, const Args&... args) const {
655  printer_->FormatInternal({ToString(args)...}, vars_, format);
656  }
657 
658  void Indent() const { printer_->Indent(); }
659  void Outdent() const { printer_->Outdent(); }
660  io::Printer* printer() const { return printer_; }
661 
662  class PROTOC_EXPORT SaveState {
663  public:
665  : format_(format), vars_(format->vars_) {}
666  ~SaveState() { format_->vars_.swap(vars_); }
667 
668  private:
670  std::map<std::string, std::string> vars_;
671  };
672 
673  private:
675  std::map<std::string, std::string> vars_;
676 
677  // Convenience overloads to accept different types as arguments.
678  static std::string ToString(const std::string& s) { return s; }
679  template <typename I, typename = typename std::enable_if<
681  static std::string ToString(I x) {
682  return StrCat(x);
683  }
684  static std::string ToString(strings::Hex x) { return StrCat(x); }
685  static std::string ToString(const FieldDescriptor* d) { return Payload(d); }
686  static std::string ToString(const Descriptor* d) { return Payload(d); }
687  static std::string ToString(const EnumDescriptor* d) { return Payload(d); }
689  return Payload(d);
690  }
691  static std::string ToString(const OneofDescriptor* d) { return Payload(d); }
692 
693  template <typename Descriptor>
695  std::vector<int> path;
696  descriptor->GetLocationPath(&path);
698  for (int i = 0; i < path.size(); ++i) {
699  annotation.add_path(path[i]);
700  }
701  annotation.set_source_file(descriptor->file()->name());
702  return annotation.SerializeAsString();
703  }
704 };
705 
706 class PROTOC_EXPORT NamespaceOpener {
707  public:
709  : printer_(format.printer()) {}
712  ChangeTo(name);
713  }
714  ~NamespaceOpener() { ChangeTo(""); }
715 
716  void ChangeTo(const std::string& name) {
717  std::vector<std::string> new_stack_ =
718  Split(name, "::", true);
719  int len = std::min(name_stack_.size(), new_stack_.size());
720  int common_idx = 0;
721  while (common_idx < len) {
722  if (name_stack_[common_idx] != new_stack_[common_idx]) break;
723  common_idx++;
724  }
725  for (int i = name_stack_.size() - 1; i >= common_idx; i--) {
726  if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") {
727  printer_->Print("PROTOBUF_NAMESPACE_CLOSE\n");
728  } else {
729  printer_->Print("} // namespace $ns$\n", "ns", name_stack_[i]);
730  }
731  }
732  name_stack_.swap(new_stack_);
733  for (int i = common_idx; i < name_stack_.size(); i++) {
734  if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") {
735  printer_->Print("PROTOBUF_NAMESPACE_OPEN\n");
736  } else {
737  printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]);
738  }
739  }
740  }
741 
742  private:
744  std::vector<std::string> name_stack_;
745 };
746 
749  const Options& options, bool for_parse,
750  const char* parameters,
751  const Formatter& format);
752 
754  const Options& options, bool for_parse,
755  const char* parameters,
756  const Formatter& format);
757 
758 template <typename T>
760  struct Iterator {
761  using iterator_category = std::forward_iterator_tag;
762  using value_type = const FieldDescriptor*;
763  using difference_type = int;
764 
765  value_type operator*() { return descriptor->field(idx); }
766 
767  friend bool operator==(const Iterator& a, const Iterator& b) {
768  GOOGLE_DCHECK(a.descriptor == b.descriptor);
769  return a.idx == b.idx;
770  }
771  friend bool operator!=(const Iterator& a, const Iterator& b) {
772  return !(a == b);
773  }
774 
776  idx++;
777  return *this;
778  }
779 
780  int idx;
781  const T* descriptor;
782  };
783 
784  Iterator begin() const { return {0, descriptor}; }
785  Iterator end() const { return {descriptor->field_count(), descriptor}; }
786 
787  const T* descriptor;
788 };
789 
790 template <typename T>
792  return {desc};
793 }
794 
796  struct Iterator {
797  using iterator_category = std::forward_iterator_tag;
798  using value_type = const OneofDescriptor*;
799  using difference_type = int;
800 
802 
803  friend bool operator==(const Iterator& a, const Iterator& b) {
804  GOOGLE_DCHECK(a.descriptor == b.descriptor);
805  return a.idx == b.idx;
806  }
807  friend bool operator!=(const Iterator& a, const Iterator& b) {
808  return !(a == b);
809  }
810 
812  idx++;
813  return *this;
814  }
815 
816  int idx;
818  };
819 
820  Iterator begin() const { return {0, descriptor}; }
822 
824 };
825 
826 inline OneOfRangeImpl OneOfRange(const Descriptor* desc) { return {desc}; }
827 
828 void GenerateParserLoop(const Descriptor* descriptor, int num_hasbits,
829  const Options& options,
830  MessageSCCAnalyzer* scc_analyzer, io::Printer* printer);
831 
832 } // namespace cpp
833 } // namespace compiler
834 } // namespace protobuf
835 } // namespace google
836 
837 #include <google/protobuf/port_undef.inc>
838 
839 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
google::protobuf::FieldDescriptor::Type
Type
Definition: src/google/protobuf/descriptor.h:521
google::protobuf::compiler::cpp::IsBootstrapProto
bool IsBootstrapProto(const Options &options, const FileDescriptor *file)
Definition: cpp_helpers.cc:1262
google::protobuf::compiler::cpp::EnforceOptimizeMode::kLiteRuntime
@ kLiteRuntime
google::protobuf::compiler::cpp::IsAnyMessage
bool IsAnyMessage(const FileDescriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:953
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(const EnumValueDescriptor *d)
Definition: cpp_helpers.h:688
google::protobuf::compiler::cpp::Formatter::printer_
io::Printer * printer_
Definition: cpp_helpers.h:674
google::protobuf::compiler::cpp::MessageSCCAnalyzer::DepsGenerator
Definition: cpp_helpers.h:539
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::difference_type
int difference_type
Definition: cpp_helpers.h:763
google::protobuf::compiler::cpp::HasGeneratedMethods
bool HasGeneratedMethods(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:359
google::protobuf::compiler::cpp::IsStringOrMessage
bool IsStringOrMessage(const FieldDescriptor *field)
Definition: cpp_helpers.cc:921
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: src/google/protobuf/descriptor.h:562
google::protobuf::FieldDescriptor
Definition: src/google/protobuf/descriptor.h:515
google::protobuf::compiler::cpp::NamespaceOpener::NamespaceOpener
NamespaceOpener(const Formatter &format)
Definition: cpp_helpers.h:708
google::protobuf::compiler::cpp::FieldRangeImpl::descriptor
const T * descriptor
Definition: cpp_helpers.h:787
FileOptions::LITE_RUNTIME
static constexpr OptimizeMode LITE_RUNTIME
Definition: descriptor.pb.h:3485
google::protobuf::compiler::cpp::IsCord
bool IsCord(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.h:312
google::protobuf::compiler::cpp::Formatter::Formatter
Formatter(io::Printer *printer, const std::map< std::string, std::string > &vars)
Definition: cpp_helpers.h:640
google::protobuf::compiler::SCC
Definition: scc.h:49
google::protobuf::compiler::cpp::FieldName
std::string FieldName(const FieldDescriptor *field)
Definition: cpp_helpers.cc:410
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
google::protobuf::compiler::cpp::ProtobufNamespace
std::string ProtobufNamespace(const Options &options)
Definition: cpp_helpers.h:60
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(const OneofDescriptor *d)
Definition: cpp_helpers.h:691
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: strutil.cc:1480
google::protobuf::compiler::cpp::MessageAnalysis
Definition: cpp_helpers.h:512
google::protobuf::compiler::cpp::StripProto
std::string StripProto(const std::string &filename)
Definition: cpp_helpers.cc:474
types
GLsizei GLenum GLenum * types
Definition: glcorearb.h:4177
google::protobuf::compiler::cpp::FieldRange
FieldRangeImpl< T > FieldRange(const T *desc)
Definition: cpp_helpers.h:791
options
Message * options
Definition: src/google/protobuf/descriptor.cc:3119
input
std::string input
Definition: tokenizer_unittest.cc:197
google::protobuf::compiler::cpp::NamespaceOpener::NamespaceOpener
NamespaceOpener(const std::string &name, const Formatter &format)
Definition: cpp_helpers.h:710
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(I x)
Definition: cpp_helpers.h:681
google::protobuf.internal._parameterized.parameters
def parameters(*testcases)
Definition: _parameterized.py:315
google::protobuf::compiler::cpp::Formatter::SaveState
Definition: cpp_helpers.h:662
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator
Definition: cpp_helpers.h:796
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: logging.h:194
google::protobuf::compiler::cpp::Formatter::operator()
void operator()(const char *format, const Args &... args) const
Definition: cpp_helpers.h:654
s
XmlRpcServer s
google::protobuf::compiler::cpp::FieldConstantName
std::string FieldConstantName(const FieldDescriptor *field)
Definition: cpp_helpers.cc:451
google::protobuf::compiler::cpp::HasEnumDefinitions
static bool HasEnumDefinitions(const Descriptor *message_type)
Definition: cpp_helpers.cc:905
google::protobuf::compiler::cpp::NamespaceOpener
Definition: cpp_helpers.h:706
google::protobuf::compiler::cpp::HasLazyFields
static bool HasLazyFields(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:765
google::protobuf::compiler::cpp::FieldRangeImpl::begin
Iterator begin() const
Definition: cpp_helpers.h:784
google::protobuf::compiler::cpp::GetUtf8Suffix
std::string GetUtf8Suffix(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.cc:1011
google::protobuf::compiler::cpp::Formatter::Indent
void Indent() const
Definition: cpp_helpers.h:658
google::protobuf::compiler::cpp::Formatter::AddMap
void AddMap(const std::map< std::string, std::string > &vars)
Definition: cpp_helpers.h:649
desc
#define desc
Definition: extension_set.h:342
FieldOptions_CType
FieldOptions_CType
Definition: descriptor.pb.h:259
google::protobuf::compiler::cpp::QualifiedClassName
std::string QualifiedClassName(const Descriptor *d, const Options &options)
Definition: cpp_helpers.cc:319
GeneratedCodeInfo_Annotation::add_path
void add_path(::PROTOBUF_NAMESPACE_ID::int32 value)
Definition: descriptor.pb.h:11749
google::protobuf::OneofDescriptor
Definition: src/google/protobuf/descriptor.h:843
GeneratedCodeInfo_Annotation::set_source_file
void set_source_file(const std::string &value)
Definition: descriptor.pb.h:11776
google::protobuf::compiler::cpp::IsStringInlined
bool IsStringInlined(const FieldDescriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:746
google::protobuf::compiler::cpp::HasPreservingUnknownEnumSemantics
bool HasPreservingUnknownEnumSemantics(const FieldDescriptor *field)
Definition: cpp_helpers.h:419
google::protobuf::compiler::cpp::Formatter::SaveState::SaveState
SaveState(Formatter *format)
Definition: cpp_helpers.h:664
google::protobuf::compiler::cpp::SuperClassName
std::string SuperClassName(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:396
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
scc.h
google::protobuf::compiler::cpp::EstimateAlignmentSize
int EstimateAlignmentSize(const FieldDescriptor *field)
Definition: cpp_helpers.cc:427
google::protobuf::compiler::cpp::MakeDefaultName
std::string MakeDefaultName(const FieldDescriptor *field)
Definition: cpp_helpers.h:444
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::operator!=
friend bool operator!=(const Iterator &a, const Iterator &b)
Definition: cpp_helpers.h:771
descriptor
Descriptor * descriptor
Definition: php/ext/google/protobuf/protobuf.h:936
google::protobuf::compiler::cpp::EnumValueName
std::string EnumValueName(const EnumValueDescriptor *enum_value)
Definition: cpp_helpers.cc:419
x
GLint GLenum GLint x
Definition: glcorearb.h:2834
port.h
google::protobuf::compiler::cpp::UniqueName
string UniqueName(const std::string &name, const std::string &filename, const Options &options)
Definition: cpp_helpers.cc:706
google::protobuf::compiler::cpp::OneOfRangeImpl
Definition: cpp_helpers.h:795
google::protobuf::compiler::cpp::GetOptimizeFor
FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:478
T
#define T(upbtypeconst, upbtype, ctype, default_value)
google::protobuf::compiler::cpp::OneOfRangeImpl::descriptor
const Descriptor * descriptor
Definition: cpp_helpers.h:823
google::protobuf::compiler::cpp::MessageCreateFunction
std::string MessageCreateFunction(const Descriptor *d)
Definition: cpp_helpers.h:440
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::idx
int idx
Definition: cpp_helpers.h:780
google::protobuf::compiler::cpp::DeclaredTypeMethodName
const char * DeclaredTypeMethodName(FieldDescriptor::Type type)
Definition: cpp_helpers.cc:545
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::descriptor
const T * descriptor
Definition: cpp_helpers.h:781
google::protobuf::FileDescriptor::syntax
Syntax syntax() const
Definition: src/google/protobuf/descriptor.h:2175
google::protobuf::compiler::cpp::ReferenceFunctionName
std::string ReferenceFunctionName(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:391
FileOptions::cc_generic_services
bool cc_generic_services() const
Definition: descriptor.pb.h:9758
google::protobuf::compiler::cpp::HasMapFields
static bool HasMapFields(const Descriptor *descriptor)
Definition: cpp_helpers.cc:886
google::protobuf::compiler::cpp::FlattenMessagesInFile
void FlattenMessagesInFile(const FileDescriptor *file, std::vector< const Descriptor * > *result)
Definition: cpp_helpers.cc:1097
google::protobuf::compiler::cpp::IsWeak
bool IsWeak(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.h:297
google::protobuf::compiler::SCC::GetRepresentative
const Descriptor * GetRepresentative() const
Definition: scc.h:53
google::protobuf::compiler::cpp::HasWeakFields
bool HasWeakFields(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:1104
b
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:3228
google::protobuf::compiler::cpp::GenerateUtf8CheckCodeForString
void GenerateUtf8CheckCodeForString(const FieldDescriptor *field, const Options &options, bool for_parse, const char *parameters, const Formatter &format)
Definition: cpp_helpers.cc:1069
google::protobuf::compiler::cpp::Formatter::Set
void Set(const std::string &key, const T &value)
Definition: cpp_helpers.h:645
google::protobuf::compiler::cpp::FileDllExport
std::string FileDllExport(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.cc:387
google::protobuf::compiler::cpp::MessageAnalysis::constructor_requires_initialization
bool constructor_requires_initialization
Definition: cpp_helpers.h:517
google::protobuf::ServiceDescriptor
Definition: src/google/protobuf/descriptor.h:1152
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: cpp_helpers.h:797
google::protobuf::compiler::cpp::HasStringPieceFields
static bool HasStringPieceFields(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:826
google::protobuf::compiler::cpp::FieldRangeImpl
Definition: cpp_helpers.h:759
google::protobuf::compiler::cpp::UsingImplicitWeakFields
bool UsingImplicitWeakFields(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.cc:1118
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator
Definition: cpp_helpers.h:760
google::protobuf::compiler::cpp::SafeFunctionName
std::string SafeFunctionName(const Descriptor *descriptor, const FieldDescriptor *field, const std::string &prefix)
Definition: cpp_helpers.cc:727
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::descriptor
const Descriptor * descriptor
Definition: cpp_helpers.h:817
strutil.h
google::protobuf::compiler::cpp::Formatter::SaveState::format_
Formatter * format_
Definition: cpp_helpers.h:669
google::protobuf::compiler::cpp::Formatter::printer
io::Printer * printer() const
Definition: cpp_helpers.h:660
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::operator!=
friend bool operator!=(const Iterator &a, const Iterator &b)
Definition: cpp_helpers.h:807
path
GLsizei const GLchar ** path
Definition: glcorearb.h:3658
prefix
static const char prefix[]
Definition: test_pair_ipc.cpp:26
google::protobuf::compiler::cpp::Formatter::SaveState::~SaveState
~SaveState()
Definition: cpp_helpers.h:666
google::protobuf::compiler::cpp::EffectiveStringCType
FieldOptions::CType EffectiveStringCType(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.cc:941
FileOptions::cc_enable_arenas
bool cc_enable_arenas() const
Definition: descriptor.pb.h:9848
google::protobuf::compiler::cpp::Formatter::SaveState::vars_
std::map< std::string, std::string > vars_
Definition: cpp_helpers.h:670
FileOptions_OptimizeMode
FileOptions_OptimizeMode
Definition: descriptor.pb.h:235
google::protobuf::compiler::cpp::IsLazy
bool IsLazy(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.h:327
format
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:2773
google::protobuf::compiler::cpp::FieldScope
const Descriptor * FieldScope(const FieldDescriptor *field)
Definition: cpp_helpers.h:182
google::protobuf::compiler::cpp::ResolveKeyword
std::string ResolveKeyword(const string &name)
Definition: cpp_helpers.cc:403
google::protobuf::compiler::cpp::SupportsArenas
bool SupportsArenas(const FileDescriptor *file)
Definition: cpp_helpers.h:423
GeneratedCodeInfo_Annotation
Definition: descriptor.pb.h:6147
google::protobuf::compiler::cpp::IsImplicitWeakField
bool IsImplicitWeakField(const FieldDescriptor *field, const Options &options, MessageSCCAnalyzer *scc_analyzer)
Definition: cpp_helpers.cc:1124
google::protobuf::Descriptor::oneof_decl
const OneofDescriptor * oneof_decl(int index) const
google::protobuf::compiler::cpp::QualifiedFileLevelSymbol
std::string QualifiedFileLevelSymbol(const FileDescriptor *file, const std::string &name, const Options &options)
Definition: cpp_helpers.cc:712
google::protobuf::compiler::cpp::IsMapEntryMessage
bool IsMapEntryMessage(const Descriptor *descriptor)
Definition: cpp_helpers.h:403
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(const FieldDescriptor *d)
Definition: cpp_helpers.h:685
google::protobuf::compiler::cpp::MessageAnalysis::contains_cord
bool contains_cord
Definition: cpp_helpers.h:514
printer.h
google::protobuf::compiler::cpp::MessageAnalysis::contains_extension
bool contains_extension
Definition: cpp_helpers.h:515
google::protobuf::compiler::cpp::FieldMessageTypeName
std::string FieldMessageTypeName(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.cc:467
google::protobuf::Descriptor::oneof_decl_count
int oneof_decl_count() const
google::protobuf::compiler::cpp::OneOfRange
OneOfRangeImpl OneOfRange(const Descriptor *desc)
Definition: cpp_helpers.h:826
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: cpp_helpers.h:761
google::protobuf::compiler::cpp::DefaultInstanceType
std::string DefaultInstanceType(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:366
google::protobuf::compiler::cpp::NamespaceOpener::ChangeTo
void ChangeTo(const std::string &name)
Definition: cpp_helpers.h:716
google::protobuf::compiler::cpp::DescriptorTableName
std::string DescriptorTableName(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.cc:382
google::protobuf::compiler::cpp::IsStringPiece
bool IsStringPiece(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.h:317
google::protobuf::compiler::cpp::MessageSCCAnalyzer::options_
Options options_
Definition: cpp_helpers.h:551
google::protobuf::compiler::cpp::DefaultValue
std::string DefaultValue(const FieldDescriptor *field)
Definition: cpp_helpers.cc:616
google::protobuf::compiler::cpp::DeprecatedAttribute
std::string DeprecatedAttribute(const Options &options, bool deprecated)
Definition: cpp_helpers.h:68
google::protobuf::compiler::cpp::UseUnknownFieldSet
bool UseUnknownFieldSet(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:292
code_generator.h
cpp
Definition: third_party/googletest/googlemock/scripts/generator/cpp/__init__.py:1
google::protobuf::FileDescriptor::options
const FileOptions & options() const
google::protobuf::compiler::cpp::SetCommonVars
void SetCommonVars(const Options &options, std::map< std::string, std::string > *variables)
Definition: cpp_helpers.cc:209
google::protobuf::compiler::cpp::NamespaceOpener::~NamespaceOpener
~NamespaceOpener()
Definition: cpp_helpers.h:714
d
d
google::protobuf::compiler::cpp::Options
Definition: cpp_options.h:52
google::protobuf::compiler::cpp::GetBootstrapBasename
bool GetBootstrapBasename(const Options &options, const std::string &basename, std::string *bootstrap_basename)
Definition: cpp_helpers.cc:1238
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::operator==
friend bool operator==(const Iterator &a, const Iterator &b)
Definition: cpp_helpers.h:803
google::protobuf::compiler::cpp::IncludeGuard
std::string IncludeGuard(const FileDescriptor *file, bool pb_h, const Options &options)
Definition: cpp_helpers.h:454
google::protobuf::compiler::cpp::InternalRuntimeOptions
Options InternalRuntimeOptions()
Definition: cpp_helpers.h:243
google::protobuf::compiler::cpp::QualifiedDefaultInstanceName
std::string QualifiedDefaultInstanceName(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:376
google::protobuf::FileDescriptor::SYNTAX_PROTO3
@ SYNTAX_PROTO3
Definition: src/google/protobuf/descriptor.h:1394
google::protobuf::compiler::cpp::MessageAnalysis::contains_required
bool contains_required
Definition: cpp_helpers.h:516
google::protobuf::compiler::cpp::MessageSCCAnalyzer::analysis_cache_
std::map< const SCC *, MessageAnalysis > analysis_cache_
Definition: cpp_helpers.h:552
google::protobuf::compiler::cpp::IsCrossFileMessage
bool IsCrossFileMessage(const FieldDescriptor *field)
Definition: cpp_helpers.h:435
google::protobuf::compiler::cpp::HasDescriptorMethods
bool HasDescriptorMethods(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:365
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf::compiler::cpp::ListAllFields
void ListAllFields(const Descriptor *d, std::vector< const FieldDescriptor * > *fields)
Definition: cpp_helpers.cc:1198
FileOptions::optimize_for
PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode optimize_for() const
Definition: descriptor.pb.h:9659
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(const std::string &s)
Definition: cpp_helpers.h:678
google::protobuf::compiler::cpp::MessageSCCAnalyzer::MessageSCCAnalyzer
MessageSCCAnalyzer(const Options &options)
Definition: cpp_helpers.h:526
key
const SETUP_TEARDOWN_TESTCONTEXT char * key
Definition: test_wss_transport.cpp:10
FileOptions::SPEED
static constexpr OptimizeMode SPEED
Definition: descriptor.pb.h:3481
google::protobuf::compiler::cpp::OneOfRangeImpl::end
Iterator end() const
Definition: cpp_helpers.h:821
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: logging.h:153
google::protobuf::io::Printer
Definition: printer.h:181
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::operator++
Iterator & operator++()
Definition: cpp_helpers.h:775
google::protobuf::compiler::cpp::HasCordFields
static bool HasCordFields(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:849
i
int i
Definition: gmock-matchers_test.cc:764
google::protobuf::compiler::cpp::kThickSeparator
const char kThickSeparator[]
Definition: cpp_helpers.cc:272
google::protobuf::compiler::cpp::Int32ToString
std::string Int32ToString(int number)
Definition: cpp_helpers.cc:593
google::protobuf::FieldDescriptor::TYPE_MESSAGE
@ TYPE_MESSAGE
Definition: src/google/protobuf/descriptor.h:536
google::protobuf::compiler::cpp::MessageSCCAnalyzer::HasRequiredFields
bool HasRequiredFields(const Descriptor *descriptor)
Definition: cpp_helpers.h:530
google::protobuf::compiler::cpp::Namespace
std::string Namespace(const std::string &package)
Definition: cpp_helpers.cc:336
google::protobuf::FileDescriptor::name
const std::string & name() const
google::protobuf::compiler::cpp::Formatter::vars_
std::map< std::string, std::string > vars_
Definition: cpp_helpers.h:675
fields
static const upb_fielddef fields[107]
Definition: ruby/ext/google/protobuf_c/upb.c:7671
google::protobuf::compiler::cpp::FieldRangeImpl::end
Iterator end() const
Definition: cpp_helpers.h:785
google::protobuf::compiler::cpp::IsWellKnownMessage
bool IsWellKnownMessage(const FileDescriptor *file)
Definition: cpp_helpers.cc:962
type
GLenum type
Definition: glcorearb.h:2695
google::protobuf::compiler::cpp::MessageSCCAnalyzer::DepsGenerator::operator()
std::vector< const Descriptor * > operator()(const Descriptor *desc) const
Definition: cpp_helpers.h:540
len
int len
Definition: php/ext/google/protobuf/map.c:206
google::protobuf::compiler::cpp::SccInfoSymbol
std::string SccInfoSymbol(const SCC *scc, const Options &options)
Definition: cpp_helpers.h:555
google::protobuf::compiler::cpp::HasGenericServices
bool HasGenericServices(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:371
google::protobuf::compiler::cpp::MessageSCCAnalyzer::GetSCC
const SCC * GetSCC(const Descriptor *descriptor)
Definition: cpp_helpers.h:534
Args
Args({7, 6, 3})
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::operator*
value_type operator*()
Definition: cpp_helpers.h:801
google::protobuf::compiler::cpp::FilenameIdentifier
std::string FilenameIdentifier(const std::string &filename)
Definition: cpp_helpers.cc:692
google::protobuf::compiler::cpp::MessageSCCAnalyzer
Definition: cpp_helpers.h:524
google::protobuf::compiler::cpp::DefaultInstanceName
std::string DefaultInstanceName(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.cc:371
enum_descriptor
VALUE enum_descriptor(VALUE self)
Definition: ruby/ext/google/protobuf_c/message.c:801
google::protobuf::compiler::cpp::GenerateParserLoop
void GenerateParserLoop(const Descriptor *descriptor, int num_hasbits, const Options &options, MessageSCCAnalyzer *scc_analyzer, io::Printer *printer)
Definition: cpp_helpers.cc:1832
google::protobuf::compiler::cpp::Formatter::Payload
static std::string Payload(const Descriptor *descriptor)
Definition: cpp_helpers.h:694
google::protobuf::compiler::cpp::GenerateUtf8CheckCodeForCord
void GenerateUtf8CheckCodeForCord(const FieldDescriptor *field, const Options &options, bool for_parse, const char *parameters, const Formatter &format)
Definition: cpp_helpers.cc:1078
google::protobuf::FileDescriptor::service_count
int service_count() const
google::protobuf::compiler::cpp::HasExtensionsOrExtendableMessage
static bool HasExtensionsOrExtendableMessage(const Descriptor *descriptor)
Definition: cpp_helpers.cc:867
google::protobuf::compiler::cpp::EscapeTrigraphs
std::string EscapeTrigraphs(const std::string &to_escape)
Definition: cpp_helpers.cc:722
func
GLenum func
Definition: glcorearb.h:3052
google::protobuf::compiler::cpp::EnforceOptimizeMode::kNoEnforcement
@ kNoEnforcement
google::protobuf::EnumValueDescriptor
Definition: src/google/protobuf/descriptor.h:1075
google::protobuf::Split
std::vector< string > Split(const string &full, const char *delim, bool skip_empty=true)
Definition: strutil.h:235
google::protobuf::compiler::cpp::ClassName
std::string ClassName(const Descriptor *descriptor)
Definition: cpp_helpers.cc:301
google::protobuf::compiler::cpp::HasRepeatedFields
static bool HasRepeatedFields(const Descriptor *descriptor)
Definition: cpp_helpers.cc:801
google::protobuf::Descriptor
Definition: src/google/protobuf/descriptor.h:231
descriptor.h
google::protobuf::compiler::SCCAnalyzer
Definition: scc.h:63
google::protobuf::compiler::cpp::EnforceOptimizeMode::kSpeed
@ kSpeed
google::protobuf::compiler::cpp::UnderscoresToCamelCase
std::string UnderscoresToCamelCase(const std::string &input, bool cap_next_letter)
Definition: cpp_helpers.cc:246
google::protobuf::compiler::cpp::PrimitiveTypeName
const char * PrimitiveTypeName(FieldDescriptor::CppType type)
Definition: cpp_helpers.cc:482
FieldOptions::STRING_PIECE
static constexpr CType STRING_PIECE
Definition: descriptor.pb.h:4201
google::protobuf::compiler::cpp::ForEachField
void ForEachField(const Descriptor *d, T &&func)
Definition: cpp_helpers.h:566
google::protobuf::compiler::cpp::ListAllTypesForServices
void ListAllTypesForServices(const FileDescriptor *fd, std::vector< const Descriptor * > *types)
Definition: cpp_helpers.cc:1226
google::protobuf::FileDescriptor
Definition: src/google/protobuf/descriptor.h:1320
google::protobuf::compiler::cpp::ShouldIgnoreRequiredFieldCheck
static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor *field, const Options &options)
Definition: cpp_helpers.h:506
google::protobuf::compiler::cpp::Formatter::Outdent
void Outdent() const
Definition: cpp_helpers.h:659
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(const EnumDescriptor *d)
Definition: cpp_helpers.h:687
google::protobuf::compiler::cpp::PublicUnknownFieldsAccessors
bool PublicUnknownFieldsAccessors(const Descriptor *message)
Definition: cpp_helpers.h:282
google::protobuf::compiler::cpp::MessageSCCAnalyzer::analyzer_
SCCAnalyzer< DepsGenerator > analyzer_
Definition: cpp_helpers.h:550
google::protobuf::compiler::cpp::HasFieldPresence
bool HasFieldPresence(const FileDescriptor *file)
Definition: cpp_helpers.h:413
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(const Descriptor *d)
Definition: cpp_helpers.h:686
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::difference_type
int difference_type
Definition: cpp_helpers.h:799
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::idx
int idx
Definition: cpp_helpers.h:816
google::protobuf::compiler::cpp::MacroPrefix
std::string MacroPrefix(const Options &options)
Definition: cpp_helpers.h:64
google::protobuf::compiler::cpp::IsProto2MessageSet
bool IsProto2MessageSet(const Descriptor *descriptor, const Options &options)
Definition: cpp_helpers.h:386
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
google::protobuf::compiler::cpp::OneOfRangeImpl::begin
Iterator begin() const
Definition: cpp_helpers.h:820
descriptor.pb.h
google::protobuf::compiler::cpp::kThinSeparator
const char kThinSeparator[]
Definition: cpp_helpers.cc:274
FileOptions::CODE_SIZE
static constexpr OptimizeMode CODE_SIZE
Definition: descriptor.pb.h:3483
cpp_options.h
google::protobuf::compiler::cpp::IsProto2MessageSetFile
bool IsProto2MessageSetFile(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:395
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::operator*
value_type operator*()
Definition: cpp_helpers.h:765
google::protobuf::EnumDescriptor
Definition: src/google/protobuf/descriptor.h:918
google::protobuf::compiler::GeneratorContext
Definition: code_generator.h:119
FieldOptions::CORD
static constexpr CType CORD
Definition: descriptor.pb.h:4199
google::protobuf::compiler::cpp::HasFastArraySerialization
bool HasFastArraySerialization(const FileDescriptor *file, const Options &options)
Definition: cpp_helpers.h:381
google::protobuf::compiler::cpp::Formatter::ToString
static std::string ToString(strings::Hex x)
Definition: cpp_helpers.h:684
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:3228
google::protobuf::compiler::cpp::CanInitializeByZeroing
bool CanInitializeByZeroing(const FieldDescriptor *field)
Definition: cpp_helpers.cc:277
google::protobuf::compiler::cpp::Int64ToString
std::string Int64ToString(const std::string &macro_prefix, int64 number)
Definition: cpp_helpers.cc:603
number
double number
Definition: cJSON.h:326
google::protobuf::compiler::cpp::OneOfRangeImpl::Iterator::operator++
Iterator & operator++()
Definition: cpp_helpers.h:811
google::protobuf::FieldDescriptor::CppType
CppType
Definition: src/google/protobuf/descriptor.h:553
compiler
Definition: plugin.pb.cc:22
google
Definition: data_proto2_to_proto3_util.h:11
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
google::protobuf::compiler::cpp::Formatter::Formatter
Formatter(io::Printer *printer)
Definition: cpp_helpers.h:639
google::protobuf::compiler::cpp::MessageAnalysis::is_recursive
bool is_recursive
Definition: cpp_helpers.h:513
google::protobuf::compiler::cpp::Formatter
Definition: cpp_helpers.h:637
google::protobuf::compiler::cpp::NamespaceOpener::printer_
io::Printer * printer_
Definition: cpp_helpers.h:743
google::protobuf::compiler::cpp::NamespaceOpener::name_stack_
std::vector< std::string > name_stack_
Definition: cpp_helpers.h:744
benchmarks.python.py_benchmark.args
args
Definition: py_benchmark.py:24
google::protobuf::compiler::cpp::FieldRangeImpl::Iterator::operator==
friend bool operator==(const Iterator &a, const Iterator &b)
Definition: cpp_helpers.h:767
options_
DebugStringOptions options_
Definition: src/google/protobuf/descriptor.cc:2410
google::protobuf::compiler::cpp::MaybeBootstrap
bool MaybeBootstrap(const Options &options, GeneratorContext *generator_context, bool bootstrap_flag, std::string *basename)
Definition: cpp_helpers.cc:1267


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