From 38f89597798a911221839188864f5f90949e3416 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Tue, 31 Aug 2010 16:51:25 +0000 Subject: [PATCH] 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 --- compiler/cpp/src/generate/t_rb_generator.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc index d580eb36..70c9c7a4 100644 --- a/compiler/cpp/src/generate/t_rb_generator.cc +++ b/compiler/cpp/src/generate/t_rb_generator.cc @@ -25,14 +25,13 @@ #include #include #include +#include #include #include #include #include -#include - #include "t_oop_generator.h" #include "platform.h" using namespace std; @@ -174,11 +173,20 @@ class t_rb_generator : public t_oop_generator { std::vector ruby_modules(t_program* p) { std::string ns = p->get_namespace("rb"); - boost::tokenizer<> tok(ns); std::vector 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; -- 2.17.1