Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:12:47

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: kenton@google.com (Kenton Varda)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 //
0012 // Provides a mechanism for mapping a descriptor to the
0013 // fully-qualified name of the corresponding Java class.
0014 
0015 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
0016 #define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
0017 
0018 #include <string>
0019 
0020 #include "absl/strings/string_view.h"
0021 #include "google/protobuf/compiler/java/options.h"
0022 #include "google/protobuf/descriptor.h"
0023 
0024 // Must be last.
0025 #include "google/protobuf/port_def.inc"
0026 
0027 namespace google {
0028 namespace protobuf {
0029 
0030 class Descriptor;
0031 class EnumDescriptor;
0032 class FileDescriptor;
0033 class FieldDescriptor;
0034 class ServiceDescriptor;
0035 
0036 namespace compiler {
0037 namespace java {
0038 
0039 // Requires:
0040 //   descriptor != NULL
0041 //
0042 // Returns:
0043 //   The fully-qualified Java class name.
0044 PROTOC_EXPORT std::string ClassName(const Descriptor* descriptor);
0045 
0046 // Requires:
0047 //   descriptor != NULL
0048 //
0049 // Returns:
0050 //   The fully-qualified Java class name.
0051 PROTOC_EXPORT std::string ClassName(const EnumDescriptor* descriptor);
0052 
0053 // Requires:
0054 //   descriptor != NULL
0055 //
0056 // Returns:
0057 //   The fully-qualified Java class name.
0058 PROTOC_EXPORT std::string ClassName(const FileDescriptor* descriptor);
0059 
0060 // Requires:
0061 //   descriptor != NULL
0062 //
0063 // Returns:
0064 //   The fully-qualified Java class name.
0065 PROTOC_EXPORT std::string ClassName(const ServiceDescriptor* descriptor);
0066 
0067 // Requires:
0068 //   descriptor != NULL
0069 //
0070 // Returns:
0071 //   Java package name.
0072 PROTOC_EXPORT std::string FileJavaPackage(const FileDescriptor* descriptor,
0073                                           Options options = {});
0074 
0075 // Requires:
0076 //   descriptor != NULL
0077 //
0078 // Returns:
0079 //   Java package directory.
0080 PROTOC_EXPORT std::string JavaPackageDirectory(const FileDescriptor* file);
0081 
0082 // Requires:
0083 //   descriptor != NULL
0084 //
0085 // Returns:
0086 //   The unqualified Java class name.
0087 PROTOC_EXPORT std::string FileClassName(const FileDescriptor* file);
0088 
0089 // Requires:
0090 //   descriptor != NULL
0091 // Returns:
0092 //   Capitalized camel case field name.
0093 PROTOC_EXPORT std::string CapitalizedFieldName(const FieldDescriptor* field);
0094 
0095 // Requires:
0096 //   descriptor != NULL
0097 // Returns:
0098 //   Capitalized camel case oneof name.
0099 PROTOC_EXPORT std::string CapitalizedOneofName(const OneofDescriptor* oneof);
0100 
0101 // Returns:
0102 //   Converts a name to camel-case. If cap_first_letter is true, capitalize the
0103 //   first letter.
0104 PROTOC_EXPORT std::string UnderscoresToCamelCase(absl::string_view input,
0105                                                  bool cap_next_letter);
0106 // Requires:
0107 //   field != NULL
0108 // Returns:
0109 //   Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
0110 //   "fooBarBaz" or "FooBarBaz", respectively.
0111 PROTOC_EXPORT std::string UnderscoresToCamelCase(const FieldDescriptor* field);
0112 
0113 // Requires:
0114 //   method != NULL
0115 // Returns:
0116 //   Similar, but for method names.  (Typically, this merely has the effect
0117 //   of lower-casing the first letter of the name.)
0118 PROTOC_EXPORT std::string UnderscoresToCamelCase(
0119     const MethodDescriptor* method);
0120 
0121 // Requires:
0122 //   field != NULL
0123 // Returns:
0124 //   Same as UnderscoresToCamelCase, but checks for reserved keywords
0125 PROTOC_EXPORT std::string UnderscoresToCamelCaseCheckReserved(
0126     const FieldDescriptor* field);
0127 
0128 // Requires:
0129 //   field != NULL
0130 // Returns:
0131 //   Same as UnderscoresToCamelCase, but capitalizes the first letter
0132 PROTOC_EXPORT std::string UnderscoresToCapitalizedCamelCase(
0133     const FieldDescriptor* field);
0134 
0135 // Requires:
0136 //   descriptor != NULL
0137 // Returns:
0138 //   The unqualified Kotlin factory name.
0139 PROTOC_EXPORT std::string KotlinFactoryName(const Descriptor* descriptor);
0140 
0141 // Requires:
0142 //   descriptor != NULL
0143 // Returns:
0144 //   The fully qualified Kotlin factory name.
0145 PROTOC_EXPORT std::string FullyQualifiedKotlinFactoryName(
0146     const Descriptor* descriptor);
0147 
0148 // Requires:
0149 //   descriptor != NULL
0150 // Returns:
0151 //   The fully qualified Kotlin extensions class name. "Extensions" in this case
0152 //   refers to "Extensions" the Kotlin concept, not "Extensions" the Protobuf
0153 //   concept
0154 PROTOC_EXPORT std::string KotlinExtensionsClassName(
0155     const Descriptor* descriptor);
0156 
0157 
0158 }  // namespace java
0159 }  // namespace compiler
0160 }  // namespace protobuf
0161 }  // namespace google
0162 
0163 #include "google/protobuf/port_undef.inc"
0164 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__