diff --git a/doc/types.html b/doc/arithmetic.html similarity index 93% rename from doc/types.html rename to doc/arithmetic.html index af7c5ad..17040dd 100644 --- a/doc/types.html +++ b/doc/arithmetic.html @@ -5,7 +5,7 @@ -Endian Integers +Endian Arithmetic Types @@ -13,13 +13,14 @@ - +
- - +
+ -boost.png (6897 bytes) - Endian Types +boost.png (6897 bytes) + + Endian Arithmetic Types
@@ -29,7 +30,8 @@ Boost Home     Endian Home     Conversion Functions     - Endian Types + Arithmetic Types     + Buffer Types @@ -69,7 +71,7 @@ <boost/endian/conversion.hpp>
- <boost/endian/types.hpp> + <boost/endian/arithmetic.hpp>

Introduction

@@ -108,7 +110,7 @@ binary file containing four byte big-endian and little-endian integers:

#include <iostream>
 #include <cstdio>
-#include <boost/endian/types.hpp>
+#include <boost/endian/arithmetic.hpp>
 #include <boost/static_assert.hpp>
 
 using namespace boost::endian;
@@ -212,7 +214,7 @@ enum class align {no, yes}; 

One class template is provided:

template <order Order, typename T, std::size_t n_bits, align A = align::no>
-  class endian;
+  class endian_arithmetic;
 

Typedefs, such as big_int32_t, provide convenient naming @@ -227,112 +229,112 @@ conventions for common use cases:

Sizes in bits (n) - big_align_intn_t + big_intn_t big yes signed 16,32,64 - - big_align_uintn_t - big - yes - unsigned - 16,32,64 - - - big_align_floatn_t - big - yes - signed - 32,64 - - - big_intn_t - big - no - signed - 8,16,24,32,40,48,56,64 - big_uintn_t big + yes + unsigned + 16,32,64 + + + big_floatn_t + big + yes + signed + 32,64 + + + big_intn_ut + big + no + signed + 8,16,24,32,40,48,56,64 + + + big_uintn_ut + big no unsigned 8,16,24,32,40,48,56,64 - big_floatn_t + big_floatn_ut big no signed 32,64 - little_align_intn_t + little_intn_t little yes signed 16,32,64 - little_align_uintn_t + little_uintn_t little yes unsigned 16,32,64 - - little_align_floatn_t - little - yes - signed - 32,64 - - - little_intn_t - little - no - signed - 8,16,24,32,40,48,56,64 - - - little_uintn_t - little - no - unsigned - 8,16,24,32,40,48,56,64 - little_floatn_t little + yes + signed + 32,64 + + + little_intn_ut + little + no + signed + 8,16,24,32,40,48,56,64 + + + little_uintn_ut + little + no + unsigned + 8,16,24,32,40,48,56,64 + + + little_floatn_ut + little no signed 32,64 - native_align_floatn_t + native_floatn_t native yes signed 32,64 - native_intn_t + native_intn_ut native no signed 8,16,24,32,40,48,56,64 - native_uintn_t + native_uintn_ut native no unsigned 8,16,24,32,40,48,56,64 - native_floatn_t + native_floatn_ut native no signed @@ -352,7 +354,7 @@ are only available on architectures with 16, 32, and 64-bit integer types.

Note: One-byte types have identical functionality. They are provided to improve code readability and searchability.

-

Class template endian

+

Class template endian_arithmetic

An endian is an integer byte-holder with user-specified endianness, value type, size, and alignment. The usual operations on integers are supplied.

@@ -421,12 +423,12 @@ usual operations on integers are supplied.

// typedefs // aligned big endian floating point types - typedef endian<order::big, float, 32, align::yes> big_align_float32_t; - typedef endian<order::big, double, 64, align::yes> big_align_float64_t; + typedef endian<order::big, float, 32, align::yes> big_float32_t; + typedef endian<order::big, double, 64, align::yes> big_float64_t; // aligned little endian floating point types - typedef endian<order::little, float, 32, align::yes> little_align_float32_t; - typedef endian<order::little, double, 64, align::yes> little_align_float64_t; + typedef endian<order::little, float, 32, align::yes> little_float32_t; + typedef endian<order::little, double, 64, align::yes> little_float64_t; // unaligned big endian floating point types typedef endian<order::big, float, 32, align::no> big_float32un_t; @@ -437,87 +439,87 @@ usual operations on integers are supplied.

typedef endian<order::little, double, 64, align::no> little_float64un_t; // aligned big endian signed integer types - typedef endian<order::big, int16_t, 16, align::yes> big_align_int16_t; - typedef endian<order::big, int32_t, 32, align::yes> big_align_int32_t; - typedef endian<order::big, int64_t, 64, align::yes> big_align_int64_t; + typedef endian<order::big, int16_t, 16, align::yes> big_int16_t; + typedef endian<order::big, int32_t, 32, align::yes> big_int32_t; + typedef endian<order::big, int64_t, 64, align::yes> big_int64_t; // aligned big endian unsigned integer types - typedef endian<order::big, uint16_t, 16, align::yes> big_align_uint16_t; - typedef endian<order::big, uint32_t, 32, align::yes> big_align_uint32_t; - typedef endian<order::big, uint64_t, 64, align::yes> big_align_uint64_t; + typedef endian<order::big, uint16_t, 16, align::yes> big_uint16_t; + typedef endian<order::big, uint32_t, 32, align::yes> big_uint32_t; + typedef endian<order::big, uint64_t, 64, align::yes> big_uint64_t; // aligned little endian signed integer types - typedef endian<order::little, int16_t, 16, align::yes> little_align_int16_t; - typedef endian<order::little, int32_t, 32, align::yes> little_align_int32_t; - typedef endian<order::little, int64_t, 64, align::yes> little_align_int64_t; + typedef endian<order::little, int16_t, 16, align::yes> little_int16_t; + typedef endian<order::little, int32_t, 32, align::yes> little_int32_t; + typedef endian<order::little, int64_t, 64, align::yes> little_int64_t; // aligned little endian unsigned integer types - typedef endian<order::little, uint16_t, 16, align::yes> little_align_uint16_t; - typedef endian<order::little, uint32_t, 32, align::yes> little_align_uint32_t; - typedef endian<order::little, uint64_t, 64, align::yes> little_align_uint64_t; + typedef endian<order::little, uint16_t, 16, align::yes> little_uint16_t; + typedef endian<order::little, uint32_t, 32, align::yes> little_uint32_t; + typedef endian<order::little, uint64_t, 64, align::yes> little_uint64_t; // aligned native endian typedefs are not provided because // <cstdint> types are superior for that use case // unaligned big endian signed integer types - typedef endian<order::big, int_least8_t, 8> big_int8_t; - typedef endian<order::big, int_least16_t, 16> big_int16_t; - typedef endian<order::big, int_least32_t, 24> big_int24_t; - typedef endian<order::big, int_least32_t, 32> big_int32_t; - typedef endian<order::big, int_least64_t, 40> big_int40_t; - typedef endian<order::big, int_least64_t, 48> big_int48_t; - typedef endian<order::big, int_least64_t, 56> big_int56_t; - typedef endian<order::big, int_least64_t, 64> big_int64_t; + typedef endian<order::big, int_least8_t, 8> big_int8_ut; + typedef endian<order::big, int_least16_t, 16> big_int16_ut; + typedef endian<order::big, int_least32_t, 24> big_int24_ut; + typedef endian<order::big, int_least32_t, 32> big_int32_ut; + typedef endian<order::big, int_least64_t, 40> big_int40_ut; + typedef endian<order::big, int_least64_t, 48> big_int48_ut; + typedef endian<order::big, int_least64_t, 56> big_int56_ut; + typedef endian<order::big, int_least64_t, 64> big_int64_ut; // unaligned big endian unsigned integer types - typedef endian<order::big, uint_least8_t, 8> big_uint8_t; - typedef endian<order::big, uint_least16_t, 16> big_uint16_t; - typedef endian<order::big, uint_least32_t, 24> big_uint24_t; - typedef endian<order::big, uint_least32_t, 32> big_uint32_t; - typedef endian<order::big, uint_least64_t, 40> big_uint40_t; - typedef endian<order::big, uint_least64_t, 48> big_uint48_t; - typedef endian<order::big, uint_least64_t, 56> big_uint56_t; - typedef endian<order::big, uint_least64_t, 64> big_uint64_t; + typedef endian<order::big, uint_least8_t, 8> big_uint8_ut; + typedef endian<order::big, uint_least16_t, 16> big_uint16_ut; + typedef endian<order::big, uint_least32_t, 24> big_uint24_ut; + typedef endian<order::big, uint_least32_t, 32> big_uint32_ut; + typedef endian<order::big, uint_least64_t, 40> big_uint40_ut; + typedef endian<order::big, uint_least64_t, 48> big_uint48_ut; + typedef endian<order::big, uint_least64_t, 56> big_uint56_ut; + typedef endian<order::big, uint_least64_t, 64> big_uint64_ut; // unaligned little endian signed integer types - typedef endian<order::little, int_least8_t, 8> little_int8_t; - typedef endian<order::little, int_least16_t, 16> little_int16_t; - typedef endian<order::little, int_least32_t, 24> little_int24_t; - typedef endian<order::little, int_least32_t, 32> little_int32_t; - typedef endian<order::little, int_least64_t, 40> little_int40_t; - typedef endian<order::little, int_least64_t, 48> little_int48_t; - typedef endian<order::little, int_least64_t, 56> little_int56_t; - typedef endian<order::little, int_least64_t, 64> little_int64_t; + typedef endian<order::little, int_least8_t, 8> little_int8_ut; + typedef endian<order::little, int_least16_t, 16> little_int16_ut; + typedef endian<order::little, int_least32_t, 24> little_int24_ut; + typedef endian<order::little, int_least32_t, 32> little_int32_ut; + typedef endian<order::little, int_least64_t, 40> little_int40_ut; + typedef endian<order::little, int_least64_t, 48> little_int48_ut; + typedef endian<order::little, int_least64_t, 56> little_int56_ut; + typedef endian<order::little, int_least64_t, 64> little_int64_ut; // unaligned little endian unsigned integer types - typedef endian<order::little, uint_least8_t, 8> little_uint8_t; - typedef endian<order::little, uint_least16_t, 16> little_uint16_t; - typedef endian<order::little, uint_least32_t, 24> little_uint24_t; - typedef endian<order::little, uint_least32_t, 32> little_uint32_t; - typedef endian<order::little, uint_least64_t, 40> little_uint40_t; - typedef endian<order::little, uint_least64_t, 48> little_uint48_t; - typedef endian<order::little, uint_least64_t, 56> little_uint56_t; - typedef endian<order::little, uint_least64_t, 64> little_uint64_t; + typedef endian<order::little, uint_least8_t, 8> little_uint8_ut; + typedef endian<order::little, uint_least16_t, 16> little_uint16_ut; + typedef endian<order::little, uint_least32_t, 24> little_uint24_ut; + typedef endian<order::little, uint_least32_t, 32> little_uint32_ut; + typedef endian<order::little, uint_least64_t, 40> little_uint40_ut; + typedef endian<order::little, uint_least64_t, 48> little_uint48_ut; + typedef endian<order::little, uint_least64_t, 56> little_uint56_ut; + typedef endian<order::little, uint_least64_t, 64> little_uint64_ut; // unaligned native endian signed integer types - typedef implementation-defined_int8_t native_int8_t; - typedef implementation-defined_int16_t native_int16_t; - typedef implementation-defined_int24_t native_int24_t; - typedef implementation-defined_int32_t native_int32_t; - typedef implementation-defined_int40_t native_int40_t; - typedef implementation-defined_int48_t native_int48_t; - typedef implementation-defined_int56_t native_int56_t; - typedef implementation-defined_int64_t native_int64_t; + typedef implementation-defined_int8_t native_int8_ut; + typedef implementation-defined_int16_t native_int16_ut; + typedef implementation-defined_int24_t native_int24_ut; + typedef implementation-defined_int32_t native_int32_ut; + typedef implementation-defined_int40_t native_int40_ut; + typedef implementation-defined_int48_t native_int48_ut; + typedef implementation-defined_int56_t native_int56_ut; + typedef implementation-defined_int64_t native_int64_ut; // unaligned native endian unsigned integer types - typedef implementation-defined_uint8_t native_uint8_t; - typedef implementation-defined_uint16_t native_uint16_t; - typedef implementation-defined_uint24_t native_uint24_t; - typedef implementation-defined_uint32_t native_uint32_t; - typedef implementation-defined_uint40_t native_uint40_t; - typedef implementation-defined_uint48_t native_uint48_t; - typedef implementation-defined_uint56_t native_uint56_t; - typedef implementation-defined_uint64_t native_uint64_t; + typedef implementation-defined_uint8_t native_uint8_ut; + typedef implementation-defined_uint16_t native_uint16_ut; + typedef implementation-defined_uint24_t native_uint24_ut; + typedef implementation-defined_uint32_t native_uint32_ut; + typedef implementation-defined_uint40_t native_uint40_ut; + typedef implementation-defined_uint48_t native_uint48_ut; + typedef implementation-defined_uint56_t native_uint56_ut; + typedef implementation-defined_uint64_t native_uint64_ut; } // namespace endian } // namespace boost @@ -676,7 +678,7 @@ differs from endian representation size. Vicente Botet and other reviewers suggested supporting floating point types.


Last revised: -12 November, 2014

+19 November, 2014

© Copyright Beman Dawes, 2006-2009, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

diff --git a/doc/conversion.html b/doc/conversion.html index d0a793a..4054e00 100644 --- a/doc/conversion.html +++ b/doc/conversion.html @@ -15,10 +15,10 @@ -boost.png (6897 bytes) +boost.png (6897 bytes) - Endian Conversion
- Functions
+ + Endian Conversion Functions @@ -27,7 +27,8 @@ Boost Home     Endian Home     Conversion Functions     - Endian Types + Arithmetic Types     + Buffer Types @@ -55,7 +56,7 @@ <boost/endian/conversion.hpp>
- <boost/endian/types.hpp> + <boost/endian/arithmetic.hpp> @@ -333,7 +334,7 @@ Pierre Talbot provided the int8_t reverse_value() and templated reverse() implementations.


Last revised: -12 November, 2014

+19 November, 2014

© Copyright Beman Dawes, 2011, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

diff --git a/doc/index.html b/doc/index.html index a88cbb4..607947b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -13,11 +13,12 @@ - - +
+ boost.png (6897 bytes) - Endian Library + + Endian Library
@@ -26,7 +27,8 @@ Boost Home     Endian Home     Conversion Functions     - Endian Types + Arithmetic Types     + Buffer Types

@@ -56,7 +58,7 @@ <boost/endian/conversion.hpp>
- <boost/endian/types.hpp> + <boost/endian/arithmetic.hpp> @@ -68,12 +70,12 @@ floating point, and user defined data.

  • The primary use case is binary I/O for portable data exchange with other systems, via either external media or network transmission.
     
  • -
  • A second use case is minimizing storage size via sizes and/or +
  • An additional use case is minimizing storage size via sizes and/or alignments not supported by the built-in types.
     
  • -
  • Two distinct approaches to dealing with endianness are provided. Each approach has a +
  • Three distinct approaches to dealing with endianness are provided. Each approach has a long history of successful use, and each approach has use cases where it is - superior to the other approach.
  • + preferred over the other approaches.

    Introduction to endianness

    @@ -111,42 +113,53 @@ at different ends.

    See the Wikipedia's Endianness article for an extensive discussion of endianness.

    -

    Most programmers can ignore endianness, except perhaps for reading a core -dump on little-endian systems. Programmers have to deal with endianness in their -code when exchanging binary integers and binary floating point -values between computer systems with differing endianness, whether by physical file transfer or over a network, -.

    +

    Programmers can usually ignore endianness, except perhaps for reading a core +dump on little-endian systems. But programmers will have to deal with endianness when exchanging binary integers and binary floating point +values between computer systems with differing endianness, whether by physical file transfer or over a network. +And programmers may want to use the library if minimizing either internal or +external data sizes is advantagous.

    Introduction to the Boost.Endian library

    -

    The Boost.Endian library provides two different approaches to dealing with -integer endianness. Both approaches support integers, floating point types +

    The Boost.Endian library provides three different approaches to dealing with + +endianness. All three approaches support integers, floating point types except  long double, and user defined types (UDTs).

    Each approach has a long history of successful use, and each approach has use -cases where it is superior to the other approach.

    +cases where it is preferred to the other approaches.

    -

    Endian types - The application uses the provided endian types -which mimic the -built-in integer types. For example, big_int32_t or little_float64_t. -Integer types with lengths of 1 through 8 bytes are supported, rather than just -2, 4, and 8 byte integers. The types may be aligned or unaligned.

    -

    Endian conversion functions - The application uses the built-in integer and floating point types, and calls the provided conversion functions to convert byte ordering as needed. Both mutating and non-mutating conversions are supplied, and each comes in unconditional and conditional variants.

    +

    Endian buffer types - The application uses the provided endian +buffer types +which mimic the +built-in integer types. For example, big_buf32_t or little_floatbuf64_t. +Buffer types with lengths of 1 through 8 bytes are supported, rather than just +2, 4, and 8 bytes. The types may be aligned (name suffix _t) or unaligned +(name suffix _ut).

    + +

    Endian arithmetic types - The application uses the provided endian +arithmetic types +which mimic the +built-in arithmetic types. For example, big_int32_t or little_float64_t. +Arithmetic integer types with lengths of 1 through 8 bytes are supported, rather than just +2, 4, and 8 byte integers. The types may be aligned (name suffix _t) or unaligned +(name suffix _ut).

    +

    Boost Endian is a header-only library.

    -

    Choosing between endian types and endian -conversion functions

    +

    Choosing between conversion functions, buffers types, +and arithmetic types

    -

    Which approach is better for dealing with endianness depends on +

    Which endianness approach is best depends on application needs.

    @@ -688,7 +701,7 @@ Blechmann, Tim Moore, tymofey, Tomas Puverle, Vincente Botet, Yuval Ronen and Vitaly Budovski,.


    Last revised: -12 November, 2014

    +19 November, 2014

    © Copyright Beman Dawes, 2011, 2013

    Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt