• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CPP_GENERATOR_H
20 #define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
21 
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
24 // FlatBuffers.
25 
26 #include <memory>
27 #include <vector>
28 
29 #include "src/compiler/config.h"
30 #include "src/compiler/schema_interface.h"
31 
32 #ifndef GRPC_CUSTOM_STRING
33 #include <string>
34 #define GRPC_CUSTOM_STRING std::string
35 #endif
36 
37 namespace grpc {
38 
39 typedef GRPC_CUSTOM_STRING string;
40 
41 }  // namespace grpc
42 
43 namespace grpc_cpp_generator {
44 
45 // Contains all the parameters that are parsed from the command line.
46 struct Parameters {
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;
59 };
60 
61 // Return the prologue of the generated header file.
62 grpc::string GetHeaderPrologue(grpc_generator::File* file,
63                                const Parameters& params);
64 
65 // Return the includes needed for generated header file.
66 grpc::string GetHeaderIncludes(grpc_generator::File* file,
67                                const Parameters& params);
68 
69 // Return the includes needed for generated source file.
70 grpc::string GetSourceIncludes(grpc_generator::File* file,
71                                const Parameters& params);
72 
73 // Return the epilogue of the generated header file.
74 grpc::string GetHeaderEpilogue(grpc_generator::File* file,
75                                const Parameters& params);
76 
77 // Return the prologue of the generated source file.
78 grpc::string GetSourcePrologue(grpc_generator::File* file,
79                                const Parameters& params);
80 
81 // Return the services for generated header file.
82 grpc::string GetHeaderServices(grpc_generator::File* file,
83                                const Parameters& params);
84 
85 // Return the services for generated source file.
86 grpc::string GetSourceServices(grpc_generator::File* file,
87                                const Parameters& params);
88 
89 // Return the epilogue of the generated source file.
90 grpc::string GetSourceEpilogue(grpc_generator::File* file,
91                                const Parameters& params);
92 
93 // Return the prologue of the generated mock file.
94 grpc::string GetMockPrologue(grpc_generator::File* file,
95                              const Parameters& params);
96 
97 // Return the includes needed for generated mock file.
98 grpc::string GetMockIncludes(grpc_generator::File* file,
99                              const Parameters& params);
100 
101 // Return the services for generated mock file.
102 grpc::string GetMockServices(grpc_generator::File* file,
103                              const Parameters& params);
104 
105 // Return the epilogue of generated mock file.
106 grpc::string GetMockEpilogue(grpc_generator::File* file,
107                              const Parameters& params);
108 
109 // Return the prologue of the generated mock file.
110 grpc::string GetMockPrologue(grpc_generator::File* file,
111                              const Parameters& params);
112 
113 // Return the includes needed for generated mock file.
114 grpc::string GetMockIncludes(grpc_generator::File* file,
115                              const Parameters& params);
116 
117 // Return the services for generated mock file.
118 grpc::string GetMockServices(grpc_generator::File* file,
119                              const Parameters& params);
120 
121 // Return the epilogue of generated mock file.
122 grpc::string GetMockEpilogue(grpc_generator::File* file,
123                              const Parameters& params);
124 
125 }  // namespace grpc_cpp_generator
126 
127 #endif  // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
128