theplu::yat::utility::GetlineIterator Class Reference

Read from std::istream with std::getline. More...

#include <yat/utility/GetlineIterator.h>

List of all members.

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


Detailed Description

Read from std::istream with std::getline.

A GetlineIterator is an Input Iterator similar to std::istream_iterator that can be used to read from an istream. The main difference is that GetlineIterator reads from the istream using std::getline rather than operator>>. value_type is std::string and operator* returns const std::string&. When end of stream is reached iterator gets into a special state end of stream. Two iterators are equal if they are end of stream or if they are pointing to the same stream (and not being end of stream).

Here is an example copying lines in a file to a 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));

Since:
New in yat 0.6

Constructor & Destructor Documentation

theplu::yat::utility::GetlineIterator::GetlineIterator ( std::istream &  is,
char  delimiter = '\n' 
)

Constructor.

Parameters:
is istream to extract string elements from.
delimiter the delimiting character.


The documentation for this class was generated from the following file:

Generated on Mon Nov 7 02:25:52 2011 for yat by  doxygen 1.5.9