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 2010/08/31 18:51:25 UTC

svn commit: r991251 - /incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc

Author: dreiss
Date: Tue Aug 31 16:51:25 2010
New Revision: 991251

URL: http://svn.apache.org/viewvc?rev=991251&view=rev
Log:
THRIFT-507. ruby: Stop using boost::tokenizer

Previously, the Ruby generated used boost::tokenizer to produce a
vector of namespace components from a dot-delimited namespace string.
We can do this manually with only a slight increase in complexity.

Modified:
    incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc?rev=991251&r1=991250&r2=991251&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc Tue Aug 31 16:51:25 2010
@@ -25,14 +25,13 @@
 #include <fstream>
 #include <iostream>
 #include <vector>
+#include <algorithm>
 
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sstream>
 
-#include <boost/tokenizer.hpp>
-
 #include "t_oop_generator.h"
 #include "platform.h"
 using namespace std;
@@ -174,11 +173,20 @@ class t_rb_generator : public t_oop_gene
 
   std::vector<std::string> ruby_modules(t_program* p) {
     std::string ns = p->get_namespace("rb");
-    boost::tokenizer<> tok(ns);
     std::vector<std::string> modules;
+    if (ns.empty()) {
+      return modules;
+    }
 
-    for(boost::tokenizer<>::iterator beg=tok.begin(); beg != tok.end(); ++beg) {
-      modules.push_back(capitalize(*beg));
+    std::string::iterator pos = ns.begin();
+    while (true) {
+      std::string::iterator delim = std::find(pos, ns.end(), '.');
+      modules.push_back(capitalize(std::string(pos, delim)));
+      pos = delim;
+      if (pos == ns.end()) {
+        break;
+      }
+      ++pos;
     }
 
     return modules;