[PATCH] Add functions for writing endian specific data to streams

Justin Bogner mail at justinbogner.com
Fri Mar 28 12:22:04 PDT 2014


Michael Spencer <bigcheesegs at gmail.com> writes:
> On Mon, Mar 24, 2014 at 3:34 PM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>> This is fine by me. Michael, what do you think?
>>
>> On 24 March 2014 17:08, Justin Bogner <mail at justinbogner.com> wrote:
>>> This adds a new header, EndianStream.h, which supplies a single
>>> templated function for writing endian specific data to a raw_ostream.
>>>
>>> The second patch is just a mechanical update of clang to use this rather
>>> than rolling their own. I've included it to show what it looks like to
>>> use this new API.
>>>
>
> I'm fine with this, but it does seem a bit verbose. It may be better
> to add an adapter:
>
> template <endianess e>
> struct Writer {
>   raw_ostream &OS;
>   Writer(raw_ostream &os) : OS(os) {}
>   template <typename value_type>
>   void write(value_type Val) {
>      ...
>   }
> };

I like this way better, thanks! Committed in r205032.




More information about the llvm-commits mailing list