You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2009/03/26 09:40:25 UTC

svn commit: r758556 - in /incubator/thrift/trunk/compiler/cpp/src/generate: t_generator.cc t_generator.h t_oop_generator.h

Author: dreiss
Date: Thu Mar 26 08:40:18 2009
New Revision: 758556

URL: http://svn.apache.org/viewvc?rev=758556&view=rev
Log:
THRIFT-282. Move generate_docstring_comment to t_generator

Modified:
    incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.cc
    incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h
    incubator/thrift/trunk/compiler/cpp/src/generate/t_oop_generator.h

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.cc?rev=758556&r1=758555&r2=758556&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.cc Thu Mar 26 08:40:18 2009
@@ -66,6 +66,23 @@
   }
 }
 
+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();

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h?rev=758556&r1=758555&r2=758556&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h Thu Mar 26 08:40:18 2009
@@ -9,6 +9,7 @@
 
 #include <string>
 #include <iostream>
+#include <fstream>
 #include <sstream>
 #include "parse/t_program.h"
 #include "globals.h"
@@ -39,6 +40,11 @@
 
   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:
 
   /**

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_oop_generator.h
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_oop_generator.h?rev=758556&r1=758555&r2=758556&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_oop_generator.h (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_oop_generator.h Thu Mar 26 08:40:18 2009
@@ -7,9 +7,7 @@
 #ifndef T_OOP_GENERATOR_H
 #define T_OOP_GENERATOR_H
 
-#include <sstream>
 #include <string>
-#include <fstream>
 #include <iostream>
 
 #include "globals.h"
@@ -46,23 +44,6 @@
     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!