Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74206 - in sandbox/endian: boost/endian libs/endian/test
From: bdawes_at_[hidden]
Date: 2011-09-03 11:14:53


Author: bemandawes
Date: 2011-09-03 11:14:53 EDT (Sat, 03 Sep 2011)
New Revision: 74206
URL: http://svn.boost.org/trac/boost/changeset/74206

Log:
Change to more explicit conversion names
Text files modified:
   sandbox/endian/boost/endian/conversion.hpp | 58 ++++++++++++------------
   sandbox/endian/libs/endian/test/conversion_test.cpp | 96 ++++++++++++++++++++--------------------
   2 files changed, 77 insertions(+), 77 deletions(-)

Modified: sandbox/endian/boost/endian/conversion.hpp
==============================================================================
--- sandbox/endian/boost/endian/conversion.hpp (original)
+++ sandbox/endian/boost/endian/conversion.hpp 2011-09-03 11:14:53 EDT (Sat, 03 Sep 2011)
@@ -38,19 +38,19 @@
   // conditional modifying (i.e. in-place) endianness reversal;
   // no effect if native endianness and specified endianness are the same
 
- template <class T> inline void to_big(T& x); // if different, convert native to big
- template <class T> inline void to_little(T& x); // if different, convert native to little
- template <class T> inline void from_big(T& x); // if different, convert big to native
- template <class T> inline void from_little(T& x); // if different, convert little to native
-
- // non-modifying copy, conditionally reversing endianness;
- // copy the first argument to the second argument, converting to or from the
- // specified endianness if different than native endianness
-
- template <class T> inline void to_big(T native, T& big);
- template <class T> inline void to_little(T native, T& little);
- template <class T> inline void from_big(T big, T& native);
- template <class T> inline void from_little(T little, T& native);
+ template <class T> inline void native_to_big(T& x);
+ template <class T> inline void native_to_little(T& x);
+ template <class T> inline void big_to_native(T& x);
+ template <class T> inline void little_to_native(T& x);
+
+ // non-modifying copy conditionally reversing endianness;
+ // copy the source argument to the target argument, converting to or from the
+ // indicated endianness if different than native endianness
+
+ template <class T> inline void native_to_big(T source, T& target);
+ template <class T> inline void native_to_little(T source, T& target);
+ template <class T> inline void big_to_native(T source, T& target);
+ template <class T> inline void little_to_native(T source, T& target);
 
 //----------------------------------- implementation -----------------------------------//
                                                 
@@ -197,23 +197,23 @@
   }
 
 #ifdef BOOST_LITTLE_ENDIAN
- template <class T> inline void to_big(T& x) { flip(x); }
- template <class T> inline void to_little(T&) {}
- template <class T> inline void from_big(T& x) { flip(x); }
- template <class T> inline void from_little(T&) {}
- template <class T> inline void to_big(T native, T& big) { flip(native, big); }
- template <class T> inline void to_little(T native, T& little) { little = native; }
- template <class T> inline void from_big(T big, T& native) { flip(big, native); }
- template <class T> inline void from_little(T little, T& native) { native = little; }
+ template <class T> inline void native_to_big(T& x) { flip(x); }
+ template <class T> inline void native_to_little(T&) {}
+ template <class T> inline void big_to_native(T& x) { flip(x); }
+ template <class T> inline void little_to_native(T&) {}
+ template <class T> inline void native_to_big(T source, T& target) { flip(source, target); }
+ template <class T> inline void native_to_little(T source, T& target) { target = source; }
+ template <class T> inline void big_to_native(T source, T& target) { flip(source, target); }
+ template <class T> inline void little_to_native(T source, T& target) { target = source; }
 #else
- template <class T> inline void to_big(T&) {}
- template <class T> inline void to_little(T& x) { flip(x); }
- template <class T> inline void from_big(T&) {}
- template <class T> inline void from_little(T& x) { flip(x); }
- template <class T> inline void to_big(T native, T& big) { big = native; }
- template <class T> inline void to_little(T native, T& little) { flip(native, little); }
- template <class T> inline void from_big(T big, T& native) { native = big; }
- template <class T> inline void from_little(T little, T& native) { flip(little, native); }
+ template <class T> inline void native_to_big(T&) {}
+ template <class T> inline void native_to_little(T& x) { flip(x); }
+ template <class T> inline void big_to_native(T&) {}
+ template <class T> inline void little_to_native(T& x) { flip(x); }
+ template <class T> inline void native_to_big(T native, T& big) { target = source; }
+ template <class T> inline void native_to_little(T native, T& little) { flip(source, target); }
+ template <class T> inline void big_to_native(T big, T& native) { target = source; }
+ template <class T> inline void little_to_native(T little, T& native) { flip(source, target); }
 #endif
 
 } // namespace endian

Modified: sandbox/endian/libs/endian/test/conversion_test.cpp
==============================================================================
--- sandbox/endian/libs/endian/test/conversion_test.cpp (original)
+++ sandbox/endian/libs/endian/test/conversion_test.cpp 2011-09-03 11:14:53 EDT (Sat, 03 Sep 2011)
@@ -203,109 +203,109 @@
     boost::int64_t i64;
 
     i64 = ni64;
- be::to_big(i64);
+ be::native_to_big(i64);
     BOOST_TEST_EQ(i64, bi64);
 
     i64 = ni64;
- be::to_little(i64);
+ be::native_to_little(i64);
     BOOST_TEST_EQ(i64, li64);
 
     i64 = bi64;
- be::from_big(i64);
+ be::big_to_native(i64);
     BOOST_TEST_EQ(i64, ni64);
 
     i64 = li64;
- be::from_little(i64);
+ be::little_to_native(i64);
     BOOST_TEST_EQ(i64, ni64);
 
     boost::uint64_t ui64;
 
     ui64 = nui64;
- be::to_big(ui64);
+ be::native_to_big(ui64);
     BOOST_TEST_EQ(ui64, bui64);
 
     ui64 = nui64;
- be::to_little(ui64);
+ be::native_to_little(ui64);
     BOOST_TEST_EQ(ui64, lui64);
 
     ui64 = bui64;
- be::from_big(ui64);
+ be::big_to_native(ui64);
     BOOST_TEST_EQ(ui64, nui64);
 
     ui64 = lui64;
- be::from_little(ui64);
+ be::little_to_native(ui64);
     BOOST_TEST_EQ(ui64, nui64);
 
     boost::int32_t i32;
 
     i32 = ni32;
- be::to_big(i32);
+ be::native_to_big(i32);
     BOOST_TEST_EQ(i32, bi32);
 
     i32 = ni32;
- be::to_little(i32);
+ be::native_to_little(i32);
     BOOST_TEST_EQ(i32, li32);
 
     i32 = bi32;
- be::from_big(i32);
+ be::big_to_native(i32);
     BOOST_TEST_EQ(i32, ni32);
 
     i32 = li32;
- be::from_little(i32);
+ be::little_to_native(i32);
     BOOST_TEST_EQ(i32, ni32);
 
     boost::uint32_t ui32;
 
     ui32 = nui32;
- be::to_big(ui32);
+ be::native_to_big(ui32);
     BOOST_TEST_EQ(ui32, bui32);
 
     ui32 = nui32;
- be::to_little(ui32);
+ be::native_to_little(ui32);
     BOOST_TEST_EQ(ui32, lui32);
 
     ui32 = bui32;
- be::from_big(ui32);
+ be::big_to_native(ui32);
     BOOST_TEST_EQ(ui32, nui32);
 
     ui32 = lui32;
- be::from_little(ui32);
+ be::little_to_native(ui32);
     BOOST_TEST_EQ(ui32, nui32);
 
     boost::int16_t i16;
 
     i16 = ni16;
- be::to_big(i16);
+ be::native_to_big(i16);
     BOOST_TEST_EQ(i16, bi16);
 
     i16 = ni16;
- be::to_little(i16);
+ be::native_to_little(i16);
     BOOST_TEST_EQ(i16, li16);
 
     i16 = bi16;
- be::from_big(i16);
+ be::big_to_native(i16);
     BOOST_TEST_EQ(i16, ni16);
 
     i16 = li16;
- be::from_little(i16);
+ be::little_to_native(i16);
     BOOST_TEST_EQ(i16, ni16);
 
     boost::uint16_t ui16;
 
     ui16 = nui16;
- be::to_big(ui16);
+ be::native_to_big(ui16);
     BOOST_TEST_EQ(ui16, bui16);
 
     ui16 = nui16;
- be::to_little(ui16);
+ be::native_to_little(ui16);
     BOOST_TEST_EQ(ui16, lui16);
 
     ui16 = bui16;
- be::from_big(ui16);
+ be::big_to_native(ui16);
     BOOST_TEST_EQ(ui16, nui16);
 
     ui16 = lui16;
- be::from_little(ui16);
+ be::little_to_native(ui16);
     BOOST_TEST_EQ(ui16, nui16);
     
     std::cout << " test_in_place_conditional_flip complete\n";
@@ -318,109 +318,109 @@
     boost::int64_t i64, ti64;
 
     i64 = ni64;
- be::to_big(i64, ti64);
+ be::native_to_big(i64, ti64);
     BOOST_TEST_EQ(ti64, bi64);
 
     i64 = ni64;
- be::to_little(i64, ti64);
+ be::native_to_little(i64, ti64);
     BOOST_TEST_EQ(ti64, li64);
 
     i64 = bi64;
- be::from_big(i64, ti64);
+ be::big_to_native(i64, ti64);
     BOOST_TEST_EQ(ti64, ni64);
 
     i64 = li64;
- be::from_little(i64, ti64);
+ be::little_to_native(i64, ti64);
     BOOST_TEST_EQ(ti64, ni64);
 
     boost::uint64_t ui64, tui64;
 
     ui64 = nui64;
- be::to_big(ui64, tui64);
+ be::native_to_big(ui64, tui64);
     BOOST_TEST_EQ(tui64, bui64);
 
     ui64 = nui64;
- be::to_little(ui64, tui64);
+ be::native_to_little(ui64, tui64);
     BOOST_TEST_EQ(tui64, lui64);
 
     ui64 = bui64;
- be::from_big(ui64, tui64);
+ be::big_to_native(ui64, tui64);
     BOOST_TEST_EQ(tui64, nui64);
 
     ui64 = lui64;
- be::from_little(ui64, tui64);
+ be::little_to_native(ui64, tui64);
     BOOST_TEST_EQ(tui64, nui64);
 
     boost::int32_t i32, ti32;
 
     i32 = ni32;
- be::to_big(i32, ti32);
+ be::native_to_big(i32, ti32);
     BOOST_TEST_EQ(ti32, bi32);
 
     i32 = ni32;
- be::to_little(i32, ti32);
+ be::native_to_little(i32, ti32);
     BOOST_TEST_EQ(ti32, li32);
 
     i32 = bi32;
- be::from_big(i32, ti32);
+ be::big_to_native(i32, ti32);
     BOOST_TEST_EQ(ti32, ni32);
 
     i32 = li32;
- be::from_little(i32, ti32);
+ be::little_to_native(i32, ti32);
     BOOST_TEST_EQ(ti32, ni32);
 
     boost::uint32_t ui32, tui32;
 
     ui32 = nui32;
- be::to_big(ui32, tui32);
+ be::native_to_big(ui32, tui32);
     BOOST_TEST_EQ(tui32, bui32);
 
     ui32 = nui32;
- be::to_little(ui32, tui32);
+ be::native_to_little(ui32, tui32);
     BOOST_TEST_EQ(tui32, lui32);
 
     ui32 = bui32;
- be::from_big(ui32, tui32);
+ be::big_to_native(ui32, tui32);
     BOOST_TEST_EQ(tui32, nui32);
 
     ui32 = lui32;
- be::from_little(ui32, tui32);
+ be::little_to_native(ui32, tui32);
     BOOST_TEST_EQ(tui32, nui32);
 
     boost::int16_t i16, ti16;
 
     i16 = ni16;
- be::to_big(i16, ti16);
+ be::native_to_big(i16, ti16);
     BOOST_TEST_EQ(ti16, bi16);
 
     i16 = ni16;
- be::to_little(i16, ti16);
+ be::native_to_little(i16, ti16);
     BOOST_TEST_EQ(ti16, li16);
 
     i16 = bi16;
- be::from_big(i16, ti16);
+ be::big_to_native(i16, ti16);
     BOOST_TEST_EQ(ti16, ni16);
 
     i16 = li16;
- be::from_little(i16, ti16);
+ be::little_to_native(i16, ti16);
     BOOST_TEST_EQ(ti16, ni16);
 
     boost::uint16_t ui16, tui16;
 
     ui16 = nui16;
- be::to_big(ui16, tui16);
+ be::native_to_big(ui16, tui16);
     BOOST_TEST_EQ(tui16, bui16);
 
     ui16 = nui16;
- be::to_little(ui16, tui16);
+ be::native_to_little(ui16, tui16);
     BOOST_TEST_EQ(tui16, lui16);
 
     ui16 = bui16;
- be::from_big(ui16, tui16);
+ be::big_to_native(ui16, tui16);
     BOOST_TEST_EQ(tui16, nui16);
 
     ui16 = lui16;
- be::from_little(ui16, tui16);
+ be::little_to_native(ui16, tui16);
     BOOST_TEST_EQ(tui16, nui16);
     
     std::cout << " test_copying_conditional_flip complete\n";


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