Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:57

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 C# class.
0014 
0015 #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
0016 #define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
0017 
0018 #include <string>
0019 
0020 #include "absl/strings/string_view.h"
0021 #include "google/protobuf/port_def.inc"
0022 
0023 namespace google {
0024 namespace protobuf {
0025 
0026 class Descriptor;
0027 class EnumDescriptor;
0028 class FileDescriptor;
0029 class ServiceDescriptor;
0030 
0031 namespace compiler {
0032 namespace csharp {
0033 
0034 // Requires:
0035 //   descriptor != NULL
0036 //
0037 // Returns:
0038 //   The namespace to use for given file descriptor.
0039 std::string PROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor);
0040 
0041 // Requires:
0042 //   descriptor != NULL
0043 //
0044 // Returns:
0045 //   The fully-qualified C# class name.
0046 std::string PROTOC_EXPORT GetClassName(const Descriptor* descriptor);
0047 
0048 // Requires:
0049 //   descriptor != NULL
0050 //
0051 // Returns:
0052 //   The fully-qualified C# enum class name.
0053 std::string GetClassName(const EnumDescriptor* descriptor);
0054 
0055 // Requires:
0056 //   descriptor != NULL
0057 //
0058 // Returns:
0059 //   The unqualified name of the C# class that provides access to the file
0060 //   descriptor. Proto compiler generates
0061 //   such class for each .proto file processed.
0062 std::string GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor);
0063 
0064 // Gets unqualified name of the extension class
0065 // Requires:
0066 //   descriptor != NULL
0067 //
0068 // Returns:
0069 //   The unqualified name of the generated C# extensions class that provide
0070 //   access to extensions. Proto compiler generates such class for each
0071 //   .proto file processed that contains extensions.
0072 std::string GetExtensionClassUnqualifiedName(const FileDescriptor* descriptor);
0073 
0074 // Requires:
0075 //   descriptor != NULL
0076 //
0077 // Returns:
0078 //   The fully-qualified name of the C# class that provides access to the file
0079 //   descriptor. Proto compiler generates such class for each .proto file
0080 //   processed.
0081 std::string PROTOC_EXPORT
0082 GetReflectionClassName(const FileDescriptor* descriptor);
0083 
0084 // Generates output file name for given file descriptor. If generate_directories
0085 // is true, the output file will be put under directory corresponding to file's
0086 // namespace. base_namespace can be used to strip some of the top level
0087 // directories. E.g. for file with namespace "Bar.Foo" and base_namespace="Bar",
0088 // the resulting file will be put under directory "Foo" (and not "Bar/Foo").
0089 //
0090 // Requires:
0091 //   descriptor != NULL
0092 //   error != NULL
0093 //
0094 //  Returns:
0095 //    The file name to use as output file for given file descriptor. In case
0096 //    of failure, this function will return empty string and error parameter
0097 //    will contain the error message.
0098 std::string PROTOC_EXPORT GetOutputFile(const FileDescriptor* descriptor,
0099                                         absl::string_view file_extension,
0100                                         bool generate_directories,
0101                                         absl::string_view base_namespace,
0102                                         std::string* error);
0103 
0104 std::string UnderscoresToPascalCase(absl::string_view input);
0105 
0106 // Note that we wouldn't normally want to export this (we're not expecting
0107 // it to be used outside libprotoc itself) but this exposes it for testing.
0108 std::string PROTOC_EXPORT UnderscoresToCamelCase(absl::string_view input,
0109                                                  bool cap_next_letter,
0110                                                  bool preserve_period);
0111 
0112 inline std::string UnderscoresToCamelCase(absl::string_view input,
0113                                           bool cap_next_letter) {
0114   return UnderscoresToCamelCase(input, cap_next_letter, false);
0115 }
0116 
0117 }  // namespace csharp
0118 }  // namespace compiler
0119 }  // namespace protobuf
0120 }  // namespace google
0121 
0122 #include "google/protobuf/port_undef.inc"
0123 
0124 #endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__