[endian] cooperation with iostream

Dear Beman, In my recent work on the zoneinfo database for the date_time library, I have tried the current endian-0.8 from sandbox in order read big endian data. I had partial success. Although I see a working example based on the cstdio function calls, I am primarily using an ifstream to read a binary file. I haven't been able to figure out on how to get ifstreams working in combination with big endian types. (By the way, perhaps in conjunction with iostreams, it would be nice if std::ios::big_endian would exist, and be done with it?) Is it possible to use the endian library in combination with bniary iostreams? If so, would it be possible to give an example on how that should look like? Thanks, Kind regards, Rutger

On Fri, Nov 21, 2008 at 7:54 AM, Rutger ter Borg <rutger@terborg.net> wrote:
Dear Beman,
In my recent work on the zoneinfo database for the date_time library, I have tried the current endian-0.8 from sandbox in order read big endian data.
I had partial success. Although I see a working example based on the cstdio function calls, I am primarily using an ifstream to read a binary file. I haven't been able to figure out on how to get ifstreams working in combination with big endian types. (By the way, perhaps in conjunction with iostreams, it would be nice if std::ios::big_endian would exist, and be done with it?)
Not sure I understand the request. Could you explain a bit?
Is it possible to use the endian library in combination with bniary iostreams?
Yes.
If so, would it be possible to give an example on how that should look like?
I'll try, but I'm pretty backed up right now. --Beman

Beman Dawes wrote:
Not sure I understand the request. Could you explain a bit?
At the moment, the library lets you define big and/or little endian types directly in your code. Am I also correct that the main motivation of the library is for IO? If that's the case, instead of writing big64_t my_integer; my_stream >> my_integer; I would intuitively prefer setting the endianness to be similar to setting a property of an iostream, int my_integer; my_stream >> big_endian >> my_integer; because in the first case I am expecting a performance penalty on computing with the big64_t type, which I am not expecting for the native integer type. I know there may be no performance penalty at all, it's just what I'm expecting from the semantics. Hopefully this clarifies it a bit, Kind regards, Rutger
participants (2)
-
Beman Dawes
-
Rutger ter Borg