yat
0.8.3pre
|
Read from std::istream with std::getline. More...
#include <yat/utility/GetlineIterator.h>
Public Member Functions | |
GetlineIterator (void) | |
Constructor of end of stream iterator. | |
GetlineIterator (std::istream &is, char delimiter='\n') | |
Constructor. | |
Friends | |
class | boost::iterator_core_access |
Read from std::istream with std::getline.
A GetlineIterator is an <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> similar to std::istream_iterator that can be used to read from an \c istream. The main difference is that GetlineIterator reads from the istream using \c std::getline rather than \c operator>>. \c value_type is std::string and \c operator* returns \c const \c std::string&. When end of stream is reached iterator gets into a special state \a end \a of \a stream. Two iterators are equal if they are \a end \a of \a stream or if they are pointing to the same stream (and not being \a end \a of \a stream). Here is an example copying lines in a file to a \c vector<std::string>:
std::ifstream is("file.txt"); std::vector<std::std::string> vec; GetlineIterator begin(is); GetlineIterator end; std::copy(begin, end, std::back_inserter(vec));
theplu::yat::utility::GetlineIterator::GetlineIterator | ( | std::istream & | is, |
char | delimiter = '\n' |
||
) |
Constructor.
is | istream to extract string elements from. |
delimiter | the delimiting character. |