From: <bl...@us...> - 2003-04-26 13:13:39
|
Update of /cvsroot/cpptool/rfta/include/xtl In directory sc8-pr-cvs1:/tmp/cvs-serv32663/include/xtl Modified Files: CStringView.h Log Message: * added reverse iterator for CStringEnumerator * fixed release configuration Index: CStringView.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/xtl/CStringView.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CStringView.h 26 Apr 2003 12:09:45 -0000 1.1 --- CStringView.h 26 Apr 2003 13:13:36 -0000 1.2 *************** *** 12,15 **** --- 12,16 ---- class CStringView; class CStringEnumerator; + class CStringBackEnumerator; *************** *** 51,54 **** --- 52,60 ---- CStringEnumerator enumerate( int startIndex, int endIndex ) const; + + CStringBackEnumerator backEnumerate() const; + + CStringBackEnumerator backEnumerate( int startIndex, + int endIndex ) const; const char *getStart() const *************** *** 134,145 **** } - int getRemainingLength() const - { - return string_.getEnd() - current_; - } - char operator*() const { ! return getCurrent(); } --- 140,148 ---- } char operator*() const { ! if ( current_ < string_.getEnd() ) ! return *current_; ! return 0; } *************** *** 178,193 **** } ! char getNext() ! { ! if ( current_ < string_.getEnd() ) ! return *current_++; ! return 0; ! } ! ! char getCurrent() const { ! if ( current_ < string_.getEnd() ) ! return *current_; ! return 0; } --- 181,187 ---- } ! bool hasPrevious() const { ! return current_ > string_.getStart(); } *************** *** 221,283 **** ! /* ! class CStringBackEnumerator { public: CStringBackEnumerator() - : current_( 0 ) - , end_( 0 ) { } ! CStringBackEnumerator( const char *current, ! const char *start ) ! : current_( start ? current : 0 ) ! , start_( start ? start : current ) ! { ! } ! ! ! CStringBackEnumerator( const CStringView &cstringView ); ! ! int getRemainingLength() const { - return current_ - start_; } char getNext() { ! if ( current_ >= start_ ) ! return *current_--; ! return 0; } ! char getCurrent() const { ! if ( current_ >= start_ ) ! return *current_; ! return 0; } bool hasNext() const { ! return current_ >= start_; } const char *getCurrentPos() const { ! return current_; } ! const char *getStartPos() const { ! return start_; } - - private: - const char *current_; - const char *start_; }; ! */ --- 215,259 ---- ! ! class CStringBackEnumerator : public std::reverse_iterator<CStringEnumerator, char, char> { + private: + typedef std::reverse_iterator<CStringEnumerator, char, char> SuperClass; public: CStringBackEnumerator() { } ! CStringBackEnumerator( const CStringEnumerator &other ) ! : SuperClass( other ) { } char getNext() { ! return *(*this)++; } ! bool hasPrevious() const { ! return current.hasNext(); } bool hasNext() const { ! return current.hasPrevious(); } const char *getCurrentPos() const { ! return current.getCurrentPos(); } ! const CStringView &getString() const { ! return current.getString(); } }; ! *************** *** 295,298 **** --- 271,275 ---- } + inline CStringEnumerator CStringView::enumerate() const *************** *** 301,304 **** --- 278,282 ---- } + inline CStringEnumerator CStringView::enumerate( int startIndex, *************** *** 309,312 **** --- 287,305 ---- start_ + endIndex ); return CStringEnumerator(); + } + + + inline CStringBackEnumerator + CStringView::backEnumerate() const + { + return CStringBackEnumerator( enumerate() ); + } + + + inline CStringBackEnumerator + CStringView::backEnumerate( int startIndex, + int endIndex ) const + { + return CStringBackEnumerator( enumerate( startIndex, endIndex ) ); } |