schema_interface.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_INTERNAL_COMPILER_SCHEMA_INTERFACE_H
20 #define GRPC_INTERNAL_COMPILER_SCHEMA_INTERFACE_H
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include "src/compiler/config.h"
27 
28 #ifdef GRPC_CUSTOM_STRING
29 #warning GRPC_CUSTOM_STRING is no longer supported. Please use std::string.
30 #endif
31 
32 namespace grpc {
33 
34 // Using grpc::string and grpc::to_string is discouraged in favor of
35 // std::string and std::to_string. This is only for legacy code using
36 // them explictly.
37 using std::string; // deprecated
38 using std::to_string; // deprecated
39 
40 } // namespace grpc
41 
42 namespace grpc_generator {
43 
44 // A common interface for objects having comments in the source.
45 // Return formatted comments to be inserted in generated code.
46 struct CommentHolder {
47  virtual ~CommentHolder() {}
48  virtual std::string GetLeadingComments(const std::string prefix) const = 0;
49  virtual std::string GetTrailingComments(const std::string prefix) const = 0;
50  virtual std::vector<std::string> GetAllComments() const = 0;
51 };
52 
53 // An abstract interface representing a method.
54 struct Method : public CommentHolder {
55  virtual ~Method() {}
56 
57  virtual std::string name() const = 0;
58 
59  virtual std::string input_type_name() const = 0;
60  virtual std::string output_type_name() const = 0;
61 
64  bool generate_in_pb2_grpc, std::string import_prefix,
65  const std::vector<std::string>& prefixes_to_filter) const = 0;
68  bool generate_in_pb2_grpc, std::string import_prefix,
69  const std::vector<std::string>& prefixes_to_filter) const = 0;
70 
71  virtual std::string get_input_type_name() const = 0;
72  virtual std::string get_output_type_name() const = 0;
73  virtual bool NoStreaming() const = 0;
74  virtual bool ClientStreaming() const = 0;
75  virtual bool ServerStreaming() const = 0;
76  virtual bool BidiStreaming() const = 0;
77 };
78 
79 // An abstract interface representing a service.
80 struct Service : public CommentHolder {
81  virtual ~Service() {}
82 
83  virtual std::string name() const = 0;
84 
85  virtual int method_count() const = 0;
86  virtual std::unique_ptr<const Method> method(int i) const = 0;
87 };
88 
89 struct Printer {
90  virtual ~Printer() {}
91 
92  virtual void Print(const std::map<std::string, std::string>& vars,
93  const char* template_string) = 0;
94  virtual void Print(const char* string) = 0;
95  virtual void PrintRaw(const char* string) = 0;
96  virtual void Indent() = 0;
97  virtual void Outdent() = 0;
98 };
99 
100 // An interface that allows the source generated to be output using various
101 // libraries/idls/serializers.
102 struct File : public CommentHolder {
103  virtual ~File() {}
104 
105  virtual std::string filename() const = 0;
106  virtual std::string filename_without_ext() const = 0;
107  virtual std::string package() const = 0;
108  virtual std::vector<std::string> package_parts() const = 0;
109  virtual std::string additional_headers() const = 0;
110  virtual std::vector<std::string> GetImportNames() const { return {}; }
111 
112  virtual int service_count() const = 0;
113  virtual std::unique_ptr<const Service> service(int i) const = 0;
114 
115  virtual std::unique_ptr<Printer> CreatePrinter(std::string* str) const = 0;
116 };
117 } // namespace grpc_generator
118 
119 #endif // GRPC_INTERNAL_COMPILER_SCHEMA_INTERFACE_H
grpc_generator::Method::get_module_and_message_path_output
virtual bool get_module_and_message_path_output(std::string *str, std::string generator_file_name, bool generate_in_pb2_grpc, std::string import_prefix, const std::vector< std::string > &prefixes_to_filter) const =0
xds_interop_client.str
str
Definition: xds_interop_client.py:487
grpc_generator::CommentHolder::GetTrailingComments
virtual std::string GetTrailingComments(const std::string prefix) const =0
grpc_generator::Service
Definition: schema_interface.h:80
grpc_generator::CommentHolder
Definition: schema_interface.h:46
grpc
Definition: grpcpp/alarm.h:33
grpc_generator::Method::name
virtual std::string name() const =0
grpc_python_generator::generator_file_name
std::string generator_file_name
Definition: src/compiler/python_generator.cc:55
grpc_generator::Printer::~Printer
virtual ~Printer()
Definition: schema_interface.h:90
grpc_generator::Printer::Print
virtual void Print(const std::map< std::string, std::string > &vars, const char *template_string)=0
grpc_generator::File
Definition: schema_interface.h:102
config.h
grpc_generator::Printer::Outdent
virtual void Outdent()=0
grpc_generator::Method::input_type_name
virtual std::string input_type_name() const =0
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_generator::Service::method
virtual std::unique_ptr< const Method > method(int i) const =0
grpc_generator::Method::get_output_type_name
virtual std::string get_output_type_name() const =0
grpc_generator::File::~File
virtual ~File()
Definition: schema_interface.h:103
grpc_generator::CommentHolder::GetLeadingComments
virtual std::string GetLeadingComments(const std::string prefix) const =0
grpc_generator::Method::~Method
virtual ~Method()
Definition: schema_interface.h:55
grpc_generator::Method::ServerStreaming
virtual bool ServerStreaming() const =0
grpc_generator::Printer::PrintRaw
virtual void PrintRaw(const char *string)=0
grpc_generator::Method
Definition: schema_interface.h:54
grpc_generator::CommentHolder::GetAllComments
virtual std::vector< std::string > GetAllComments() const =0
grpc_generator::Service::~Service
virtual ~Service()
Definition: schema_interface.h:81
grpc_generator::Method::ClientStreaming
virtual bool ClientStreaming() const =0
grpc_generator::Method::NoStreaming
virtual bool NoStreaming() const =0
grpc_generator::Printer::Indent
virtual void Indent()=0
grpc_generator::Method::BidiStreaming
virtual bool BidiStreaming() const =0
grpc_generator::Method::get_input_type_name
virtual std::string get_input_type_name() const =0
grpc_generator::Service::method_count
virtual int method_count() const =0
grpc_generator::File::GetImportNames
virtual std::vector< std::string > GetImportNames() const
Definition: schema_interface.h:110
grpc_generator::File::filename_without_ext
virtual std::string filename_without_ext() const =0
grpc_generator::File::package
virtual std::string package() const =0
generate_in_pb2_grpc
bool generate_in_pb2_grpc
Definition: python_private_generator.h:40
grpc_generator::File::additional_headers
virtual std::string additional_headers() const =0
grpc_generator::File::package_parts
virtual std::vector< std::string > package_parts() const =0
grpc_generator::CommentHolder::~CommentHolder
virtual ~CommentHolder()
Definition: schema_interface.h:47
grpc_generator::Printer
Definition: schema_interface.h:89
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
grpc_generator::Method::get_module_and_message_path_input
virtual bool get_module_and_message_path_input(std::string *str, std::string generator_file_name, bool generate_in_pb2_grpc, std::string import_prefix, const std::vector< std::string > &prefixes_to_filter) const =0
grpc_generator::File::CreatePrinter
virtual std::unique_ptr< Printer > CreatePrinter(std::string *str) const =0
grpc_generator::Service::name
virtual std::string name() const =0
grpc_generator::File::service
virtual std::unique_ptr< const Service > service(int i) const =0
grpc_generator::Method::output_type_name
virtual std::string output_type_name() const =0
grpc_generator::File::service_count
virtual int service_count() const =0
grpc_generator
Definition: generator_helpers.h:30
to_string
static bool to_string(zval *from)
Definition: protobuf/php/ext/google/protobuf/convert.c:333
grpc_generator::File::filename
virtual std::string filename() const =0


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:15