osg::string_token_iterator Struct Reference

#include <OSGBaseFunctions.h>

List of all members.

Public Member Functions

 string_token_iterator ()
 string_token_iterator (const std::string &str_, const char *separator_=" ")
 string_token_iterator (const string_token_iterator &rhs)
string_token_iteratoroperator++ ()
string_token_iterator operator++ (int)
std::string operator* () const
bool operator== (const string_token_iterator &rhs) const
bool operator!= (const string_token_iterator &rhs) const

Private Member Functions

void find_next (void)

Private Attributes

const char * _separator
const std::string * _str
std::string::size_type _start
std::string::size_type _end


Detailed Description

Definition at line 451 of file OSGBaseFunctions.h.


Constructor & Destructor Documentation

string_token_iterator::string_token_iterator ( const std::string &  str_,
const char *  separator_ = " " 
)

Definition at line 557 of file OSGBaseFunctions.cpp.

References find_next().

00558                                                                            :
00559         _separator(separator),
00560         _str(&str),
00561         _end(0)
00562 {
00563     find_next();
00564 }
  

string_token_iterator::string_token_iterator ( const string_token_iterator rhs  ) 

Definition at line 566 of file OSGBaseFunctions.cpp.

00566                                                                               :
00567         _separator(rhs._separator),
00568         _str(rhs._str),
00569         _start(rhs._start),
00570         _end(rhs._end)
00571 {
00572 }


Member Function Documentation

string_token_iterator & string_token_iterator::operator++ (  ) 

Definition at line 574 of file OSGBaseFunctions.cpp.

References find_next().

00575 {
00576     find_next();
00577     return *this;
00578 }

string_token_iterator string_token_iterator::operator++ ( int   ) 

Definition at line 580 of file OSGBaseFunctions.cpp.

00581 {
00582     string_token_iterator temp(*this);
00583     ++(*this);
00584     return temp;
00585 }

std::string string_token_iterator::operator* (  )  const

Definition at line 587 of file OSGBaseFunctions.cpp.

References _end, _start, and _str.

00588 {
00589     if(_end == std::string::npos)
00590     {
00591         return std::string(*_str, _start, std::string::npos);
00592     }
00593     else
00594     {
00595         return std::string(*_str, _start, _end - _start);
00596     }
00597 }

bool string_token_iterator::operator== ( const string_token_iterator rhs  )  const

Definition at line 599 of file OSGBaseFunctions.cpp.

References _end, _start, and _str.

00600 {
00601     return (rhs._str == _str && rhs._start == _start && rhs._end == _end);
00602 }

bool string_token_iterator::operator!= ( const string_token_iterator rhs  )  const

Definition at line 604 of file OSGBaseFunctions.cpp.

00605 {
00606     return !(rhs == *this);
00607 }

void string_token_iterator::find_next ( void   )  [private]

Definition at line 609 of file OSGBaseFunctions.cpp.

References _end, _separator, _start, and _str.

Referenced by operator++(), and string_token_iterator().

00610 {
00611     _start = _str->find_first_not_of(_separator, _end);
00612     // Apparently some STL implementations don't do npos !?!
00613     if(_start == std::string::npos || _start >= _str->length())
00614     {
00615         _start = _end = 0;
00616         _str = 0;
00617         return;
00618     }
00619 
00620     _end = _str->find_first_of(_separator, _start);
00621 }


Member Data Documentation

Definition at line 480 of file OSGBaseFunctions.h.

Referenced by find_next().

const std::string* osg::string_token_iterator::_str [private]

Definition at line 481 of file OSGBaseFunctions.h.

Referenced by find_next(), operator*(), and operator==().

std::string::size_type osg::string_token_iterator::_start [private]

Definition at line 482 of file OSGBaseFunctions.h.

Referenced by find_next(), operator*(), and operator==().

std::string::size_type osg::string_token_iterator::_end [private]

Definition at line 483 of file OSGBaseFunctions.h.

Referenced by find_next(), operator*(), and operator==().


The documentation for this struct was generated from the following files:

Generated on Mon Mar 17 11:10:41 2008 for OpenSG by  doxygen 1.5.5