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.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991251 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index d580eb3..70c9c7a 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -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 @@
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;