Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63133 - sandbox/endian_ext/libs/integer/example
From: vicente.botet_at_[hidden]
Date: 2010-06-20 08:23:33


Author: viboes
Date: 2010-06-20 08:23:32 EDT (Sun, 20 Jun 2010)
New Revision: 63133
URL: http://svn.boost.org/trac/boost/changeset/63133

Log:
* test UDT for endian_pack

Added:
   sandbox/endian_ext/libs/integer/example/endian_hello_world_1.cpp (contents, props changed)
   sandbox/endian_ext/libs/integer/example/endian_hello_world_2.cpp (contents, props changed)
   sandbox/endian_ext/libs/integer/example/endian_quantity.cpp (contents, props changed)
Text files modified:
   sandbox/endian_ext/libs/integer/example/endian_hello_world.cpp | 13 +++++++------
   1 files changed, 7 insertions(+), 6 deletions(-)

Modified: sandbox/endian_ext/libs/integer/example/endian_hello_world.cpp
==============================================================================
--- sandbox/endian_ext/libs/integer/example/endian_hello_world.cpp (original)
+++ sandbox/endian_ext/libs/integer/example/endian_hello_world.cpp 2010-06-20 08:23:32 EDT (Sun, 20 Jun 2010)
@@ -17,14 +17,15 @@
 
 int main()
 {
- int_least32_t v = 0x31323334L; // = ASCII { '1', '2', '3', '4' }
+ int_least32_t v = 0x31323334L; // = ASCII { '1', '2', '3', '4' }
                                   // value chosen to work on text stream
- big32_t b(v);
- little32_t l(v);
+ big32_pt b(v);
+ little32_pt l(v);
 
- std::cout << "Hello, endian world!\n\n";
+ std::cout << "Hello, endian world!\n\n";
 
- std::cout << v << ' ' << b << ' ' << l << '\n';
- std::cout <= v <= ' ' <= b <= ' ' <= l <= '\n';
+ std::cout << v << ' ' << b << ' ' << l << '\n';
+ std::cout <= v <= ' ' <= b <= ' ' <= l <= '\n';
+ return 0;
 }
 

Added: sandbox/endian_ext/libs/integer/example/endian_hello_world_1.cpp
==============================================================================
--- (empty file)
+++ sandbox/endian_ext/libs/integer/example/endian_hello_world_1.cpp 2010-06-20 08:23:32 EDT (Sun, 20 Jun 2010)
@@ -0,0 +1,32 @@
+// endian_hello_world_1.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
+
+#include <boost/integer/endian_pack.hpp>
+#include <boost/integer/endian_binary_stream.hpp>
+#include <boost/binary_stream.hpp>
+#include <iostream>
+
+using namespace boost;
+using namespace boost::integer;
+using namespace boost::endianness;
+
+int main()
+{
+ int_least32_t v = 0x31323334L; // = ASCII { '1', '2', '3', '4' }
+ // value chosen to work on text stream
+ endian_pack<big, int_least32_t> b(v);
+ endian_pack<little, int_least32_t> l(v);
+
+ std::cout << "Hello, endian world!\n\n";
+
+ std::cout << v << ' ' << b << ' ' << l << '\n';
+ std::cout <= v <= '*' <= b <= '*' <= l <= '\n';
+ return 0;
+}
+

Added: sandbox/endian_ext/libs/integer/example/endian_hello_world_2.cpp
==============================================================================
--- (empty file)
+++ sandbox/endian_ext/libs/integer/example/endian_hello_world_2.cpp 2010-06-20 08:23:32 EDT (Sun, 20 Jun 2010)
@@ -0,0 +1,33 @@
+// endian_hello_world_2.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
+
+#include <boost/integer/endian_pack.hpp>
+#include <boost/integer/endian.hpp>
+#include <boost/integer/endian_binary_stream.hpp>
+#include <boost/binary_stream.hpp>
+#include <iostream>
+
+using namespace boost;
+using namespace boost::integer;
+using namespace boost::endianness;
+
+int main()
+{
+ int_least32_t v = 0x313233L; // = ASCII { '1', '2', '3'}
+ // value chosen to work on text stream
+ endian_pack<big, int_least32_t, 24, alignment::unaligned> b(v);
+ endian_pack<little, int_least32_t, 24, alignment::unaligned> l(v);
+
+ std::cout << "Hello, endian world!\n\n";
+
+ std::cout << v << ' ' << b << ' ' << l << '\n';
+ std::cout <= b <= ' ' <= l <= '\n';
+ return 0;
+}
+

Added: sandbox/endian_ext/libs/integer/example/endian_quantity.cpp
==============================================================================
--- (empty file)
+++ sandbox/endian_ext/libs/integer/example/endian_quantity.cpp 2010-06-20 08:23:32 EDT (Sun, 20 Jun 2010)
@@ -0,0 +1,44 @@
+// endian_hello_world_2.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
+
+#include <boost/integer/endian_pack.hpp>
+#include <boost/integer/endian_binary_stream.hpp>
+#include <boost/binary_stream.hpp>
+#include <iostream>
+#include <boost/units/io.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/si/plane_angle.hpp>
+
+using namespace boost;
+using namespace boost::integer;
+using namespace boost::endianness;
+using namespace boost::units;
+
+int main()
+{
+ quantity<si::length, boost::int_least32_t> q = 825373492 * si::meter;
+ endian_pack<big, quantity<si::length, boost::int_least32_t> > b;
+ endian_pack<little, quantity<si::length, boost::int_least32_t> > l;
+ b=q;
+ l=q;
+
+ //~ quantity<si::length, boost::int_least32_t> q2 = b;
+
+ std::cout << "Hello, endian quantity!\n\n";
+
+ //~ std::cout << q << '\n';
+ //~ std::cout << q2 << '\n';
+ std::cout << q << ' ' << b << ' ' << l << '\n';
+ std::cout <= b <= ' ' <= l <= '\n';
+ //~ std::cout <= q <= ' ' <= b <= ' ' <= l <= '\n';
+
+ return 1;
+}
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk