webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
csharp_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_CSHARP_HELPERS_H__
36 #define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__
37 
38 #include <string>
44 
45 namespace google {
46 namespace protobuf {
47 namespace compiler {
48 namespace csharp {
49 
50 struct Options;
51 class FieldGeneratorBase;
52 
53 // TODO: start using this enum.
54 enum CSharpType {
67 };
68 
69 // Converts field type to corresponding C# type.
71 
72 std::string StripDotProto(const std::string& proto_file);
73 
74 // Gets unqualified name of the reflection class
76 
78 
80 
82 
84 
86 
88  bool cap_next_letter,
89  bool preserve_period);
90 
91 inline std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter) {
92  return UnderscoresToCamelCase(input, cap_next_letter, false);
93 }
94 
96 
97 // Note that we wouldn't normally want to export this (we're not expecting
98 // it to be used outside libprotoc itself) but this exposes it for testing.
99 std::string LIBPROTOBUF_EXPORT GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name);
100 
101 // TODO(jtattermusch): perhaps we could move this to strutil
103 
105 
107  int fieldOrdinal,
108  const Options* options);
109 
110 // Determines whether the given message is a map entry message,
111 // i.e. one implicitly created by protoc due to a map<key, value> field.
112 inline bool IsMapEntryMessage(const Descriptor* descriptor) {
113  return descriptor->options().map_entry();
114 }
115 
116 // Determines whether we're generating code for the proto representation of
117 // descriptors etc, for use in the runtime. This is the only type which is
118 // allowed to use proto2 syntax, and it generates internal classes.
119 inline bool IsDescriptorProto(const FileDescriptor* descriptor) {
120  return descriptor->name() == "google/protobuf/descriptor.proto";
121 }
122 
123 inline bool IsWrapperType(const FieldDescriptor* descriptor) {
124  return descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
125  descriptor->message_type()->file()->name() == "google/protobuf/wrappers.proto";
126 }
127 
128 } // namespace csharp
129 } // namespace compiler
130 } // namespace protobuf
131 } // namespace google
132 #endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__
Definition: upb.c:6604
std::string GetClassName(const Descriptor *descriptor)
Definition: csharp_helpers.cc:305
Definition: descriptor.h:801
const FieldDescriptor * field
Definition: parser_unittest.cc:2279
std::string UnderscoresToPascalCase(const std::string &input)
Definition: csharp_helpers.cc:177
std::string GetEnumValueName(const std::string &enum_name, const std::string &enum_value_name)
Definition: csharp_helpers.cc:268
options
Definition: CodeGeneratorReplayInputs.py:1046
const MessageOptions & options() const
std::string StripDotProto(const std::string &proto_file)
Definition: csharp_helpers.cc:109
const Descriptor * descriptor
Definition: descriptor.cc:271
FieldGeneratorBase * CreateFieldGenerator(const FieldDescriptor *descriptor, int fieldOrdinal, const Options *options)
Definition: csharp_helpers.cc:453
std::string GetFieldName(const FieldDescriptor *descriptor)
Definition: csharp_helpers.cc:316
Definition: descriptor.h:1156
Definition: descriptor.h:172
bool IsMapEntryMessage(const Descriptor *descriptor)
Definition: csharp_helpers.h:112
std::string GetReflectionClassUnqualifiedName(const FileDescriptor *descriptor)
Definition: csharp_helpers.cc:130
Definition: descriptor.h:439
std::string GetFieldConstantName(const FieldDescriptor *field)
Definition: csharp_helpers.cc:324
std::string StringToBase64(const std::string &input)
Definition: csharp_helpers.cc:414
Type
Definition: descriptor.h:443
std::string GetPropertyName(const FieldDescriptor *descriptor)
Definition: csharp_helpers.cc:328
Definition: __init__.py:1
EGLenum type
Definition: eglext.h:63
GLsizei const GLchar *const * string
Definition: gl2.h:479
bool IsWrapperType(const FieldDescriptor *descriptor)
Definition: csharp_helpers.h:123
std::string FileDescriptorToBase64(const FileDescriptor *descriptor)
Definition: csharp_helpers.cc:445
const string & name() const
CSharpType
Definition: csharp_helpers.h:54
#define LIBPROTOBUF_EXPORT
Definition: port.h:97
bool map_entry() const
Definition: descriptor.pb.h:6368
std::string UnderscoresToCamelCase(const std::string &input, bool cap_next_letter, bool preserve_period)
Definition: csharp_helpers.cc:137
Definition: csharp_options.h:43
Definition: gflags_completions.h:115
string input
Definition: tokenizer_unittest.cc:198
int GetFixedSize(FieldDescriptor::Type type)
Definition: csharp_helpers.cc:381
const Descriptor * message_type() const
CSharpType GetCSharpType(FieldDescriptor::Type type)
Definition: csharp_helpers.cc:63
bool IsDescriptorProto(const FileDescriptor *descriptor)
Definition: csharp_helpers.h:119
const FileDescriptor * file() const