Boost logo

Boost Users :

Subject: [Boost-users] [iostreams] mapped_file_source and std::ios::in
From: Norbert Wenzel (Norbert.Wenzel_at_[hidden])
Date: 2008-12-02 04:35:03


Hi,

I've recently been reworking some filereaders and changed them
from std::iostream to boost::iostreams::mapped_file_source.

Though the data has been fully loaded the std::getline() did set
only the first character of the text and returned false, which
caused the usual while loop to exit.

When I wanted to ask you for help and made up a small example, in
which the filereading - to my surprise - worked fine. The problem
has been, that from rewritting from the code from std::iostreams
there was an std::ios::in left. So my actual filereading looked
like this:

io::mapped_file_source file("C://test.txt", std::ios::in);
io::stream<io::mapped_file_source> input(file);
std::string line;
while(std::getline(input, line)) {
   std::cout << "Line: " << line << std::endl;
}

After removing the std::ios::in everything worked as expected.
All tests have been made using Boost 1.37 and MSVC8.

My question is if this is the intended behaviour of
mapped_file_source and if so, if that could be pointed out more
prominently in the docs, since I think I've virtually read all of
them and didn't find anything similiar in there.

cheers,
Norbert


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net