activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r556610 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util: StringTokenizer.cpp StringTokenizer.h
Date Mon, 16 Jul 2007 12:56:07 GMT
Author: tabish
Date: Mon Jul 16 05:56:03 2007
New Revision: 556610

URL: http://svn.apache.org/viewvc?view=rev&rev=556610
Log:
Code Cleanup

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.h

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.cpp?view=diff&rev=556610&r1=556609&r2=556610
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.cpp Mon Jul
16 05:56:03 2007
@@ -37,35 +37,31 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-StringTokenizer::~StringTokenizer(void)
-{
+StringTokenizer::~StringTokenizer(){
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int StringTokenizer::countTokens(void) const
+int StringTokenizer::countTokens() const
 {
     int count = 0;
     string::size_type localPos = pos;
     string::size_type lastPos  = pos;
 
-    while(localPos != string::npos)
-    {
-        if(returnDelims && str.find_first_of(delim, localPos) == localPos)
-        {
+    while(localPos != string::npos) {
+
+        if( returnDelims && str.find_first_of( delim, localPos ) == localPos ) {
             count += 1;
             localPos += 1;
-
             continue;
         }
 
         // Find first token by spanning the fist non-delimiter, to the
         // next delimiter, skipping any delimiters that are at the curret
         // location.
-        lastPos  = str.find_first_not_of(delim, localPos);
+        lastPos = str.find_first_not_of(delim, localPos);
         localPos = str.find_first_of(delim, lastPos);
 
-        if(lastPos != string::npos)
-        {
+        if(lastPos != string::npos) {
             count++;
         }
     }
@@ -74,65 +70,59 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool StringTokenizer::hasMoreTokens(void) const
+bool StringTokenizer::hasMoreTokens() const
 {
     string::size_type nextpos =
         returnDelims ? str.find_first_of(delim, pos) :
                        str.find_first_not_of(delim, pos);
 
-    return (nextpos != string::npos);
+    return ( nextpos != string::npos );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string StringTokenizer::nextToken(void)
+std::string StringTokenizer::nextToken()
    throw ( lang::exceptions::NoSuchElementException )
 {
-    if(pos == string::npos)
-    {
+    if( pos == string::npos ) {
+
         throw NoSuchElementException(
             __FILE__, __LINE__,
             "StringTokenizer::nextToken - No more Tokens available");
     }
 
-    if(returnDelims)
-    {
+    if( returnDelims ) {
         // if char at current pos is a delim return it and advance pos
-        if(str.find_first_of(delim, pos) == pos)
-        {
-            return str.substr(pos++, 1);
+        if( str.find_first_of( delim, pos ) == pos ) {
+            return str.substr( pos++, 1 );
         }
     }
 
     // Skip delimiters at beginning.
-    string::size_type lastPos = str.find_first_not_of(delim, pos);
+    string::size_type lastPos = str.find_first_not_of( delim, pos );
 
     // Find the next delimiter in the string, the charactors in between
     // will be the token to return.  If this returns string::npos then
     // there are no more delimiters in the string.
-    pos = str.find_first_of(delim, lastPos);
+    pos = str.find_first_of( delim, lastPos );
 
-    if(string::npos != lastPos)
-    {
+    if( string::npos != lastPos ) {
         // Found a token, count it, if the pos of the next delim is npos
         // then we set length to copy to npos so that all the remianing
         // portion of the string is copied, otherwise we set it to the
         return str.substr( lastPos,
                            pos == string::npos ? pos : pos-lastPos );
-    }
-    else
-    {
+    } else {
         throw NoSuchElementException(
             __FILE__, __LINE__,
-            "StringTokenizer::nextToken - No more Tokens available");
+            "StringTokenizer::nextToken - No more Tokens available" );
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string StringTokenizer::nextToken( const std::string& delim )
-    throw ( lang::exceptions::NoSuchElementException )
-{
-    this->delim = delim;
+    throw ( lang::exceptions::NoSuchElementException ) {
 
+    this->delim = delim;
     return nextToken();
 }
 
@@ -141,8 +131,7 @@
 {
     int count = 0;
 
-    while(hasMoreTokens())
-    {
+    while( hasMoreTokens() ) {
         array.push_back( nextToken() );
         count++;
     }
@@ -155,13 +144,11 @@
                              const std::string& delim,
                              bool returnDelims )
 {
-    if(str != "")
-    {
+    if( str != "" ) {
         this->str = str;
     }
 
-    if(delim != "")
-    {
+    if( delim != "" ) {
         this->delim = delim;
     }
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.h?view=diff&rev=556610&r1=556609&r2=556610
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/StringTokenizer.h Mon Jul 16
05:56:03 2007
@@ -63,7 +63,7 @@
                          const std::string& delim = " \t\n\r\f",
                          bool returnDelims = false);
 
-        virtual ~StringTokenizer(void);
+        virtual ~StringTokenizer();
 
         /**
          * Calculates the number of times that this tokenizer's nextToken
@@ -71,21 +71,21 @@
          * position is not advanced.
          * @return Count of remaining tokens
          */
-        virtual int countTokens(void) const;
+        virtual int countTokens() const;
 
         /**
          * Tests if there are more tokens available from this tokenizer's
          * string.
          * @return true if there are more tokens remaining
          */
-        virtual bool hasMoreTokens(void) const;
+        virtual bool hasMoreTokens() const;
 
         /**
          * Returns the next token from this string tokenizer.
          * @return string value of next token
          * @thorws NoSuchElementException
          */
-        virtual std::string nextToken(void)
+        virtual std::string nextToken()
             throw ( lang::exceptions::NoSuchElementException );
 
         /**
@@ -100,7 +100,7 @@
          * @return next string in the token list
          * @throw NoSuchElementException
          */
-        virtual std::string nextToken(const std::string& delim)
+        virtual std::string nextToken( const std::string& delim )
             throw ( lang::exceptions::NoSuchElementException );
 
         /**
@@ -128,7 +128,7 @@
          */
         virtual void reset( const std::string& str = "",
                             const std::string& delim = "",
-                            bool returnDelims = false);
+                            bool returnDelims = false );
 
     };
 



Mime
View raw message