Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::StringTokenizer Class Reference
[StringConversion]

#include <OSGStringTokenizer.h>

List of all members.

Public Member Functions

Constructors
StringTokenizer (std::string &toTokens)
Destructor
*virtual ~StringTokenizer (void)
Tokenize
*bool hasNext (void)
std::string getNext (void)
void setString (std::string &toTokens)
UInt32 countTokens (void)

Protected Member Functions

Helper
*void nextTokenPos (std::string::size_type &start, std::string::size_type &end)

Protected Attributes

Member
*bool _hasNext
std::string & _tokenString
std::string _nextToken
std::string::size_type _currPos

Private Member Functions

 StringTokenizer (const StringTokenizer &source)
 prohibit default function (move to 'public' if needed)
void operator= (const StringTokenizer &source)
 prohibit default function (move to 'public' if needed)


Detailed Description

Definition at line 60 of file OSGStringTokenizer.h.


Constructor & Destructor Documentation

StringTokenizer::StringTokenizer std::string &  toTokens  ) 
 

Definition at line 61 of file OSGStringTokenizer.cpp.

References _currPos, _hasNext, _nextToken, _tokenString, nextTokenPos(), and start.

00061                                                     : 
00062     _hasNext    (false   ),
00063     _tokenString(toTokens),
00064     _nextToken  (        ),
00065     _currPos    (       0)
00066 {
00067     std::string::size_type start;
00068     std::string::size_type end;
00069 
00070     nextTokenPos(start, end);
00071 
00072     if((start == std::string::npos) ||
00073        (end   == std::string::npos)  )
00074     {
00075         _hasNext = false;
00076     }
00077     else
00078     {
00079         _hasNext   = true;
00080         _nextToken = _tokenString.substr(start, end - start);
00081         _currPos   = end;
00082     }  
00083 }

StringTokenizer::~StringTokenizer void   )  [virtual]
 

Definition at line 88 of file OSGStringTokenizer.cpp.

00089 {
00090 }

osg::StringTokenizer::StringTokenizer const StringTokenizer source  )  [private]
 


Member Function Documentation

bool StringTokenizer::hasNext void   ) 
 

Definition at line 95 of file OSGStringTokenizer.cpp.

References _hasNext.

Referenced by osg::StandardStringConversionState::addValueStr().

00096 {
00097     return _hasNext;
00098 }

std::string StringTokenizer::getNext void   ) 
 

Definition at line 100 of file OSGStringTokenizer.cpp.

References _currPos, _hasNext, _nextToken, _tokenString, nextTokenPos(), and start.

Referenced by osg::StandardStringConversionState::addValueStr().

00101 {
00102     std::string retString = _nextToken;
00103     if(!_hasNext)
00104     {
00105         return retString;
00106     }
00107     std::string::size_type start;
00108     std::string::size_type end;
00109     nextTokenPos(start, end);
00110     if((start == std::string::npos) ||
00111        (end   == std::string::npos)   )
00112     {
00113         _hasNext = false;
00114         return retString;
00115     }
00116     _nextToken = _tokenString.substr(start, end-start);
00117     _currPos   = end;
00118     return retString; 
00119 } 

void StringTokenizer::setString std::string &  toTokens  ) 
 

Definition at line 122 of file OSGStringTokenizer.cpp.

References _currPos, _hasNext, _nextToken, _tokenString, nextTokenPos(), and start.

00123 {
00124     _currPos     = 0;
00125     _tokenString = toTokens;
00126 
00127     std::string::size_type start, end;
00128 
00129     nextTokenPos(start, end);
00130 
00131     if((start == std::string::npos) ||
00132        (end   == std::string::npos)  )
00133     {
00134         _hasNext = false;
00135     }
00136     else
00137     {
00138         _hasNext   = true;
00139         _nextToken = _tokenString.substr(start, end - start);
00140         _currPos   = end;
00141     }   
00142 }

UInt32 StringTokenizer::countTokens void   ) 
 

Definition at line 144 of file OSGStringTokenizer.cpp.

References _currPos, _hasNext, nextTokenPos(), and start.

00145 {
00146     std::string::size_type storePos     = _currPos;
00147     bool                   storeHasNext = _hasNext;
00148 
00149     UInt32 count = 0;
00150 
00151     std::string::size_type start;
00152     std::string::size_type end;
00153 
00154     _currPos = 0;
00155 
00156     nextTokenPos(start, end);
00157 
00158     if((start == std::string::npos) ||
00159        (end   == std::string::npos)  )
00160     {
00161         _hasNext = false;
00162     }
00163     else
00164     {
00165         _hasNext = true;
00166         _currPos = end;
00167     }
00168     
00169     while(_hasNext == true)
00170     {
00171         count++;
00172 
00173         nextTokenPos(start, end);
00174 
00175         if((start == std::string::npos) ||
00176            (end   == std::string::npos)  )
00177         {
00178             _hasNext = false;
00179         }
00180         else
00181         {
00182             _hasNext = true;
00183             _currPos = end;
00184         }
00185     }
00186 
00187     _currPos = storePos;
00188     _hasNext = storeHasNext;
00189 
00190     return count;
00191 }        

void StringTokenizer::nextTokenPos std::string::size_type &  start,
std::string::size_type &  end
[protected]
 

Definition at line 193 of file OSGStringTokenizer.cpp.

References _currPos, and _tokenString.

Referenced by countTokens(), getNext(), setString(), and StringTokenizer().

00195 {
00196     start = _tokenString.find_first_not_of(" \t\n", _currPos);
00197 
00198     if(start == std::string::npos)
00199     {
00200         end = std::string::npos;
00201 
00202         return;
00203     }
00204 
00205     end = _tokenString.find_first_of(" \t\n", start);
00206 
00207     if(end == std::string::npos)
00208     {
00209         end = _tokenString.length();
00210     }
00211 }

void osg::StringTokenizer::operator= const StringTokenizer source  )  [private]
 


Member Data Documentation

* bool osg::StringTokenizer::_hasNext [protected]
 

Definition at line 111 of file OSGStringTokenizer.h.

Referenced by countTokens(), getNext(), hasNext(), setString(), and StringTokenizer().

std::string& osg::StringTokenizer::_tokenString [protected]
 

Definition at line 112 of file OSGStringTokenizer.h.

Referenced by getNext(), nextTokenPos(), setString(), and StringTokenizer().

std::string osg::StringTokenizer::_nextToken [protected]
 

Definition at line 113 of file OSGStringTokenizer.h.

Referenced by getNext(), setString(), and StringTokenizer().

std::string::size_type osg::StringTokenizer::_currPos [protected]
 

Definition at line 114 of file OSGStringTokenizer.h.

Referenced by countTokens(), getNext(), nextTokenPos(), setString(), and StringTokenizer().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:58 2005 for OpenSG by  doxygen 1.4.3