21
21
#include " absl/strings/str_replace.h"
22
22
#include " generator/gapic_generator.h"
23
23
#include " internal/gapic_utils.h"
24
+ #include " internal/printer.h"
24
25
25
26
#include " google/api/client.pb.h"
26
27
@@ -69,7 +70,7 @@ std::vector<std::string> BuildNamespaces(
69
70
void PrintMethods (
70
71
pb::ServiceDescriptor const * service,
71
72
std::map<std::string, std::string> vars,
72
- pb::io:: Printer* p,
73
+ internal:: Printer& p,
73
74
char const * tmplt) {
74
75
for (int i = 0 ; i < service->method_count (); i++) {
75
76
const pb::MethodDescriptor* method = service->method (i);
@@ -81,7 +82,7 @@ void PrintMethods(
81
82
bool GenerateClientHeaderFile (
82
83
pb::ServiceDescriptor const * service,
83
84
std::map<std::string, std::string> const & vars,
84
- pb::io:: Printer* p,
85
+ internal:: Printer& p,
85
86
std::string * /* error */ ) {
86
87
auto includes = BuildHeaderIncludes (service);
87
88
auto namespaces = BuildNamespaces (service);
@@ -121,7 +122,7 @@ bool GenerateClientHeaderFile(
121
122
bool GenerateClientCCFile (
122
123
pb::ServiceDescriptor const * service,
123
124
std::map<std::string, std::string> const & vars,
124
- pb::io:: Printer* p,
125
+ internal:: Printer& p,
125
126
std::string * /* error */ ) {
126
127
auto includes = BuildCCIncludes (service);
127
128
auto namespaces = BuildNamespaces (service);
@@ -174,18 +175,14 @@ bool GapicGenerator::Generate(pb::FileDescriptor const* file,
174
175
service->full_name ());
175
176
176
177
std::string header_file_path = absl::StrCat (service_file_path, " .gapic.h" );
177
- std::unique_ptr<pb::io::ZeroCopyOutputStream> header_output (
178
- generator_context->Open (header_file_path));
179
- pb::io::Printer header_printer (header_output.get (), ' $' , NULL );
180
- if (!GenerateClientHeaderFile (service, vars, &header_printer, error)) {
178
+ internal::Printer header_printer (generator_context, header_file_path);
179
+ if (!GenerateClientHeaderFile (service, vars, header_printer, error)) {
181
180
return false ;
182
181
}
183
182
184
183
std::string cc_file_path = absl::StrCat (service_file_path, " .gapic.cc" );
185
- std::unique_ptr<pb::io::ZeroCopyOutputStream> cc_output (
186
- generator_context->Open (cc_file_path));
187
- pb::io::Printer cc_printer (cc_output.get (), ' $' , NULL );
188
- if (!GenerateClientCCFile (service, vars, &cc_printer, error)) {
184
+ internal::Printer cc_printer (generator_context, cc_file_path);
185
+ if (!GenerateClientCCFile (service, vars, cc_printer, error)) {
189
186
return false ;
190
187
}
191
188
}
0 commit comments