| 293 | } |
| 294 | |
| 295 | void ToolCodeRender::GenerateToolMainCpp(SyntaxTree *stree, FILE *write) { |
| 296 | char file_name[128]{'\0'}; |
| 297 | name_render_.GetToolMainFileName(stree->GetName(), file_name, sizeof(file_name)); |
| 298 | |
| 299 | string buffer; |
| 300 | name_render_.GetCopyright("phxrpc_pb2tool", stree->GetProtoFile(), &buffer, false); |
| 301 | |
| 302 | fprintf(write, "/* %s.cpp\n", file_name); |
| 303 | fprintf(write, "%s", buffer.c_str()); |
| 304 | fprintf(write, "*/\n"); |
| 305 | fprintf(write, "\n"); |
| 306 | |
| 307 | char tool_class[128]{'\0'}, tool_file[128]{'\0'}; |
| 308 | char tool_impl_class[128]{'\0'}, tool_impl_file[128]{'\0'}; |
| 309 | char client_class[128]{'\0'}, client_file[128]{'\0'}; |
| 310 | |
| 311 | name_render_.GetToolClassName(stree->GetName(), tool_class, sizeof(tool_class)); |
| 312 | name_render_.GetToolFileName(stree->GetName(), tool_file, sizeof(tool_file)); |
| 313 | name_render_.GetToolImplClassName(stree->GetName(), tool_impl_class, sizeof(tool_impl_class)); |
| 314 | name_render_.GetToolImplFileName(stree->GetName(), tool_impl_file, sizeof(tool_impl_file)); |
| 315 | name_render_.GetClientClassName(stree->GetName(), client_class, sizeof(client_class)); |
| 316 | name_render_.GetClientFileName(stree->GetName(), client_file, sizeof(client_file)); |
| 317 | |
| 318 | string content(PHXRPC_TOOL_MAIN_TEMPLATE); |
| 319 | StrTrim(&content); |
| 320 | StrReplaceAll(&content, "$ClientFile$", client_file); |
| 321 | StrReplaceAll(&content, "$ClientClass$", client_class); |
| 322 | StrReplaceAll(&content, "$ToolFile$", tool_file); |
| 323 | StrReplaceAll(&content, "$ToolClass$", tool_class); |
| 324 | StrReplaceAll(&content, "$ToolImplFile$", tool_impl_file); |
| 325 | StrReplaceAll(&content, "$ToolImplClass$", tool_impl_class); |
| 326 | |
| 327 | fprintf(write, "%s", content.c_str()); |
| 328 | |
| 329 | fprintf(write, "\n"); |
| 330 | fprintf(write, "\n"); |
| 331 | } |
| 332 |
no test coverage detected