Boost Users :
From: Richard (legalize+jeeves_at_[hidden])
Date: 2008-01-17 17:30:00
[Please do not mail me a copy of your followup]
Does boost have a facility for this?
I have a bunch of code that did binary I/O on x86. I want to make the
code endian-neutral. This is similar to writing binary data in
"network order" as is done with TCP and other internet protocols.
I was thinking that you could now determine completely at compile-time
whether or not bytes need to be swapped using a template class.
My thought was that you would have a class for writing "LittleEndian"
bytes that took a boolean template parameter. The parameter is
determined at compile-time based on the endian-ness of your
architecture. Then a specializations for the template determines
whether or not you just use stream.write() to write the binary bytes
directly from the POD datum or whether or not you manually extract the
individual bytes for writing in the proper order.
I hope that's clear... it hasn't gelled in my mind enough to have a
sample implementation. I'm hoping that there's a facility in boost
for this already?
-- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
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