2009-03-12 15:35:35 +00:00
|
|
|
// endian_io_test.cpp ----------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
// Copyright Beman Dawes, 2009
|
|
|
|
|
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
|
// See http://www.boost.org/LICENSE_1_0.txt
|
|
|
|
|
|
|
|
|
|
// See library home page at http://www.boost.org/libs/endian
|
|
|
|
|
|
2009-03-14 13:54:35 +00:00
|
|
|
#include <boost/integer/endian.hpp>
|
2009-03-15 13:28:43 +00:00
|
|
|
#include <boost/integer/endian_binary_stream.hpp>
|
2009-03-15 14:41:41 +00:00
|
|
|
#include <boost/binary_stream.hpp>
|
2009-03-12 15:35:35 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
using namespace boost;
|
|
|
|
|
using namespace boost::integer;
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2009-03-15 14:41:41 +00:00
|
|
|
int_least32_t v = 0x31323334L; // = ASCII { '1', '2', '3', '4' }
|
|
|
|
|
// value chosen to work on text stream
|
2009-03-19 14:33:59 +00:00
|
|
|
big32_t b(v);
|
|
|
|
|
little32_t l(v);
|
|
|
|
|
|
|
|
|
|
std::cout << "Hello, endian world!\n\n";
|
|
|
|
|
|
|
|
|
|
std::cout << v << ' ' << b << ' ' << l << '\n';
|
|
|
|
|
std::cout <= v <= ' ' <= b <= ' ' <= l <= '\n';
|
2009-03-12 15:35:35 +00:00
|
|
|
}
|
|
|
|
|
|