// StringSegment03.cpp // tom bailey 9 mar 06 // Define the methods of the StringSegment class. // tom bailey 17 mar 06 // ver 2: operator< // tom bailey 20 mar 06 // ver 3: matchLength #include "StringSegment03.h" using std::ostream; using std::string; StringSegment::StringSegment( StrCIt aBegin, StrCIt anEnd ) : begin( aBegin ), end( anEnd ) { } void StringSegment::write( ostream & outfile, size_t limit, string term ) const { size_t chars = 0; for( StrCIt it = begin; it!=end; ++it ) { if( chars >= limit ) break; outfile << *it << term; ++chars; } } StrCIt StringSegment::beginIter() const { return begin; } StrCIt StringSegment::endIter() const { return end; } ostream & operator<<( ostream & outfile, const StringSegment & ss ) { ss.write( outfile ); return outfile; }