Boost logo

Boost Users :

Subject: Re: [Boost-users] [iostreams] mapped_file_source and std::ios::in
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-12-02 12:34:28


AMDG

Norbert Wenzel wrote:
> 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.
>

It looks like you are calling this constructor:

    // Constructor taking a list of parameters
    template<typename Path>
    explicit mapped_file_source( const Path& path,
                                 size_type length = max_length,
                                 boost::intmax_t offset = 0 );

In Christ,
Steven Watanabe


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