diff --git a/doc/bikeshed.txt b/doc/bikeshed.txt index aedc22d..9d26f54 100644 --- a/doc/bikeshed.txt +++ b/doc/bikeshed.txt @@ -8,17 +8,17 @@ reverse_endianness reverse_endianness_in_place endian_reverse endian_reverse_in_place " endian_reverse_in_situ " endian_reverse_here - " endian_reverse_this - " endian_reverse_self - " endian_reverse_arg - " endian_reverse_in + " endian_reverse_this <----- + " endian_reverse_self + " endian_reverse_arg + " endian_reverse_in reverse reverse_in_place reverse_endian reverse_endian_in_place swap_endianness swap_endianness_in_place swap_endian swap_endian_in_place -endian_swap endian_swap_in_place +endian_swap endian_swap_this flip_endianness flip_endianness_in_place flip_endian flip_endian_in_place @@ -30,29 +30,28 @@ reverse_order reverse_order_in_place Key points: -* These names are defined in a user namespace as customization points to be found by +* The above names are defined in a user namespace as customization points to be found by ADL, and so cannot depend on the enclosing namespace name to signal readers that they are related to endianness. -* These functions are rarely called directly by user code, which is more likely to use +* The above functions are rarely called directly by user code, which is more likely to use the various conditional functions instead. So explicitness is more important than brevity. -big_to_native native_to_big reverse_unless_native_big little_to_native native_to_little reverse_unless_native_little - reverse_if_not_big - reverse_if_little - reverse_unless_big +Conditional names -big_to_host host_to_big reverse_unless_host_big - reverse_if_host_little +big_to_native native_to_big little_to_native native_to_little + +big_to_host host_to_big + be_to_ne ne_to_be -from_big, to_big, reverse_unless_big +from_big, to_big big_to_native big_to_native native_to_big native_to_big -reverse_unless_native_big ------ <------ -conditional_reverse reverse_unless_same<...>() <------ -runtime_conditional_reverse reverse_unless_same() <------ + +conditional_reverse runtime_conditional_reverse +conditional_reverse conditional_reverse <------ merriam-webster.com/dictionary diff --git a/doc/buffers.html b/doc/buffers.html index f6dbb33..6007965 100644 --- a/doc/buffers.html +++ b/doc/buffers.html @@ -1,4 +1,4 @@ - + @@ -515,7 +515,7 @@ is a constant of type value_type with Nbits low-order bits set to one.

Remarks: If Align is align::yes then endianness conversion if required is performed by -boost::endian::reverse_endianness.

+boost::endian::endian_reverse.

endian_buffer& operator=(T v) noexcept;
@@ -525,7 +525,7 @@ boost::endian::reverse_endianness.

Returns: *this.

Remarks: If Align is align::yes then endianness conversion if required is performed by -boost::endian::reverse_endianness.

+boost::endian::endian_reverse.

value_type value() const noexcept;
@@ -533,7 +533,7 @@ boost::endian::reverse_endianness.

if necessary and having the endianness of the native platform.

Remarks: If Align is align::yes then endianness conversion if required is performed by -boost::endian::reverse_endianness.

+boost::endian::endian_reverse.

const char* data() const noexcept;
diff --git a/doc/conversion.html b/doc/conversion.html index 9203108..be55728 100644 --- a/doc/conversion.html +++ b/doc/conversion.html @@ -1,4 +1,4 @@ - + @@ -18,7 +18,7 @@ boost.png (6897 bytes) - Endian Conversion Functions + Endian Conversion Functions @@ -96,16 +96,16 @@ namespace endian native = implementation-defined // same as order::big or order::little }; - int8_t reverse_endianness(int8_t x) noexcept; - int16_t reverse_endianness(int16_t x) noexcept; - int32_t reverse_endianness(int32_t x) noexcept; - int64_t reverse_endianness(int64_t x) noexcept; - uint8_t reverse_endianness(uint8_t x) noexcept; - uint16_t reverse_endianness(uint16_t x) noexcept; - uint32_t reverse_endianness(uint32_t x) noexcept; - uint64_t reverse_endianness(uint64_t x) noexcept; - float reverse_endianness(float x) noexcept; - double reverse_endianness(double x) noexcept; + int8_t endian_reverse(int8_t x) noexcept; + int16_t endian_reverse(int16_t x) noexcept; + int32_t endian_reverse(int32_t x) noexcept; + int64_t endian_reverse(int64_t x) noexcept; + uint8_t endian_reverse(uint8_t x) noexcept; + uint16_t endian_reverse(uint16_t x) noexcept; + uint32_t endian_reverse(uint32_t x) noexcept; + uint64_t endian_reverse(uint64_t x) noexcept; + float endian_reverse(float x) noexcept; + double endian_reverse(double x) noexcept; template <class Reversible> Reversible big_to_native(Reversible x) noexcept; @@ -122,7 +122,7 @@ namespace endian order order1, order order2) noexcept; template <class Reversible> - void reverse_endianness_in_place(Reversible& x) noexcept; + void endian_reverse_in_place(Reversible& x) noexcept; template <class Reversible> void big_to_native_in_place(Reversible& x) noexcept; @@ -160,7 +160,7 @@ instantiating a template.

-

reverse_endianness(x) +

endian_reverse(x) x is a value of a possibly const type convertible to Reversible. @@ -170,7 +170,7 @@ instantiating a template.

- reverse_endianness_in_place(x) + endian_reverse_in_place(x) x is a modifiable lvalue of type Reversible. @@ -186,10 +186,10 @@ modifiable lvalue of type Reversible. non-member function in the same namespace as the UDT itself so that the function can be found by argument dependent lookup (ADL).  —end note]

-

[Note: Because there is a function template for reverse_endianness_in_place -that calls reverse_endianness, only reverse_endianness +

[Note: Because there is a function template for endian_reverse_in_place +that calls endian_reverse, only endian_reverse is required for a user-defined type to meet the Reversible -requirements. User-defined types may provide reverse_endianness_in_place +requirements. User-defined types may provide endian_reverse_in_place for improved efficiency. —end note]

@@ -201,28 +201,28 @@ implementation.

The endianness reversal function templates that return values are required to perform reversal of endianness if needed by making an unqualified -call to reverse_endianness(argument), as described in the +call to endian_reverse(argument), as described in the preceding table.

The endianness reversal function templates that modify their argument in -place, except reverse_endianness_in_place itself, are required to perform reversal of endianness if needed by making an -unqualified call to reverse_endianness_in_place(argument), +place, except endian_reverse_in_place itself, are required to perform reversal of endianness if needed by making an +unqualified call to endian_reverse_in_place(argument), as described in the preceding table.

See udt_conversion_example.cpp for an example user-defined type.

Functions

-
int8_t   reverse_endianness(int8_t x) noexcept;
-int16_t  reverse_endianness(int16_t x) noexcept;
-int32_t  reverse_endianness(int32_t x) noexcept;
-int64_t  reverse_endianness(int64_t x) noexcept;
-uint8_t  reverse_endianness(uint8_t x) noexcept;
-uint16_t reverse_endianness(uint16_t x) noexcept;
-uint32_t reverse_endianness(uint32_t x) noexcept;
-uint64_t reverse_endianness(uint64_t x) noexcept;
-float    reverse_endianness(float x) noexcept;
-double   reverse_endianness(double x) noexcept;
+
int8_t   endian_reverse(int8_t x) noexcept;
+int16_t  endian_reverse(int16_t x) noexcept;
+int32_t  endian_reverse(int32_t x) noexcept;
+int64_t  endian_reverse(int64_t x) noexcept;
+uint8_t  endian_reverse(uint8_t x) noexcept;
+uint16_t endian_reverse(uint16_t x) noexcept;
+uint32_t endian_reverse(uint32_t x) noexcept;
+uint64_t endian_reverse(uint64_t x) noexcept;
+float    endian_reverse(float x) noexcept;
+double   endian_reverse(double x) noexcept;

Returns: x, with the order of its constituent bytes reversed.

@@ -254,22 +254,22 @@ Reversible native_to_little(Reversible x) noexcept; Reversible conditional_reverse(Reversible x) noexcept;

Returns: x if O1 == O2, otherwise - reverse_endianness(x).

-

Remarks: Whether x or reverse_endianness(x) + endian_reverse(x).

+

Remarks: Whether x or endian_reverse(x) is to be returned shall be determined at compile time.

template <class Reversible>
 Reversible runtime_conditional_reverse(Reversible x,
       order order1, order order2) noexcept; 
-

Returns: order1 == order2 ? x : reverse_endianness(x).

+

Returns: order1 == order2 ? x : endian_reverse(x).

template <class Reversible>
-void reverse_endianness_in_place(Reversible& x) noexcept; 
+void endian_reverse_in_place(Reversible& x) noexcept;
-

Effects: x = reverse_endianness(x).

+

Effects: x = endian_reverse(x).

template <class Reversible>
@@ -303,7 +303,7 @@ void native_to_little_in_place(Reversible& x) noexcept; 
void conditional_reverse_in_place(Reversible& x) noexcept;

Effects: None if O1 == O2, otherwise - reverse_endianness_in_place(x).

+ endian_reverse_in_place(x).

Remarks: Which effect applies shall be determined at compile time.

template <class Reversible>
@@ -312,7 +312,7 @@ void runtime_conditional_reverse_in_place(Reversible& x,
 
 
 
-

Effects: If order1 == order2 then reverse_endianness_in_place(x).

+

Effects: If order1 == order2 then endian_reverse_in_place(x).

@@ -321,7 +321,7 @@ void runtime_conditional_reverse_in_place(Reversible& x,

See the Endian home page FAQ for a library-wide FAQ.

-

Why are the template versions of reverse() and reverse_endianness() +

Why are the template versions of reverse() and endian_reverse() in a detail namespace?

@@ -347,7 +347,7 @@ provided.

Acknowledgements

Tomas Puverle was instrumental in identifying and articulating the need to support endian conversion as separate from endian integer types. Phil Endecott suggested the form of the value returning signatures. Vicente Botet and other reviewers suggested supporting floating point types and user defined types. General reverse template implementation approach using std::reverse suggested by Mathias Gaunard. Portable implementation approach for 16, 32, and 64-bit integers suggested by tymofey, with avoidance of undefined behavior as suggested by Giovanni Piero Deretta, and a further refinement suggested by Pyry Jahkola. Intrinsic builtins implementation approach for 16, 32, and 64-bit integers suggested by several reviewers, and by David Stone, who provided his Boost licensed macro implementation that became the starting point for boost/endian/detail/intrinsic.hpp. -Pierre Talbot provided the int8_t reverse_endianness() and templated +Pierre Talbot provided the int8_t endian_reverse() and templated reverse() implementations.


Last revised: diff --git a/doc/index.html b/doc/index.html index d6ebcfe..2db2416 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1,4 +1,4 @@ - + @@ -678,7 +678,7 @@ and 16, 32, and 64-bit aligned integers.

  • order::native is now a synonym for order::big or order::little according to the endianness of the platform, as requested. This reduces the number of template specializations required.
  • -
  • reverse_endianness() overloads for int8_t and +
  • endian_reverse() overloads for int8_t and uint8_t have been added for improved generality. (Pierre Talbot)
  • Overloads of reverse() have been replaced with a single reverse() template. (Pierre Talbot)
  • diff --git a/example/udt_conversion_example.cpp b/example/udt_conversion_example.cpp index 64f304a..6696350 100644 --- a/example/udt_conversion_example.cpp +++ b/example/udt_conversion_example.cpp @@ -20,52 +20,54 @@ using std::cout; using std::endl; using boost::int32_t; -class UDT +namespace user { -public: - UDT() : id_(0), value_(0.0) {desc_[0] = '\0';} - UDT(int32_t id, float value, const char* desc) : id_(id), value_(value) + class UDT { - std::strncpy(desc_, desc, sizeof(desc_)-1); - desc_[sizeof(desc_)-1] = '\0'; - } - int32_t id() const {return id_;} - float value() const {return value_;} - const char* desc() const {return desc_;} - void id(int32_t x) {id_ = x;} - void value(float v) {value_ = v;} - void desc(const char* s) + public: + UDT() : id_(0), value_(0.0) {desc_[0] = '\0';} + UDT(int32_t id, float value, const char* desc) : id_(id), value_(value) + { + std::strncpy(desc_, desc, sizeof(desc_)-1); + desc_[sizeof(desc_)-1] = '\0'; + } + int32_t id() const {return id_;} + float value() const {return value_;} + const char* desc() const {return desc_;} + void id(int32_t x) {id_ = x;} + void value(float v) {value_ = v;} + void desc(const char* s) + { + std::strncpy(desc_, s, sizeof(desc_)-1); + desc_[sizeof(desc_-1)] = '\0'; + } + + friend void endian_reverse_in_place(UDT&); + + private: + int32_t id_; + float value_; + char desc_[56]; // '/0' + }; + + void endian_reverse_in_place(UDT& x) { - std::strncpy(desc_, s, sizeof(desc_)-1); - desc_[sizeof(desc_-1)] = '\0'; + boost::endian::endian_reverse_in_place(x.id_); + boost::endian::endian_reverse_in_place(x.value_); } - - friend UDT reverse_endianness(const UDT&); - friend void reverse_endianness_in_place(UDT&); - -private: - int32_t id_; - float value_; - char desc_[56]; // '/0' -}; - -void reverse_endianness_in_place(UDT& x) -{ - reverse_endianness_in_place(x.id_); - reverse_endianness_in_place(x.value_); } int main(int, char* []) { - UDT x(1, 1.2345f, "Bingo!"); + user::UDT x(1, 1.2345f, "Bingo!"); //cout << std::hex; cout << "(1) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl; - reverse_endianness_in_place(x); + user::endian_reverse_in_place(x); cout << "(2) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl; - reverse_endianness_in_place(x); + endian_reverse_in_place(x); cout << "(3) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl; conditional_reverse_in_place(x); diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index 00ae479..f29c313 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -44,48 +44,48 @@ namespace endian // user-defined types (UDTs) // // // // All return-by-value conversion function templates are required to be implemented in // -// terms of an unqualified call to "reverse_endianness(x)", a function returning the // +// terms of an unqualified call to "endian_reverse(x)", a function returning the // // value of x with endianness reversed. This provides a customization point for any // -// UDT that provides a "reverse_endianness" free-function meeting the requirements. // +// UDT that provides a "endian_reverse" free-function meeting the requirements. // // It must be defined in the same namespace as the UDT itself so that it will be found // // by argument dependent lookup (ADL). // // // //--------------------------------------------------------------------------------------// // customization for built-in arithmetic types - inline int8_t reverse_endianness(int8_t x) BOOST_NOEXCEPT; - inline int16_t reverse_endianness(int16_t x) BOOST_NOEXCEPT; - inline int32_t reverse_endianness(int32_t x) BOOST_NOEXCEPT; - inline int64_t reverse_endianness(int64_t x) BOOST_NOEXCEPT; - inline uint8_t reverse_endianness(uint8_t x) BOOST_NOEXCEPT; - inline uint16_t reverse_endianness(uint16_t x) BOOST_NOEXCEPT; - inline uint32_t reverse_endianness(uint32_t x) BOOST_NOEXCEPT; - inline uint64_t reverse_endianness(uint64_t x) BOOST_NOEXCEPT; + inline int8_t endian_reverse(int8_t x) BOOST_NOEXCEPT; + inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT; + inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT; + inline int64_t endian_reverse(int64_t x) BOOST_NOEXCEPT; + inline uint8_t endian_reverse(uint8_t x) BOOST_NOEXCEPT; + inline uint16_t endian_reverse(uint16_t x) BOOST_NOEXCEPT; + inline uint32_t endian_reverse(uint32_t x) BOOST_NOEXCEPT; + inline uint64_t endian_reverse(uint64_t x) BOOST_NOEXCEPT; // TODO: Track progress of Floating-Point Typedefs Having Specified Widths proposal (N3626) - inline float reverse_endianness(float x) BOOST_NOEXCEPT; - inline double reverse_endianness(double x) BOOST_NOEXCEPT; + inline float endian_reverse(float x) BOOST_NOEXCEPT; + inline double endian_reverse(double x) BOOST_NOEXCEPT; // reverse byte order unless native endianness is big template inline Reversible big_to_native(Reversible x) BOOST_NOEXCEPT; - // Returns: x if native endian order is big, otherwise reverse_endianness(x) + // Returns: x if native endian order is big, otherwise endian_reverse(x) template inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT; - // Returns: x if native endian order is big, otherwise reverse_endianness(x) + // Returns: x if native endian order is big, otherwise endian_reverse(x) // reverse byte order unless native endianness is little template inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT; - // Returns: x if native endian order is little, otherwise reverse_endianness(x) + // Returns: x if native endian order is little, otherwise endian_reverse(x) template inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT; - // Returns: x if native endian order is little, otherwise reverse_endianness(x) + // Returns: x if native endian order is little, otherwise endian_reverse(x) // generic conditional reverse byte order template inline Reversible conditional_reverse(Reversible from) BOOST_NOEXCEPT; // Returns: If From == To have different values, from. - // Otherwise reverse_endianness(from). + // Otherwise endian_reverse(from). // Remarks: The From == To test, and as a consequence which form the return takes, is // is determined at compile time. @@ -93,7 +93,7 @@ namespace endian template inline Reversible runtime_conditional_reverse(Reversible from, BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) BOOST_NOEXCEPT; - // Returns: from_order == to_order ? from : reverse_endianness(from). + // Returns: from_order == to_order ? from : endian_reverse(from). //------------------------------------------------------------------------------------// @@ -113,7 +113,7 @@ namespace endian // user-defined types (UDTs) // // // // All reverse in place function templates are required to be implemented in terms // - // of an unqualified call to "reverse_endianness_in_place(x)", a function reversing // + // of an unqualified call to "endian_reverse_in_place(x)", a function reversing // // the endianness of x, which is a non-const reference. This provides a // // customization point for any UDT that provides a "reverse_in_place" free-function // // meeting the requirements. The free-function must be declared in the same // @@ -124,24 +124,24 @@ namespace endian // reverse in place template - inline void reverse_endianness_in_place(Value& x) BOOST_NOEXCEPT; - // Effects: x = reverse_endianness(x) + inline void endian_reverse_in_place(Value& x) BOOST_NOEXCEPT; + // Effects: x = endian_reverse(x) // reverse in place unless native endianness is big template inline void big_to_native_in_place(Reversible& x) BOOST_NOEXCEPT; - // Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x) + // Effects: none if native byte-order is big, otherwise endian_reverse_in_place(x) template inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT; - // Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x) + // Effects: none if native byte-order is big, otherwise endian_reverse_in_place(x) // reverse in place unless native endianness is little template inline void little_to_native_in_place(Reversible& x) BOOST_NOEXCEPT; - // Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x); + // Effects: none if native byte-order is little, otherwise endian_reverse_in_place(x); template inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT; - // Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x); + // Effects: none if native byte-order is little, otherwise endian_reverse_in_place(x); // generic conditional reverse in place template @@ -160,11 +160,11 @@ namespace endian // generic reverse function template implementation approach using std::reverse // suggested by Mathias Gaunard. Primary motivation for inclusion is to have an // independent implementation to test against. Secondary motivation is use by - // floating-point reverse_endianness, but that use is likely to be replace by a + // floating-point endian_reverse, but that use is likely to be replace by a // more tailored floating-point implementation. template - inline T std_reverse_endianness(T x) BOOST_NOEXCEPT + inline T std_endian_reverse(T x) BOOST_NOEXCEPT { T tmp(x); std::reverse( @@ -196,12 +196,12 @@ namespace endian // // //--------------------------------------------------------------------------------------// - inline int8_t reverse_endianness(int8_t x) BOOST_NOEXCEPT + inline int8_t endian_reverse(int8_t x) BOOST_NOEXCEPT { return x; } - inline int16_t reverse_endianness(int16_t x) BOOST_NOEXCEPT + inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT { # ifdef BOOST_ENDIAN_NO_INTRINSICS return (static_cast(x) << 8) @@ -211,7 +211,7 @@ namespace endian # endif } - inline int32_t reverse_endianness(int32_t x) BOOST_NOEXCEPT + inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT { # ifdef BOOST_ENDIAN_NO_INTRINSICS uint32_t step16; @@ -224,7 +224,7 @@ namespace endian # endif } - inline int64_t reverse_endianness(int64_t x) BOOST_NOEXCEPT + inline int64_t endian_reverse(int64_t x) BOOST_NOEXCEPT { # ifdef BOOST_ENDIAN_NO_INTRINSICS uint64_t step32, step16; @@ -238,12 +238,12 @@ namespace endian # endif } - inline uint8_t reverse_endianness(uint8_t x) BOOST_NOEXCEPT + inline uint8_t endian_reverse(uint8_t x) BOOST_NOEXCEPT { return x; } - inline uint16_t reverse_endianness(uint16_t x) BOOST_NOEXCEPT + inline uint16_t endian_reverse(uint16_t x) BOOST_NOEXCEPT { # ifdef BOOST_ENDIAN_NO_INTRINSICS return (x << 8) @@ -253,7 +253,7 @@ namespace endian # endif } - inline uint32_t reverse_endianness(uint32_t x) BOOST_NOEXCEPT + inline uint32_t endian_reverse(uint32_t x) BOOST_NOEXCEPT { # ifdef BOOST_ENDIAN_NO_INTRINSICS uint32_t step16; @@ -266,7 +266,7 @@ namespace endian # endif } - inline uint64_t reverse_endianness(uint64_t x) BOOST_NOEXCEPT + inline uint64_t endian_reverse(uint64_t x) BOOST_NOEXCEPT { # ifdef BOOST_ENDIAN_NO_INTRINSICS uint64_t step32, step16; @@ -280,20 +280,20 @@ namespace endian # endif } - inline float reverse_endianness(float x) BOOST_NOEXCEPT + inline float endian_reverse(float x) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG(sizeof(float) == sizeof(uint32_t), "boost::endian currently supports only sizeof(float) == 4;" " please report static_assert failure to the boost mailing list"); - return detail::std_reverse_endianness(x); + return detail::std_endian_reverse(x); } - inline double reverse_endianness(double x) BOOST_NOEXCEPT + inline double endian_reverse(double x) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG(sizeof(double) == sizeof(uint64_t), "boost::endian currently supports only sizeof(double) == 8;" " please report static_assert failure to the boost mailing list"); - return detail::std_reverse_endianness(x); + return detail::std_endian_reverse(x); } template @@ -302,7 +302,7 @@ namespace endian # ifdef BOOST_BIG_ENDIAN return x; # else - return reverse_endianness(x); + return endian_reverse(x); # endif } @@ -312,7 +312,7 @@ namespace endian # ifdef BOOST_BIG_ENDIAN return x; # else - return reverse_endianness(x); + return endian_reverse(x); # endif } @@ -322,7 +322,7 @@ namespace endian # ifdef BOOST_LITTLE_ENDIAN return x; # else - return reverse_endianness(x); + return endian_reverse(x); # endif } @@ -332,14 +332,14 @@ namespace endian # ifdef BOOST_LITTLE_ENDIAN return x; # else - return reverse_endianness(x); + return endian_reverse(x); # endif } namespace detail { - // Primary template and specializations to support reverse_endianness(). - // See rationale in reverse_endianness() below. + // Primary template and specializations to support endian_reverse(). + // See rationale in endian_reverse() below. template class value_converter ; // primary template template class value_converter @@ -347,9 +347,9 @@ namespace endian template class value_converter {public: T operator()(T x) BOOST_NOEXCEPT {return x;}}; template class value_converter - {public: T operator()(T x) BOOST_NOEXCEPT {return reverse_endianness(x);}}; + {public: T operator()(T x) BOOST_NOEXCEPT {return endian_reverse(x);}}; template class value_converter - {public: T operator()(T x) BOOST_NOEXCEPT {return reverse_endianness(x);}}; + {public: T operator()(T x) BOOST_NOEXCEPT {return endian_reverse(x);}}; } // generic conditional reverse @@ -367,7 +367,7 @@ namespace endian inline Reversible runtime_conditional_reverse(Reversible from, BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) BOOST_NOEXCEPT { - return from_order == to_order ? from : reverse_endianness(from); + return from_order == to_order ? from : endian_reverse(from); } //--------------------------------------------------------------------------------------// @@ -376,9 +376,9 @@ namespace endian // reverse in place template - inline void reverse_endianness_in_place(Value& x) BOOST_NOEXCEPT + inline void endian_reverse_in_place(Value& x) BOOST_NOEXCEPT { - x = reverse_endianness(x); + x = endian_reverse(x); } template @@ -386,7 +386,7 @@ namespace endian inline void big_to_native_in_place(Reversible&) BOOST_NOEXCEPT {} # else inline void big_to_native_in_place(Reversible& x) BOOST_NOEXCEPT - { reverse_endianness_in_place(x); } + { endian_reverse_in_place(x); } # endif template # ifdef BOOST_BIG_ENDIAN @@ -394,7 +394,7 @@ namespace endian # else inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT { - reverse_endianness_in_place(x); + endian_reverse_in_place(x); } # endif @@ -403,7 +403,7 @@ namespace endian inline void little_to_native_in_place(Reversible&) BOOST_NOEXCEPT {} # else inline void little_to_native_in_place(Reversible& x) BOOST_NOEXCEPT - { reverse_endianness_in_place(x); } + { endian_reverse_in_place(x); } # endif template # ifdef BOOST_LITTLE_ENDIAN @@ -411,15 +411,15 @@ namespace endian # else inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT { - reverse_endianness_in_place(x); + endian_reverse_in_place(x); } # endif namespace detail { // Primary template and specializations support generic - // reverse_endianness_in_place(). - // See rationale in reverse_endianness_in_place() below. + // endian_reverse_in_place(). + // See rationale in endian_reverse_in_place() below. template class converter; // primary template template class converter @@ -427,9 +427,9 @@ namespace endian template class converter {public: void operator()(T&) BOOST_NOEXCEPT {/*no effect*/}}; template class converter - {public: void operator()(T& x) BOOST_NOEXCEPT { reverse_endianness_in_place(x); }}; + {public: void operator()(T& x) BOOST_NOEXCEPT { endian_reverse_in_place(x); }}; template class converter - {public: void operator()(T& x) BOOST_NOEXCEPT { reverse_endianness_in_place(x); }}; + {public: void operator()(T& x) BOOST_NOEXCEPT { endian_reverse_in_place(x); }}; } // namespace detail // generic conditional reverse in place @@ -450,7 +450,7 @@ namespace endian BOOST_NOEXCEPT { if (from_order != to_order) - reverse_endianness_in_place(x); + endian_reverse_in_place(x); } diff --git a/test/conversion_test.cpp b/test/conversion_test.cpp index 88dbfa3..f705a1a 100644 --- a/test/conversion_test.cpp +++ b/test/conversion_test.cpp @@ -139,17 +139,17 @@ namespace # ifdef BOOST_BIG_ENDIAN BOOST_TEST_EQ(native, big); - BOOST_TEST_EQ(be::detail::std_reverse_endianness(native), little); + BOOST_TEST_EQ(be::detail::std_endian_reverse(native), little); # else - BOOST_TEST_EQ(be::detail::std_reverse_endianness(native), big); + BOOST_TEST_EQ(be::detail::std_endian_reverse(native), big); BOOST_TEST_EQ(native, little); # endif // value-by-value tests // unconditional reverse - BOOST_TEST_EQ(be::reverse_endianness(big), little); - BOOST_TEST_EQ(be::reverse_endianness(little), big); + BOOST_TEST_EQ(be::endian_reverse(big), little); + BOOST_TEST_EQ(be::endian_reverse(little), big); // conditional reverse BOOST_TEST_EQ(be::native_to_big(native), big); @@ -201,8 +201,8 @@ namespace T x; // unconditional reverse - x = big; be::reverse_endianness_in_place(x); BOOST_TEST_EQ(x, little); - x = little; be::reverse_endianness_in_place(x); BOOST_TEST_EQ(x, big); + x = big; be::endian_reverse_in_place(x); BOOST_TEST_EQ(x, little); + x = little; be::endian_reverse_in_place(x); BOOST_TEST_EQ(x, big); // conditional reverse x = native; be::native_to_big_in_place(x); BOOST_TEST_EQ(x, big); @@ -279,14 +279,14 @@ namespace udt.member3 = native; tmp = be::conditional_reverse(udt); - BOOST_TEST_EQ(tmp.member1, be::reverse_endianness(big)); - BOOST_TEST_EQ(tmp.member2, be::reverse_endianness(little)); - BOOST_TEST_EQ(tmp.member3, be::reverse_endianness(native)); + BOOST_TEST_EQ(tmp.member1, be::endian_reverse(big)); + BOOST_TEST_EQ(tmp.member2, be::endian_reverse(little)); + BOOST_TEST_EQ(tmp.member3, be::endian_reverse(native)); be::conditional_reverse_in_place(udt); - BOOST_TEST_EQ(udt.member1, be::reverse_endianness(big)); - BOOST_TEST_EQ(udt.member2, be::reverse_endianness(little)); - BOOST_TEST_EQ(udt.member3, be::reverse_endianness(native)); + BOOST_TEST_EQ(udt.member1, be::endian_reverse(big)); + BOOST_TEST_EQ(udt.member2, be::endian_reverse(little)); + BOOST_TEST_EQ(udt.member3, be::endian_reverse(native)); udt.member1 = big; udt.member2 = little; @@ -311,7 +311,7 @@ namespace namespace user { - // UDT1 supplies both reverse_endianness and reverse_endianness_in_place + // UDT1 supplies both endian_reverse and endian_reverse_in_place struct UDT1 { int64_t member1; @@ -319,23 +319,23 @@ namespace int64_t member3; }; - UDT1 reverse_endianness(const UDT1& udt) BOOST_NOEXCEPT + UDT1 endian_reverse(const UDT1& udt) BOOST_NOEXCEPT { UDT1 tmp; - tmp.member1 = boost::endian::reverse_endianness(udt.member1); - tmp.member2 = boost::endian::reverse_endianness(udt.member2); - tmp.member3 = boost::endian::reverse_endianness(udt.member3); + tmp.member1 = boost::endian::endian_reverse(udt.member1); + tmp.member2 = boost::endian::endian_reverse(udt.member2); + tmp.member3 = boost::endian::endian_reverse(udt.member3); return tmp; } - void reverse_endianness_in_place(UDT1& udt) BOOST_NOEXCEPT + void endian_reverse_in_place(UDT1& udt) BOOST_NOEXCEPT { - boost::endian::reverse_endianness_in_place(udt.member1); - boost::endian::reverse_endianness_in_place(udt.member2); - boost::endian::reverse_endianness_in_place(udt.member3); + boost::endian::endian_reverse_in_place(udt.member1); + boost::endian::endian_reverse_in_place(udt.member2); + boost::endian::endian_reverse_in_place(udt.member3); } - // UDT2 supplies only reverse_endianness + // UDT2 supplies only endian_reverse struct UDT2 { int64_t member1; @@ -343,16 +343,16 @@ namespace int64_t member3; }; - UDT2 reverse_endianness(const UDT2& udt) BOOST_NOEXCEPT + UDT2 endian_reverse(const UDT2& udt) BOOST_NOEXCEPT { UDT2 tmp; - tmp.member1 = boost::endian::reverse_endianness(udt.member1); - tmp.member2 = boost::endian::reverse_endianness(udt.member2); - tmp.member3 = boost::endian::reverse_endianness(udt.member3); + tmp.member1 = boost::endian::endian_reverse(udt.member1); + tmp.member2 = boost::endian::endian_reverse(udt.member2); + tmp.member3 = boost::endian::endian_reverse(udt.member3); return tmp; } - // UDT3 supplies neither reverse_endianness nor reverse_endianness_in_place, + // UDT3 supplies neither endian_reverse nor endian_reverse_in_place, // so udt_test() should fail to compile struct UDT3 { @@ -404,7 +404,7 @@ int cpp_main(int, char * []) #ifdef BOOST_ENDIAN_COMPILE_FAIL cout << "UDT 3" << endl; - udt_test(); // should fail to compile since has not reverse_endianness() + udt_test(); // should fail to compile since has not endian_reverse() #endif return ::boost::report_errors(); diff --git a/test/msvc/endian.sln b/test/msvc/endian.sln index b38a560..2acb9c7 100644 --- a/test/msvc/endian.sln +++ b/test/msvc/endian.sln @@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uses_cases", "uses_cases\us EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "conversion_use_case", "conversion_use_case\conversion_use_case.vcxproj", "{1139E765-DE0F-497A-A7D9-EB2683521DF1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "html", "html\html.vcxproj", "{3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -130,6 +132,12 @@ Global {1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|Win32.ActiveCfg = Release|Win32 {1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|Win32.Build.0 = Release|Win32 {1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|x64.ActiveCfg = Release|Win32 + {3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}.Debug|Win32.ActiveCfg = Debug|Win32 + {3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}.Debug|Win32.Build.0 = Debug|Win32 + {3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}.Debug|x64.ActiveCfg = Debug|Win32 + {3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}.Release|Win32.ActiveCfg = Release|Win32 + {3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}.Release|Win32.Build.0 = Release|Win32 + {3E0B428D-FDBB-40AF-ACA8-DE677B88D39C}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE