Debian Codegraph @

src/compiler/cpp_generator.h

raw
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 <string>
28 #include <vector>
29
30 #include "src/compiler/config.h"
31 #include "src/compiler/schema_interface.h"
32
33 #ifdef GRPC_CUSTOM_STRING
34 #warning GRPC_CUSTOM_STRING is no longer supported. Please use std::string.
35 #endif
36
37 namespace grpc {
38
39 // Using grpc::string and grpc::to_string is discouraged in favor of
40 // std::string and std::to_string. This is only for legacy code using
41 // them explictly.
42 using std::string; // deprecated
43 using std::to_string; // deprecated
44
45 } // namespace grpc
46
47 namespace grpc_cpp_generator {
48
49 // Contains all the parameters that are parsed from the command line.
50 struct Parameters {
51 // Puts the service into a namespace
52 std::string services_namespace;
53 // Use system includes (<>) or local includes ("")
54 bool use_system_headers;
55 // Prefix to any grpc include
56 std::string grpc_search_path;
57 // Generate Google Mock code to facilitate unit testing.
58 bool generate_mock_code;
59 // Google Mock search path, when non-empty, local includes will be used.
60 std::string gmock_search_path;
61 // *EXPERIMENTAL* Additional include files in grpc.pb.h
62 std::vector<std::string> additional_header_includes;
63 // By default, use "pb.h"
64 std::string message_header_extension;
65 // Whether to include headers corresponding to imports in source file.
66 bool include_import_headers;
67 };
68
69 // Return the prologue of the generated header file.
70 std::string GetHeaderPrologue(grpc_generator::File* file,
71 const Parameters& params);
72
73 // Return the includes needed for generated header file.
74 std::string GetHeaderIncludes(grpc_generator::File* file,
75 const Parameters& params);
76
77 // Return the includes needed for generated source file.
78 std::string GetSourceIncludes(grpc_generator::File* file,
79 const Parameters& params);
80
81 // Return the epilogue of the generated header file.
82 std::string GetHeaderEpilogue(grpc_generator::File* file,
83 const Parameters& params);
84
85 // Return the prologue of the generated source file.
86 std::string GetSourcePrologue(grpc_generator::File* file,
87 const Parameters& params);
88
89 // Return the services for generated header file.
90 std::string GetHeaderServices(grpc_generator::File* file,
91 const Parameters& params);
92
93 // Return the services for generated source file.
94 std::string GetSourceServices(grpc_generator::File* file,
95 const Parameters& params);
96
97 // Return the epilogue of the generated source file.
98 std::string GetSourceEpilogue(grpc_generator::File* file,
99 const Parameters& params);
100
101 // Return the prologue of the generated mock file.
102 std::string GetMockPrologue(grpc_generator::File* file,
103 const Parameters& params);
104
105 // Return the includes needed for generated mock file.
106 std::string GetMockIncludes(grpc_generator::File* file,
107 const Parameters& params);
108
109 // Return the services for generated mock file.
110 std::string GetMockServices(grpc_generator::File* file,
111 const Parameters& params);
112
113 // Return the epilogue of generated mock file.
114 std::string GetMockEpilogue(grpc_generator::File* file,
115 const Parameters& params);
116
117 // Return the prologue of the generated mock file.
118 std::string GetMockPrologue(grpc_generator::File* file,
119 const Parameters& params);
120
121 // Return the includes needed for generated mock file.
122 std::string GetMockIncludes(grpc_generator::File* file,
123 const Parameters& params);
124
125 // Return the services for generated mock file.
126 std::string GetMockServices(grpc_generator::File* file,
127 const Parameters& params);
128
129 // Return the epilogue of generated mock file.
130 std::string GetMockEpilogue(grpc_generator::File* file,
131 const Parameters& params);
132
133 } // namespace grpc_cpp_generator
134
135 #endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H