Go to the documentation of this file.
35 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
36 #define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
53 #include <google/protobuf/port_def.inc>
61 return "PROTOBUF_NAMESPACE_ID";
65 return options.opensource_runtime ?
"GOOGLE_PROTOBUF" :
"GOOGLE_PROTOBUF";
70 return deprecated ?
"PROTOBUF_DEPRECATED " :
"";
79 std::map<std::string, std::string>* variables);
183 return field->is_extension() ?
field->extension_scope()
184 :
field->containing_type();
245 options.opensource_runtime =
false;
298 if (
field->options().weak()) {
328 return field->options().lazy() && !
field->is_repeated() &&
388 return !
options.opensource_runtime &&
390 !
options.lite_implicit_weak_fields &&
391 descriptor->options().message_set_wire_format() &&
392 descriptor->full_name() ==
"google.protobuf.bridge.MessageSet";
397 return !
options.opensource_runtime &&
399 !
options.lite_implicit_weak_fields &&
400 file->
name() ==
"net/proto2/bridge/proto/message_set.proto";
411 bool cap_next_letter);
437 field->message_type()->file() !=
field->file();
445 return "_i_give_permission_to_break_this_code_default_" +
FieldName(
field) +
459 file->
name() + (pb_h &&
options.proto_h ?
".pb.h" :
""));
474 return "GOOGLE_PROTOBUF_INCLUDED_" + filename_identifier;
480 switch (
options.enforce_mode) {
493 std::vector<const Descriptor*>* result);
496 std::vector<const Descriptor*> result;
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());
561 std::vector<const FieldDescriptor*>*
fields);
563 std::vector<const FieldDescriptor*>*
fields);
567 for (
int i = 0;
i <
d->nested_type_count();
i++) {
570 for (
int i = 0;
i <
d->extension_count();
i++) {
573 for (
int i = 0;
i <
d->field_count();
i++) {
580 for (
int i = 0;
i <
d->message_type_count();
i++) {
583 for (
int i = 0;
i <
d->extension_count();
i++) {
589 std::vector<const Descriptor*>*
types);
597 MessageSCCAnalyzer* scc_analyzer);
641 const std::map<std::string, std::string>& vars)
642 : printer_(printer), vars_(vars) {}
644 template <
typename T>
649 void AddMap(
const std::map<std::string, std::string>& vars) {
650 for (
const auto& keyval : vars) vars_[keyval.first] = keyval.second;
653 template <
typename...
Args>
655 printer_->FormatInternal({ToString(
args)...}, vars_,
format);
658 void Indent()
const { printer_->Indent(); }
670 std::map<std::string, std::string>
vars_;
675 std::map<std::string, std::string>
vars_;
679 template <
typename I,
typename =
typename std::enable_if<
693 template <
typename Descriptor>
695 std::vector<int>
path;
698 for (
int i = 0;
i <
path.size(); ++
i) {
702 return annotation.SerializeAsString();
709 : printer_(
format.printer()) {}
717 std::vector<std::string> new_stack_ =
719 int len = std::min(name_stack_.size(), new_stack_.size());
721 while (common_idx <
len) {
722 if (name_stack_[common_idx] != new_stack_[common_idx])
break;
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");
729 printer_->Print(
"} // namespace $ns$\n",
"ns", name_stack_[
i]);
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");
737 printer_->Print(
"namespace $ns$ {\n",
"ns", name_stack_[
i]);
758 template <
typename T>
769 return a.idx ==
b.idx;
790 template <
typename T>
805 return a.idx ==
b.idx;
830 MessageSCCAnalyzer* scc_analyzer,
io::Printer* printer);
837 #include <google/protobuf/port_undef.inc>
839 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
bool IsBootstrapProto(const Options &options, const FileDescriptor *file)
bool IsAnyMessage(const FileDescriptor *descriptor, const Options &options)
GLuint const GLchar * name
bool HasGeneratedMethods(const FileDescriptor *file, const Options &options)
bool IsStringOrMessage(const FieldDescriptor *field)
NamespaceOpener(const Formatter &format)
static constexpr OptimizeMode LITE_RUNTIME
bool IsCord(const FieldDescriptor *field, const Options &options)
std::string FieldName(const FieldDescriptor *field)
std::string ProtobufNamespace(const Options &options)
string StrCat(const AlphaNum &a, const AlphaNum &b)
std::string StripProto(const std::string &filename)
GLsizei GLenum GLenum * types
FieldRangeImpl< T > FieldRange(const T *desc)
NamespaceOpener(const std::string &name, const Formatter &format)
def parameters(*testcases)
std::string FieldConstantName(const FieldDescriptor *field)
static bool HasEnumDefinitions(const Descriptor *message_type)
static bool HasLazyFields(const Descriptor *descriptor, const Options &options)
std::string GetUtf8Suffix(const FieldDescriptor *field, const Options &options)
std::string QualifiedClassName(const Descriptor *d, const Options &options)
void add_path(::PROTOBUF_NAMESPACE_ID::int32 value)
void set_source_file(const std::string &value)
bool IsStringInlined(const FieldDescriptor *descriptor, const Options &options)
bool HasPreservingUnknownEnumSemantics(const FieldDescriptor *field)
std::string SuperClassName(const Descriptor *descriptor, const Options &options)
GLsizei const GLchar *const * string
int EstimateAlignmentSize(const FieldDescriptor *field)
std::string MakeDefaultName(const FieldDescriptor *field)
friend bool operator!=(const Iterator &a, const Iterator &b)
std::string EnumValueName(const EnumValueDescriptor *enum_value)
string UniqueName(const std::string &name, const std::string &filename, const Options &options)
FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor *file, const Options &options)
#define T(upbtypeconst, upbtype, ctype, default_value)
const Descriptor * descriptor
std::string MessageCreateFunction(const Descriptor *d)
const char * DeclaredTypeMethodName(FieldDescriptor::Type type)
std::string ReferenceFunctionName(const Descriptor *descriptor, const Options &options)
bool cc_generic_services() const
static bool HasMapFields(const Descriptor *descriptor)
void FlattenMessagesInFile(const FileDescriptor *file, std::vector< const Descriptor * > *result)
bool IsWeak(const FieldDescriptor *field, const Options &options)
const Descriptor * GetRepresentative() const
bool HasWeakFields(const Descriptor *descriptor, const Options &options)
GLboolean GLboolean GLboolean b
void GenerateUtf8CheckCodeForString(const FieldDescriptor *field, const Options &options, bool for_parse, const char *parameters, const Formatter &format)
std::string FileDllExport(const FileDescriptor *file, const Options &options)
bool constructor_requires_initialization
std::forward_iterator_tag iterator_category
static bool HasStringPieceFields(const Descriptor *descriptor, const Options &options)
bool UsingImplicitWeakFields(const FileDescriptor *file, const Options &options)
std::string SafeFunctionName(const Descriptor *descriptor, const FieldDescriptor *field, const std::string &prefix)
const Descriptor * descriptor
friend bool operator!=(const Iterator &a, const Iterator &b)
GLsizei const GLchar ** path
static const char prefix[]
FieldOptions::CType EffectiveStringCType(const FieldDescriptor *field, const Options &options)
bool cc_enable_arenas() const
bool IsLazy(const FieldDescriptor *field, const Options &options)
GLint GLint GLsizei GLint GLenum format
const Descriptor * FieldScope(const FieldDescriptor *field)
std::string ResolveKeyword(const string &name)
bool SupportsArenas(const FileDescriptor *file)
bool IsImplicitWeakField(const FieldDescriptor *field, const Options &options, MessageSCCAnalyzer *scc_analyzer)
const OneofDescriptor * oneof_decl(int index) const
std::string QualifiedFileLevelSymbol(const FileDescriptor *file, const std::string &name, const Options &options)
bool IsMapEntryMessage(const Descriptor *descriptor)
std::string FieldMessageTypeName(const FieldDescriptor *field, const Options &options)
int oneof_decl_count() const
OneOfRangeImpl OneOfRange(const Descriptor *desc)
std::forward_iterator_tag iterator_category
std::string DefaultInstanceType(const Descriptor *descriptor, const Options &options)
void ChangeTo(const std::string &name)
std::string DescriptorTableName(const FileDescriptor *file, const Options &options)
bool IsStringPiece(const FieldDescriptor *field, const Options &options)
std::string DefaultValue(const FieldDescriptor *field)
std::string DeprecatedAttribute(const Options &options, bool deprecated)
bool UseUnknownFieldSet(const FileDescriptor *file, const Options &options)
const FileOptions & options() const
void SetCommonVars(const Options &options, std::map< std::string, std::string > *variables)
bool GetBootstrapBasename(const Options &options, const std::string &basename, std::string *bootstrap_basename)
friend bool operator==(const Iterator &a, const Iterator &b)
std::string IncludeGuard(const FileDescriptor *file, bool pb_h, const Options &options)
Options InternalRuntimeOptions()
std::string QualifiedDefaultInstanceName(const Descriptor *descriptor, const Options &options)
std::map< const SCC *, MessageAnalysis > analysis_cache_
bool IsCrossFileMessage(const FieldDescriptor *field)
bool HasDescriptorMethods(const FileDescriptor *file, const Options &options)
const FieldDescriptor * field
void ListAllFields(const Descriptor *d, std::vector< const FieldDescriptor * > *fields)
PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode optimize_for() const
MessageSCCAnalyzer(const Options &options)
const SETUP_TEARDOWN_TESTCONTEXT char * key
static constexpr OptimizeMode SPEED
#define GOOGLE_CHECK(EXPRESSION)
static bool HasCordFields(const Descriptor *descriptor, const Options &options)
const char kThickSeparator[]
std::string Int32ToString(int number)
bool HasRequiredFields(const Descriptor *descriptor)
std::string Namespace(const std::string &package)
const std::string & name() const
static const upb_fielddef fields[107]
bool IsWellKnownMessage(const FileDescriptor *file)
std::vector< const Descriptor * > operator()(const Descriptor *desc) const
std::string SccInfoSymbol(const SCC *scc, const Options &options)
bool HasGenericServices(const FileDescriptor *file, const Options &options)
const SCC * GetSCC(const Descriptor *descriptor)
std::string FilenameIdentifier(const std::string &filename)
std::string DefaultInstanceName(const Descriptor *descriptor, const Options &options)
VALUE enum_descriptor(VALUE self)
void GenerateParserLoop(const Descriptor *descriptor, int num_hasbits, const Options &options, MessageSCCAnalyzer *scc_analyzer, io::Printer *printer)
void GenerateUtf8CheckCodeForCord(const FieldDescriptor *field, const Options &options, bool for_parse, const char *parameters, const Formatter &format)
int service_count() const
static bool HasExtensionsOrExtendableMessage(const Descriptor *descriptor)
std::string EscapeTrigraphs(const std::string &to_escape)
std::vector< string > Split(const string &full, const char *delim, bool skip_empty=true)
std::string ClassName(const Descriptor *descriptor)
static bool HasRepeatedFields(const Descriptor *descriptor)
std::string UnderscoresToCamelCase(const std::string &input, bool cap_next_letter)
const char * PrimitiveTypeName(FieldDescriptor::CppType type)
static constexpr CType STRING_PIECE
void ForEachField(const Descriptor *d, T &&func)
void ListAllTypesForServices(const FileDescriptor *fd, std::vector< const Descriptor * > *types)
static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor *field, const Options &options)
bool PublicUnknownFieldsAccessors(const Descriptor *message)
SCCAnalyzer< DepsGenerator > analyzer_
bool HasFieldPresence(const FileDescriptor *file)
std::string MacroPrefix(const Options &options)
bool IsProto2MessageSet(const Descriptor *descriptor, const Options &options)
GLsizei const GLfloat * value
const char kThinSeparator[]
static constexpr OptimizeMode CODE_SIZE
bool IsProto2MessageSetFile(const FileDescriptor *file, const Options &options)
static constexpr CType CORD
bool HasFastArraySerialization(const FileDescriptor *file, const Options &options)
GLboolean GLboolean GLboolean GLboolean a
bool CanInitializeByZeroing(const FieldDescriptor *field)
std::string Int64ToString(const std::string ¯o_prefix, int64 number)
GLenum GLuint GLenum GLsizei const GLchar * message
std::vector< std::string > name_stack_
friend bool operator==(const Iterator &a, const Iterator &b)
DebugStringOptions options_
bool MaybeBootstrap(const Options &options, GeneratorContext *generator_context, bool bootstrap_flag, std::string *basename)
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:49