
I am having a little trouble getting this to work. Here's an example I am working on: #include <boost/integer/endian.hpp> struct data { boost::integer::little8_t first; boost::integer::little8_t second; boost::integer::little16_t third; }; int main(int argc, char *argv[]) { std::vector<unsigned char> binary_buffer; binary_buffer.push_back(0x03); binary_buffer.push_back(0x06); binary_buffer.push_back(0x00); binary_buffer.push_back(0x09); data_record dr; std::copy(binary_buffer.begin(), binary_buffer.end(), /* need an iterator to &dr? */); return 0; } Am I doing this correctly? thanks, graham On Thu, May 29, 2008 at 1:37 PM, Scott McMurray <me22.ca+boost@gmail.com> wrote:
On Thu, May 29, 2008 at 2:19 PM, Graham Reitz <graham.cpp@gmail.com> wrote:
...would like to convert to this in a C++'ish style using a boost facility if it exists: (or consider directing me somewhere else if it doesn't)
There isn't at the moment.
However, Beman Dawes has recently updated his proposed Boost.Endian library (http://tinyurl.com/4bswsh), and there is a discussion about it over on the dev list (http://lists.boost.org/Archives/boost/2008/05/137820.php and followups).
It would allow you to say (something like)
struct // or class { boost::endian::uint_t<16, boost::endian::big_endian> first; boost::endian::uint_t<32, boost::endian::big_endian> second; } data;
Which you could then std::copy your data into (through char*s), and use the implicit conversions to get native integral types out.
HTH, ~ Scott _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users