protobuf/src/google/protobuf/compiler/java/java_context.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 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
32 #define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
33 
34 #include <map>
35 #include <memory>
36 #include <vector>
37 
38 #include <google/protobuf/stubs/common.h>
39 #include <google/protobuf/compiler/java/java_options.h>
40 
41 namespace google {
42 namespace protobuf {
43 class FileDescriptor;
44 class FieldDescriptor;
45 class OneofDescriptor;
46 class Descriptor;
47 class EnumDescriptor;
48 namespace compiler {
49 namespace java {
50 class ClassNameResolver; // name_resolver.h
51 }
52 } // namespace compiler
53 } // namespace protobuf
54 } // namespace google
55 
56 namespace google {
57 namespace protobuf {
58 namespace compiler {
59 namespace java {
60 
61 struct FieldGeneratorInfo;
62 struct OneofGeneratorInfo;
63 // A context object holds the information that is shared among all code
64 // generators.
65 class Context {
66  public:
67  Context(const FileDescriptor* file, const Options& options);
68  ~Context();
69 
70  // Get the name resolver associated with this context. The resolver
71  // can be used to map descriptors to Java class names.
72  ClassNameResolver* GetNameResolver() const;
73 
74  // Get the FieldGeneratorInfo for a given field.
75  const FieldGeneratorInfo* GetFieldGeneratorInfo(
76  const FieldDescriptor* field) const;
77 
78  // Get the OneofGeneratorInfo for a given oneof.
79  const OneofGeneratorInfo* GetOneofGeneratorInfo(
80  const OneofDescriptor* oneof) const;
81 
82  const Options& options() const { return options_; }
83 
84  // Enforces all the files (including transitive dependencies) to use
85  // LiteRuntime.
86 
87  bool EnforceLite() const { return options_.enforce_lite; }
88 
89  // Does this message class have generated parsing, serialization, and other
90  // standard methods for which reflection-based fallback implementations exist?
91  bool HasGeneratedMethods(const Descriptor* descriptor) const;
92 
93  private:
97  const std::vector<const FieldDescriptor*>& fields);
98 
99  std::unique_ptr<ClassNameResolver> name_resolver_;
100  std::map<const FieldDescriptor*, FieldGeneratorInfo>
102  std::map<const OneofDescriptor*, OneofGeneratorInfo>
106 };
107 
108 } // namespace java
109 } // namespace compiler
110 } // namespace protobuf
111 } // namespace google
112 
113 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
google::protobuf::compiler::java::Context::options
const Options & options() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h:82
google::protobuf::compiler::java::Context::InitializeFieldGeneratorInfoForFields
void InitializeFieldGeneratorInfoForFields(const std::vector< const FieldDescriptor * > &fields)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:125
google::protobuf::compiler::java::Context::EnforceLite
bool EnforceLite() const
Definition: protobuf/src/google/protobuf/compiler/java/java_context.h:87
google::protobuf::compiler::java::Options
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_options.h:42
FileDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:128
google::protobuf::compiler::java::Context
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h:65
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::compiler::java::Context::GetFieldGeneratorInfo
const FieldGeneratorInfo * GetFieldGeneratorInfo(const FieldDescriptor *field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:169
EnumDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:143
google::protobuf::compiler::java::Context::InitializeFieldGeneratorInfo
void InitializeFieldGeneratorInfo(const FileDescriptor *file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:99
google::protobuf::compiler::java::Context::Context
Context(const FileDescriptor *file, const Options &options)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:45
google::protobuf::compiler::java::Context::HasGeneratedMethods
bool HasGeneratedMethods(const Descriptor *descriptor) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:193
java
google::protobuf::compiler::java::Context::name_resolver_
std::unique_ptr< ClassNameResolver > name_resolver_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h:99
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
google::protobuf::compiler::java::Context::~Context
~Context()
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:50
google::protobuf::compiler::java::Context::InitializeFieldGeneratorInfoForMessage
void InitializeFieldGeneratorInfoForMessage(const Descriptor *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:105
OneofDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:138
google::protobuf::compiler::java::Context::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context)
google::protobuf::compiler::java::Context::options_
Options options_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h:104
profile_analyzer.fields
list fields
Definition: profile_analyzer.py:266
google::protobuf::compiler::java::Context::oneof_generator_info_map_
std::map< const OneofDescriptor *, OneofGeneratorInfo > oneof_generator_info_map_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h:103
google::protobuf::Descriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:231
google::protobuf::compiler::java::Context::field_generator_info_map_
std::map< const FieldDescriptor *, FieldGeneratorInfo > field_generator_info_map_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h:101
google::protobuf::FileDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1320
google::protobuf::compiler::java::Options::enforce_lite
bool enforce_lite
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_options.h:56
google::protobuf::compiler::java::Context::GetNameResolver
ClassNameResolver * GetNameResolver() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:52
google::protobuf::compiler::java::Context::GetOneofGeneratorInfo
const OneofGeneratorInfo * GetOneofGeneratorInfo(const OneofDescriptor *oneof) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc:180
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
compiler
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc:21
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:08