From: David Reiss Date: Thu, 26 Mar 2009 08:40:18 +0000 (+0000) Subject: THRIFT-282. Move generate_docstring_comment to t_generator X-Git-Tag: 0.2.0~208 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=39aa00d2e0e978cb7da1caf7c201e26ea33cdb97;p=common%2Fthrift.git THRIFT-282. Move generate_docstring_comment to t_generator git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758556 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_generator.cc b/compiler/cpp/src/generate/t_generator.cc index 23697495..6766cd16 100644 --- a/compiler/cpp/src/generate/t_generator.cc +++ b/compiler/cpp/src/generate/t_generator.cc @@ -66,6 +66,23 @@ void t_generator::generate_consts(vector consts) { } } +void t_generator::generate_docstring_comment(ofstream& out, + const string& comment_start, + const string& line_prefix, + const string& contents, + const string& comment_end) { + if (comment_start != "") indent(out) << comment_start; + stringstream docs(contents, ios_base::in); + while (!docs.eof()) { + char line[1024]; + docs.getline(line, 1024); + if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line + indent(out) << line_prefix << line << std::endl; + } + } + if (comment_end != "") indent(out) << comment_end; +} + void t_generator_registry::register_generator(t_generator_factory* factory) { gen_map_t& the_map = get_generator_map(); diff --git a/compiler/cpp/src/generate/t_generator.h b/compiler/cpp/src/generate/t_generator.h index a2bfa1c1..060e6565 100644 --- a/compiler/cpp/src/generate/t_generator.h +++ b/compiler/cpp/src/generate/t_generator.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "parse/t_program.h" #include "globals.h" @@ -39,6 +40,11 @@ class t_generator { const t_program* get_program() const { return program_; } + void generate_docstring_comment(std::ofstream& out, + const std::string& comment_start, + const std::string& line_prefix, + const std::string& contents, + const std::string& comment_end); protected: /** diff --git a/compiler/cpp/src/generate/t_oop_generator.h b/compiler/cpp/src/generate/t_oop_generator.h index fb770ff6..a18b2c28 100644 --- a/compiler/cpp/src/generate/t_oop_generator.h +++ b/compiler/cpp/src/generate/t_oop_generator.h @@ -7,9 +7,7 @@ #ifndef T_OOP_GENERATOR_H #define T_OOP_GENERATOR_H -#include #include -#include #include #include "globals.h" @@ -46,23 +44,6 @@ class t_oop_generator : public t_generator { return original; } - void generate_docstring_comment(std::ofstream& out, - std::string comment_start, - std::string line_prefix, - std::string contents, - std::string comment_end) { - if (comment_start != "") indent(out) << comment_start; - std::stringstream docs(contents, std::ios_base::in); - while (!docs.eof()) { - char line[1024]; - docs.getline(line, 1024); - if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line - indent(out) << line_prefix << line << std::endl; - } - } - if (comment_end != "") indent(out) << comment_end; - } - /** * Generates a comment about this code being autogenerated, using C++ style * comments, which are also fair game in Java / PHP, yay!