[iostreams] How to make a seekable device seek

I have a seekable iostream device with the tag set to : typedef boost::iostreams::input_seekable catagory; If I have not defined the functions get and seek, it will not compile, which is expected, so far so good. But when I called it like this : mydevice test("somefile.txt"); boost::iostreams::stream<mydevice> buf(test); buf.seekg(0); it never enters my seek function, which I would expect. I am sure the solution must be obvious. Any pointers here ?

After sleeping on it, i figured it out. It was a dumb mistake, I
thought you could use standard seek functions, but you need to use
iostreams functions.
boost::iostreams::seek(buf, boost::iostreams::position_to_offset(0),
std::ios_base::beg);
Then it correctly calls my seek function.
On Thu, Apr 29, 2010 at 11:10 PM, Bo Jensen
I have a seekable iostream device with the tag set to :
typedef boost::iostreams::input_seekable catagory;
If I have not defined the functions get and seek, it will not compile, which is expected, so far so good. But when I called it like this :
mydevice test("somefile.txt");
boost::iostreams::stream<mydevice> buf(test);
buf.seekg(0);
it never enters my seek function, which I would expect. I am sure the solution must be obvious. Any pointers here ?

Hi, what happens when you try to seek to another position than 0: buf.seekg(100); I remember seeing code (and a resolved bug too) that optimizes no-seeks. Your position was probably 0 before the call. Kind regards, Daniel Am 30.04.2010 01:10, schrieb Bo Jensen:
I have a seekable iostream device with the tag set to :
typedef boost::iostreams::input_seekable catagory;
If I have not defined the functions get and seek, it will not compile, which is expected, so far so good. But when I called it like this :
mydevice test("somefile.txt");
boost::iostreams::stream<mydevice> buf(test);
buf.seekg(0);
it never enters my seek function, which I would expect. I am sure the solution must be obvious. Any pointers here ? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Daniel,
Thanks for your reply, I have resolved the problem by using a iostream
seek call instead.
Regards
Bo
On Fri, Apr 30, 2010 at 8:53 PM, Daniel Eiband
Hi, what happens when you try to seek to another position than 0:
buf.seekg(100);
I remember seeing code (and a resolved bug too) that optimizes no-seeks. Your position was probably 0 before the call.
Kind regards,
Daniel
Am 30.04.2010 01:10, schrieb Bo Jensen:
I have a seekable iostream device with the tag set to :
typedef boost::iostreams::input_seekable catagory;
If I have not defined the functions get and seek, it will not compile, which is expected, so far so good. But when I called it like this :
mydevice test("somefile.txt");
boost::iostreams::stream<mydevice> buf(test);
buf.seekg(0);
it never enters my seek function, which I would expect. I am sure the solution must be obvious. Any pointers here ? _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Bo Jensen
-
Daniel Eiband