[patch][rfc] Add pwrite to raw_stream

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Apr 8 20:42:14 PDT 2015


On 8 April 2015 at 23:34, Chandler Carruth <chandlerc at google.com> wrote:
> Sorry I'm late to the party, but I think I agree with Sean.
>
> This makes absolutely no sense to me on the raw_ostream interface. That
> interface is entirely about streaming output. I don't think the seek
> interface makes any sense either honestly.
>
> I think the right way to layer these things is the other way around. Build
> the abstraction you want for IO, but don't tie it to raw_ostream in any way.
> You could make it *also* implement the raw_ostream interface if you want so
> that you can use it in that context, but I don't know why raw_ostream would
> ever be aware of this.

So, what is needed is a thing, such that

* Thing has the operations provided by the raw_ostream
* Thing has pwrite and/or seek.
* The object writer/streamer takes a thing instead of a plain raw_ostream.
* The thing can directly write to disk or hold data in a buffer and
dump it in the end.

Would it work for you to have thing be raw_pwrite_streamer and

raw_pwrite_streamer inherits from raw_ostream.
raw_fd_stream inherits from raw_pwrite_streamer
raw_svector_stream inherits from raw_pwrite_streamer
the object writer/streamer takes a raw_pwrite_streamer

Cheers,
Rafael



More information about the llvm-commits mailing list