Sunday, June 6, 2010

STLSoft 1.9.98 changes to stlsoft::read_line()

As of STLSoft 1.9.98, stlsoft::read_line() can now read from an iterator range of arbitrary type. Where formerly it would only work with a C Stream (i.e. FILE*), as in:


std::string line;
while(stlsoft::read_line(stdin, line
     , stlsoft::read_line_flags::recogniseAll))
{
  . . . // process line
}

Now it will also work with an iterator range of arbitrary type, as in:

platformstl::memory_mapped_file f("file.txt");
char const* const begin = static_cast(f.memory());
char const* const end = begin + f.size();

std::string line;
while(stlsoft::read_line(begin, end, line
     , stlsoft::read_line_flags::recogniseAll))
{
  . . . // process line
}

No comments: