blob: a9af1a6794fa00fc26e898cc001a68bff131721d [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001#ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
2#define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
3
4// cpp_generator.h/.cc do not directly depend on GRPC/ProtoBuf, such that they
5// can be used to generate code for other serialization systems, such as
6// FlatBuffers.
7
8#include <memory>
9#include <vector>
10
Austin Schuhe89fa2d2019-08-14 20:24:23 -070011#include "src/compiler/schema_interface.h"
12
13#ifndef GRPC_CUSTOM_STRING
James Kuszmaul8e62b022022-03-22 09:33:25 -070014# include <string>
15# define GRPC_CUSTOM_STRING std::string
Austin Schuhe89fa2d2019-08-14 20:24:23 -070016#endif
17
18namespace grpc {
19
20typedef GRPC_CUSTOM_STRING string;
21
22} // namespace grpc
23
24namespace grpc_cpp_generator {
25
26// Contains all the parameters that are parsed from the command line.
27struct Parameters {
28 // Puts the service into a namespace
29 grpc::string services_namespace;
30 // Use system includes (<>) or local includes ("")
31 bool use_system_headers;
32 // Prefix to any grpc include
33 grpc::string grpc_search_path;
34 // Generate GMOCK code to facilitate unit testing.
35 bool generate_mock_code;
Austin Schuh2dd86a92022-09-14 21:19:23 -070036 // By default, use "_generated.h"
37 std::string message_header_extension;
Austin Schuhe89fa2d2019-08-14 20:24:23 -070038};
39
40// Return the prologue of the generated header file.
41grpc::string GetHeaderPrologue(grpc_generator::File *file,
42 const Parameters &params);
43
44// Return the includes needed for generated header file.
45grpc::string GetHeaderIncludes(grpc_generator::File *file,
46 const Parameters &params);
47
48// Return the includes needed for generated source file.
49grpc::string GetSourceIncludes(grpc_generator::File *file,
50 const Parameters &params);
51
52// Return the epilogue of the generated header file.
53grpc::string GetHeaderEpilogue(grpc_generator::File *file,
54 const Parameters &params);
55
56// Return the prologue of the generated source file.
57grpc::string GetSourcePrologue(grpc_generator::File *file,
58 const Parameters &params);
59
60// Return the services for generated header file.
61grpc::string GetHeaderServices(grpc_generator::File *file,
62 const Parameters &params);
63
64// Return the services for generated source file.
65grpc::string GetSourceServices(grpc_generator::File *file,
66 const Parameters &params);
67
68// Return the epilogue of the generated source file.
69grpc::string GetSourceEpilogue(grpc_generator::File *file,
70 const Parameters &params);
71
72// Return the prologue of the generated mock file.
73grpc::string GetMockPrologue(grpc_generator::File *file,
74 const Parameters &params);
75
76// Return the includes needed for generated mock file.
77grpc::string GetMockIncludes(grpc_generator::File *file,
78 const Parameters &params);
79
80// Return the services for generated mock file.
81grpc::string GetMockServices(grpc_generator::File *file,
82 const Parameters &params);
83
84// Return the epilogue of generated mock file.
85grpc::string GetMockEpilogue(grpc_generator::File *file,
86 const Parameters &params);
87
88// Return the prologue of the generated mock file.
89grpc::string GetMockPrologue(grpc_generator::File *file,
90 const Parameters &params);
91
92// Return the includes needed for generated mock file.
93grpc::string GetMockIncludes(grpc_generator::File *file,
94 const Parameters &params);
95
96// Return the services for generated mock file.
97grpc::string GetMockServices(grpc_generator::File *file,
98 const Parameters &params);
99
100// Return the epilogue of generated mock file.
101grpc::string GetMockEpilogue(grpc_generator::File *file,
102 const Parameters &params);
103
104} // namespace grpc_cpp_generator
105
106#endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H