3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
20 #define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
22 // cpp_generator.h/.cc do not directly depend on GRPC/ProtoBuf, such that they
23 // can be used to generate code for other serialization systems, such as
29 #include "src/compiler/config.h"
30 #include "src/compiler/schema_interface.h"
32 #ifndef GRPC_CUSTOM_STRING
34 #define GRPC_CUSTOM_STRING std::string
39 typedef GRPC_CUSTOM_STRING string;
43 namespace grpc_cpp_generator {
45 // Contains all the parameters that are parsed from the command line.
47 // Puts the service into a namespace
48 grpc::string services_namespace;
49 // Use system includes (<>) or local includes ("")
50 bool use_system_headers;
51 // Prefix to any grpc include
52 grpc::string grpc_search_path;
53 // Generate Google Mock code to facilitate unit testing.
54 bool generate_mock_code;
55 // Google Mock search path, when non-empty, local includes will be used.
56 grpc::string gmock_search_path;
57 // *EXPERIMENTAL* Additional include files in grpc.pb.h
58 std::vector<grpc::string> additional_header_includes;
61 // Return the prologue of the generated header file.
62 grpc::string GetHeaderPrologue(grpc_generator::File* file,
63 const Parameters& params);
65 // Return the includes needed for generated header file.
66 grpc::string GetHeaderIncludes(grpc_generator::File* file,
67 const Parameters& params);
69 // Return the includes needed for generated source file.
70 grpc::string GetSourceIncludes(grpc_generator::File* file,
71 const Parameters& params);
73 // Return the epilogue of the generated header file.
74 grpc::string GetHeaderEpilogue(grpc_generator::File* file,
75 const Parameters& params);
77 // Return the prologue of the generated source file.
78 grpc::string GetSourcePrologue(grpc_generator::File* file,
79 const Parameters& params);
81 // Return the services for generated header file.
82 grpc::string GetHeaderServices(grpc_generator::File* file,
83 const Parameters& params);
85 // Return the services for generated source file.
86 grpc::string GetSourceServices(grpc_generator::File* file,
87 const Parameters& params);
89 // Return the epilogue of the generated source file.
90 grpc::string GetSourceEpilogue(grpc_generator::File* file,
91 const Parameters& params);
93 // Return the prologue of the generated mock file.
94 grpc::string GetMockPrologue(grpc_generator::File* file,
95 const Parameters& params);
97 // Return the includes needed for generated mock file.
98 grpc::string GetMockIncludes(grpc_generator::File* file,
99 const Parameters& params);
101 // Return the services for generated mock file.
102 grpc::string GetMockServices(grpc_generator::File* file,
103 const Parameters& params);
105 // Return the epilogue of generated mock file.
106 grpc::string GetMockEpilogue(grpc_generator::File* file,
107 const Parameters& params);
109 // Return the prologue of the generated mock file.
110 grpc::string GetMockPrologue(grpc_generator::File* file,
111 const Parameters& params);
113 // Return the includes needed for generated mock file.
114 grpc::string GetMockIncludes(grpc_generator::File* file,
115 const Parameters& params);
117 // Return the services for generated mock file.
118 grpc::string GetMockServices(grpc_generator::File* file,
119 const Parameters& params);
121 // Return the epilogue of generated mock file.
122 grpc::string GetMockEpilogue(grpc_generator::File* file,
123 const Parameters& params);
125 } // namespace grpc_cpp_generator
127 #endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H