Tomotaka SUWA
t-suw****@users*****
2005年 9月 6日 (火) 10:25:13 JST
Index: AquaSKK/util/StringTokenizer.cpp diff -u AquaSKK/util/StringTokenizer.cpp:1.1.1.2 AquaSKK/util/StringTokenizer.cpp:1.2 --- AquaSKK/util/StringTokenizer.cpp:1.1.1.2 Sun Jul 17 19:50:32 2005 +++ AquaSKK/util/StringTokenizer.cpp Tue Sep 6 10:25:13 2005 @@ -1,5 +1,5 @@ /* - $Id: StringTokenizer.cpp,v 1.1.1.2 2005/07/17 10:50:32 t-suwa Exp $ + $Id: StringTokenizer.cpp,v 1.2 2005/09/06 01:25:13 t-suwa Exp $ --------- MacOS X implementation of the SKK input method. @@ -19,47 +19,41 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "StringTokenizer.h" #include <string> -using namespace util; +#include "StringTokenizer.h" -StringTokenizer::StringTokenizer(const string& world,const string& delim) - : world(world) , delim(delim) , pos(0) -{ - +StringTokenizer::StringTokenizer( + const std::string& word, const std::string& delim) + : word_(word), delim_(delim) , pos_(0) { + // empty } -StringTokenizer::~StringTokenizer() -{ - +StringTokenizer::~StringTokenizer() { + // empty } bool StringTokenizer::hasMoreTokens() { - // posÈ~Éf~^ÅÈ¢¶ªêÂÅà¶Ý·êÎtrueB - return world.find_first_not_of(delim,pos) != string::npos; + // posÈ~Éf~^ÅÈ¢¶ªêÂÅà¶Ý·êÎtrueB + return word_.find_first_not_of(delim_, pos_) != std::string::npos; } -string StringTokenizer::nextToken() +std::string StringTokenizer::nextToken() { - // posÈ~Af~^ÅÈ¢¶ª»êéÜÅXLbv - unsigned int pos_not_delim = world.find_first_not_of(delim,pos); - if (pos_not_delim == string::npos) - { - throw string("NoMoreTokensException"); - } + // posÈ~Af~^ÅÈ¢¶ª»êéÜÅXLbv + size_t pos_not_delim = word_.find_first_not_of(delim_, pos_); + if(pos_not_delim == std::string::npos) { + throw std::string("NoMoreTokensException"); + } - // Éf~^ª»êéêðT· - unsigned int pos_next_delim = world.find_first_of(delim,pos_not_delim+1); - if (pos_next_delim == string::npos) - { - // ÅãÌg[N - pos = world.length(); - return world.substr(pos_not_delim,world.length() - pos_not_delim); - } - else - { - pos = pos_next_delim + 1; - return world.substr(pos_not_delim,pos_next_delim - pos_not_delim); - } + // Éf~^ª»êéêðT· + size_t pos_next_delim = word_.find_first_of(delim_, pos_not_delim + 1); + if(pos_next_delim == std::string::npos) { + // ÅãÌg[N + pos_ = word_.length(); + return word_.substr(pos_not_delim, word_.length() - pos_not_delim); + } else { + pos_ = pos_next_delim + 1; + return word_.substr(pos_not_delim, pos_next_delim - pos_not_delim); + } } Index: AquaSKK/util/StringTokenizer.h diff -u AquaSKK/util/StringTokenizer.h:1.1.1.2 AquaSKK/util/StringTokenizer.h:1.2 --- AquaSKK/util/StringTokenizer.h:1.1.1.2 Sun Jul 17 19:50:32 2005 +++ AquaSKK/util/StringTokenizer.h Tue Sep 6 10:25:13 2005 @@ -1,5 +1,5 @@ /* - $Id: StringTokenizer.h,v 1.1.1.2 2005/07/17 10:50:32 t-suwa Exp $ + $Id: StringTokenizer.h,v 1.2 2005/09/06 01:25:13 t-suwa Exp $ --------- MacOS X implementation of the SKK input method. @@ -20,25 +20,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once -#include <string> -using namespace std; -namespace util -{ - class StringTokenizer; + +namespace util { + class StringTokenizer; } -class util::StringTokenizer -{ - public: - StringTokenizer(const string& world,const string& delim); - virtual ~StringTokenizer(); - - virtual bool hasMoreTokens(); - virtual string nextToken(); - - - private: - string world; - string delim; - int pos; -}; \ No newline at end of file +class StringTokenizer { + std::string word_; + std::string delim_; + size_t pos_; + +public: + StringTokenizer(const std::string& word, const std::string& delim); + virtual ~StringTokenizer(); + + virtual bool hasMoreTokens(); + virtual std::string nextToken(); +};