yat  0.14.5pre
Public Member Functions | Friends | List of all members
theplu::yat::utility::GetlineIterator Class Reference

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

#include <yat/utility/GetlineIterator.h>

Inheritance diagram for theplu::yat::utility::GetlineIterator:

Public Member Functions

 GetlineIterator (void)
 Constructor of end of stream iterator.
 
 GetlineIterator (std::istream &is, char delimiter='\n')
 Constructor. More...
 

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;
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' 
)
explicit

Constructor.

Parameters
isistream to extract string elements from.
delimiterthe delimiting character.

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

Generated on Tue Sep 26 2017 02:33:31 for yat by  doxygen 1.8.5