[aquaskk-changes 30] CVS update: AquaSKK/util

Back to archive index

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ƒŠƒ~ƒ^‚Å‚È‚¢•¶Žš‚ªˆê‚Â‚Å‚à‘¶Ý‚·‚ê‚ÎtrueB
-	return world.find_first_not_of(delim,pos) != string::npos;
+    // posˆÈ~‚ɃfƒŠƒ~ƒ^‚Å‚È‚¢•¶Žš‚ªˆê‚Â‚Å‚à‘¶Ý‚·‚ê‚ÎtrueB
+    return word_.find_first_not_of(delim_, pos_) != std::string::npos;
 }
 
-string StringTokenizer::nextToken()
+std::string StringTokenizer::nextToken()
 {
-	// posˆÈ~AƒfƒŠƒ~ƒ^‚Å‚È‚¢•¶Žš‚ªŒ»‚ê‚é‚܂ŃXƒLƒbƒv
-	unsigned int pos_not_delim = world.find_first_not_of(delim,pos);
-	if (pos_not_delim == string::npos)
-	{
-		throw string("NoMoreTokensException");
-	}
+    // posˆÈ~AƒfƒŠƒ~ƒ^‚Å‚È‚¢•¶Žš‚ªŒ»‚ê‚é‚܂ŃXƒLƒbƒv
+    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();
+};


aquaskk-changes メーリングリストの案内
Back to archive index