From a114dd72b5f743ec9bb4754ac7d3086ebe10c950 Mon Sep 17 00:00:00 2001
From: bemandawes
Date: Sat, 3 Sep 2011 17:50:46 +0000
Subject: [PATCH] Rename flip() to invert()
git-svn-id: http://svn.boost.org/svn/boost/sandbox/endian@74214 b8fc166d-592f-0410-95f2-cb63ce0dd405
---
boost/endian/conversion.hpp | 66 ++++++++---------
libs/endian/doc/conversion.html | 107 ++++++++++++++++++---------
libs/endian/doc/index.html | 36 +++++++--
libs/endian/test/conversion_test.cpp | 104 +++++++++++++-------------
libs/endian/test/msvc10/endian.sln | 2 +-
5 files changed, 189 insertions(+), 126 deletions(-)
diff --git a/boost/endian/conversion.hpp b/boost/endian/conversion.hpp
index 1bb5ed4..c079e07 100644
--- a/boost/endian/conversion.hpp
+++ b/boost/endian/conversion.hpp
@@ -19,24 +19,24 @@ namespace endian
{
// unconditional modifying (i.e. in-place) endianness reversal
- inline void flip(int16_t& x);
- inline void flip(int32_t& x);
- inline void flip(int64_t& x);
- inline void flip(uint16_t& x);
- inline void flip(uint32_t& x);
- inline void flip(uint64_t& x);
+ inline void invert(int16_t& x);
+ inline void invert(int32_t& x);
+ inline void invert(int64_t& x);
+ inline void invert(uint16_t& x);
+ inline void invert(uint32_t& x);
+ inline void invert(uint64_t& x);
// unconditional non-modifying endianness reversing copy
- inline void flip(int16_t source, int16_t& target);
- inline void flip(int32_t source, int32_t& target);
- inline void flip(int64_t source, int64_t& target);
- inline void flip(uint16_t source, uint16_t& target);
- inline void flip(uint32_t source, uint32_t& target);
- inline void flip(uint64_t source, uint64_t& target);
+ inline void invert(int16_t source, int16_t& target);
+ inline void invert(int32_t source, int32_t& target);
+ inline void invert(int64_t source, int64_t& target);
+ inline void invert(uint16_t source, uint16_t& target);
+ inline void invert(uint32_t source, uint32_t& target);
+ inline void invert(uint64_t source, uint64_t& target);
// conditional modifying (i.e. in-place) endianness reversal;
- // no effect if native endianness and specified endianness are the same
+ // no effect if native endianness and indicated endianness are the same
template inline void native_to_big(T& x);
template inline void native_to_little(T& x);
@@ -54,7 +54,7 @@ namespace endian
//----------------------------------- implementation -----------------------------------//
- inline void flip(int16_t& x)
+ inline void invert(int16_t& x)
{
char* rep = reinterpret_cast(&x);
char tmp;
@@ -63,7 +63,7 @@ namespace endian
*(rep+1) = tmp;
}
- inline void flip(int32_t& x)
+ inline void invert(int32_t& x)
{
char* rep = reinterpret_cast(&x);
char tmp;
@@ -75,7 +75,7 @@ namespace endian
*(rep+2) = tmp;
}
- inline void flip(int64_t& x)
+ inline void invert(int64_t& x)
{
char* rep = reinterpret_cast(&x);
char tmp;
@@ -93,7 +93,7 @@ namespace endian
*(rep+4) = tmp;
}
- inline void flip(uint16_t& x)
+ inline void invert(uint16_t& x)
{
char* rep = reinterpret_cast(&x);
char tmp;
@@ -102,7 +102,7 @@ namespace endian
*(rep+1) = tmp;
}
- inline void flip(uint32_t& x)
+ inline void invert(uint32_t& x)
{
char* rep = reinterpret_cast(&x);
char tmp;
@@ -114,7 +114,7 @@ namespace endian
*(rep+2) = tmp;
}
- inline void flip(uint64_t& x)
+ inline void invert(uint64_t& x)
{
char* rep = reinterpret_cast(&x);
char tmp;
@@ -132,7 +132,7 @@ namespace endian
*(rep+4) = tmp;
}
- inline void flip(int16_t source, int16_t& target)
+ inline void invert(int16_t source, int16_t& target)
{
const char* s (reinterpret_cast(&source));
char * t (reinterpret_cast(&target) + sizeof(target) - 1);
@@ -140,7 +140,7 @@ namespace endian
*--t = *++s;
}
- inline void flip(int32_t source, int32_t& target)
+ inline void invert(int32_t source, int32_t& target)
{
const char* s (reinterpret_cast(&source));
char * t (reinterpret_cast(&target) + sizeof(target) - 1);
@@ -150,7 +150,7 @@ namespace endian
*--t = *++s;
}
- inline void flip(int64_t source, int64_t& target)
+ inline void invert(int64_t source, int64_t& target)
{
const char* s (reinterpret_cast(&source));
char * t (reinterpret_cast(&target) + sizeof(target) - 1);
@@ -164,7 +164,7 @@ namespace endian
*--t = *++s;
}
- inline void flip(uint16_t source, uint16_t& target)
+ inline void invert(uint16_t source, uint16_t& target)
{
const char* s (reinterpret_cast(&source));
char * t (reinterpret_cast(&target) + sizeof(target) - 1);
@@ -172,7 +172,7 @@ namespace endian
*--t = *++s;
}
- inline void flip(uint32_t source, uint32_t& target)
+ inline void invert(uint32_t source, uint32_t& target)
{
const char* s (reinterpret_cast(&source));
char * t (reinterpret_cast(&target) + sizeof(target) - 1);
@@ -182,7 +182,7 @@ namespace endian
*--t = *++s;
}
- inline void flip(uint64_t source, uint64_t& target)
+ inline void invert(uint64_t source, uint64_t& target)
{
const char* s (reinterpret_cast(&source));
char * t (reinterpret_cast(&target) + sizeof(target) - 1);
@@ -197,23 +197,23 @@ namespace endian
}
#ifdef BOOST_LITTLE_ENDIAN
- template inline void native_to_big(T& x) { flip(x); }
+ template inline void native_to_big(T& x) { invert(x); }
template inline void native_to_little(T&) {}
- template inline void big_to_native(T& x) { flip(x); }
+ template inline void big_to_native(T& x) { invert(x); }
template inline void little_to_native(T&) {}
- template inline void native_to_big(T source, T& target) { flip(source, target); }
+ template inline void native_to_big(T source, T& target) { invert(source, target); }
template inline void native_to_little(T source, T& target) { target = source; }
- template inline void big_to_native(T source, T& target) { flip(source, target); }
+ template inline void big_to_native(T source, T& target) { invert(source, target); }
template inline void little_to_native(T source, T& target) { target = source; }
#else
template inline void native_to_big(T&) {}
- template inline void native_to_little(T& x) { flip(x); }
+ template inline void native_to_little(T& x) { invert(x); }
template inline void big_to_native(T&) {}
- template inline void little_to_native(T& x) { flip(x); }
+ template inline void little_to_native(T& x) { invert(x); }
template inline void native_to_big(T native, T& big) { target = source; }
- template inline void native_to_little(T native, T& little) { flip(source, target); }
+ template inline void native_to_little(T native, T& little) { invert(source, target); }
template inline void big_to_native(T big, T& native) { target = source; }
- template inline void little_to_native(T little, T& native) { flip(source, target); }
+ template inline void little_to_native(T little, T& native) { invert(source, target); }
#endif
} // namespace endian
diff --git a/libs/endian/doc/conversion.html b/libs/endian/doc/conversion.html
index 55937e9..acd1071 100644
--- a/libs/endian/doc/conversion.html
+++ b/libs/endian/doc/conversion.html
@@ -32,62 +32,103 @@
-
+Header boost/endian/conversion.hpp
+provides functions that convert built-in
+integers from the native byte ordering to or from big or little endian byte
+ordering.
-Header <boost/endian/conversion>
-Synopsis
+
+
+
namespace boost
{
namespace endian
{
+ // invert: verb: put upside down or in the opposite position, order, or arrangement.
+
// unconditional modifying (i.e. in-place) endianness reversal
- inline void flip(int16_t& x);
- inline void flip(int32_t& x);
- inline void flip(int64_t& x);
- inline void flip(uint16_t& x);
- inline void flip(uint32_t& x);
- inline void flip(uint64_t& x);
+ inline void invert(int16_t& x);
+ inline void invert(int32_t& x);
+ inline void invert(int64_t& x);
+ inline void invert(uint16_t& x);
+ inline void invert(uint32_t& x);
+ inline void invert(uint64_t& x);
// unconditional non-modifying endianness reversing copy
- inline void flip(int16_t source, int16_t& target);
- inline void flip(int32_t source, int32_t& target);
- inline void flip(int64_t source, int64_t& target);
- inline void flip(uint16_t source, uint16_t& target);
- inline void flip(uint32_t source, uint32_t& target);
- inline void flip(uint64_t source, uint64_t& target);
+ inline void invert(int16_t source, int16_t& target);
+ inline void invert(int32_t source, int32_t& target);
+ inline void invert(int64_t source, int64_t& target);
+ inline void invert(uint16_t source, uint16_t& target);
+ inline void invert(uint32_t source, uint32_t& target);
+ inline void invert(uint64_t source, uint64_t& target);
- // conditional modifying (i.e. in-place) endianness reversal;
- // no effect if native endianness and specified endianness are the same
+ // conditional modifying (i.e. in-place) endianness reversal
- 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
+ template <class T> void native_to_big(T& x);
+ template <class T> void native_to_little(T& x);
+ template <class T> void big_to_native(T& x);
+ template <class T> void little_to_native(T& x);
- // 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
+ // non-modifying copy conditionally reversing 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);
-
-} // namespace endian
+ template <class T> void native_to_big(T source, T& target);
+ template <class T> void native_to_little(T source, T& target);
+ template <class T> void big_to_native(T source, T& target);
+ template <class T> void little_to_native(T source, T& target);
+
+} // namespace endian
} // namespace boost
+Members
+inline void invert(int16_t& x);
+inline void invert(int32_t& x);
+inline void invert(int64_t& x);
+inline void invert(uint16_t& x);
+inline void invert(uint32_t& x);
+inline void invert(uint64_t& x);
+
+ Effects: Reverses the byte order of x
.
+
+inline void invert(int16_t source, int16_t& target);
+inline void invert(int32_t source, int32_t& target);
+inline void invert(int64_t source, int64_t& target);
+inline void invert(uint16_t source, uint16_t& target);
+inline void invert(uint32_t source, uint32_t& target);
+inline void invert(uint64_t source, uint64_t& target);
+
+ Effects: Copies source
to target
,
+ reversing the byte order.
+
+template <class T> void native_to_big(T& x);
+template <class T> void native_to_little(T& x);
+template <class T> void big_to_native(T& x);
+template <class T> void little_to_native(T& x);
+
+ Effects: If the native byte ordering and indicated byte
+ ordering are different, invert(x)
, otherwise no effect.
+
+template <class T> void native_to_big(T source, T& target);
+template <class T> void native_to_little(T source, T& target);
+template <class T> void big_to_native(T source, T& target);
+template <class T> void little_to_native(T source, T& target);
+
+ Effects: If the native byte ordering and indicated byte
+ ordering are different, invert(source, target)
, otherwise
+ target = source
.
+
+Tomas Puverle was instrumental in identifying and articulating the need to
+support endian conversion as separate from endian types.
Last revised:
-27 May, 2011
+03 September, 2011
© Copyright Beman Dawes, 2011
Distributed under the Boost Software License, Version 1.0. See
www.boost.org/ LICENSE_1_0.txt
-
-