Boost logo

Boost Users :

Subject: Re: [Boost-users] seekable input filter definition
From: Cherotek Music (cherotek_at_[hidden])
Date: 2016-04-07 12:47:51


It works! thanks

On Thu, Apr 7, 2016 at 4:36 PM, llonesmiz <jorge.navalon_at_[hidden]> wrote:

> Cherotek Music wrote
> > Hey, I'm new to boost and need a seekable input filter that will operate
> > on
> > bytes read from an ifstream. This is what I currently have:
> >
> > struct my_filter : boost::iostreams::seekable_filter{
> > template
> > <typename Source>
> > int get(Source& src)
> > {
> > int byte = boost::iostreams::get(src);
> > if(byte != EOF && byte != boost::iostreams::WOULD_BLOCK)
> > {
> > // Do something with byte
> > }
> > return byte;
> > }
> >
> > template
> > <typename Sink>
> > bool put(Sink&, char)
> > {
> > // No need to actually implement put because this filter is
> > only used with ifstream
> > return true;
> > }
> >
> > template
> > <typename T>
> > std::streampos seek(T& t, boost::iostreams::stream_offset off,
> > std::ios_base::seekdir way, std::ios_base::openmode which =
> > std::ios_base::in | std::ios_base::out)
> > {
> > return boost::iostreams::seek(t, off, way, which);
> > }};
> >
> > It works but I would like to get rid of the useless put method. The boost
> > documentation here
> >
> http://www.boost.org/doc/libs/1_60_0/libs/iostreams/doc/concepts/filter.html
> > says
> > there is an InputSeekableFilter refinement of Filter but I can't seem to
> > understand how to use it (there are no input_seekable_filter_tag or
> > input_seekable_filter structs that I could use).
> >
> > Thanks
>
> "boost::iostreams::seekable_filter" seems to just be a typedef for
> "boost::iostreams::filter<boost::iostreams::seekable>". I don't know for
> sure, but I think it would make sense that deriving your "struct my_filter"
> from "boost::iostreams::filter<boost::iostreams::input_seekable>" would
> accomplish what you want.
>
>
>
> --
> View this message in context:
> http://boost.2283326.n4.nabble.com/seekable-input-filter-definition-tp4685157p4685158.html
> Sent from the Boost - Users mailing list archive at Nabble.com.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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