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 SRC_COMPILER_CONFIG_H
20 #define SRC_COMPILER_CONFIG_H
21
22 #include <grpcpp/impl/codegen/config_protobuf.h>
23
24 #ifndef GRPC_CUSTOM_CODEGENERATOR
25 #include <google/protobuf/compiler/code_generator.h>
26 #define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator
27 #define GRPC_CUSTOM_GENERATORCONTEXT \
28 ::google::protobuf::compiler::GeneratorContext
29 #endif
30
31 #ifndef GRPC_CUSTOM_PRINTER
32 #include <google/protobuf/io/coded_stream.h>
33 #include <google/protobuf/io/printer.h>
34 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
35 #define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer
36 #define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream
37 #define GRPC_CUSTOM_STRINGOUTPUTSTREAM \
38 ::google::protobuf::io::StringOutputStream
39 #endif
40
41 #ifndef GRPC_CUSTOM_PLUGINMAIN
42 #include <google/protobuf/compiler/plugin.h>
43 #define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain
44 #endif
45
46 #ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER
47 #include <google/protobuf/compiler/code_generator.h>
48 #define GRPC_CUSTOM_PARSEGENERATORPARAMETER \
49 ::google::protobuf::compiler::ParseGeneratorParameter
50 #endif
51
52 #ifndef GRPC_CUSTOM_STRING
53 #include <string>
54 #define GRPC_CUSTOM_STRING std::string
55 #endif
56
57 namespace grpc {
58
59 typedef GRPC_CUSTOM_STRING string;
60
61 namespace protobuf {
62
63 namespace compiler {
64 typedef GRPC_CUSTOM_CODEGENERATOR CodeGenerator;
65 typedef GRPC_CUSTOM_GENERATORCONTEXT GeneratorContext;
PluginMain(int argc,char * argv[],const CodeGenerator * generator)66 static inline int PluginMain(int argc, char* argv[],
67 const CodeGenerator* generator) {
68 return GRPC_CUSTOM_PLUGINMAIN(argc, argv, generator);
69 }
ParseGeneratorParameter(const string & parameter,std::vector<std::pair<string,string>> * options)70 static inline void ParseGeneratorParameter(
71 const string& parameter, std::vector<std::pair<string, string> >* options) {
72 GRPC_CUSTOM_PARSEGENERATORPARAMETER(parameter, options);
73 }
74
75 } // namespace compiler
76 namespace io {
77 typedef GRPC_CUSTOM_PRINTER Printer;
78 typedef GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream;
79 typedef GRPC_CUSTOM_STRINGOUTPUTSTREAM StringOutputStream;
80 } // namespace io
81 } // namespace protobuf
82 } // namespace grpc
83
84 namespace grpc_cpp_generator {
85
86 static const char* const kCppGeneratorMessageHeaderExt = ".pb.h";
87 static const char* const kCppGeneratorServiceHeaderExt = ".grpc.pb.h";
88
89 } // namespace grpc_cpp_generator
90
91 #endif // SRC_COMPILER_CONFIG_H
92