mirror of
https://github.com/boostorg/endian.git
synced 2025-08-01 13:34:39 +02:00
Complete synopsis update.
This commit is contained in:
@@ -72,38 +72,56 @@ namespace endian
|
|||||||
enum class order {big, little, native};
|
enum class order {big, little, native};
|
||||||
|
|
||||||
// reverse byte order (i.e. endianness)
|
// reverse byte order (i.e. endianness)
|
||||||
//
|
int16_t reverse_value(int16_t x) noexcept;
|
||||||
inline int16_t reverse_value(int16_t x) noexcept;
|
int32_t reverse_value(int32_t x) noexcept;
|
||||||
inline int32_t reverse_value(int32_t x) noexcept;
|
int64_t reverse_value(int64_t x) noexcept;
|
||||||
inline int64_t reverse_value(int64_t x) noexcept;
|
uint16_t reverse_value(uint16_t x) noexcept;
|
||||||
inline uint16_t reverse_value(uint16_t x) noexcept;
|
uint32_t reverse_value(uint32_t x) noexcept;
|
||||||
inline uint32_t reverse_value(uint32_t x) noexcept;
|
uint64_t reverse_value(uint64_t x) noexcept;
|
||||||
inline uint64_t reverse_value(uint64_t x) noexcept;
|
float reverse_value(float x) noexcept;
|
||||||
inline float reverse_value(float x) noexcept;
|
double reverse_value(double x) noexcept;
|
||||||
inline double reverse_value(double x) noexcept;
|
|
||||||
|
|
||||||
// reverse bytes unless native endianness is big
|
void reverse(int16_t& x) noexcept;
|
||||||
//
|
void reverse(int32_t& x) noexcept;
|
||||||
template <class ReversibleValue >
|
void reverse(int64_t& x) noexcept;
|
||||||
inline ReversibleValue big_endian_value(ReversibleValue x) noexcept;
|
void reverse(uint16_t& x) noexcept;
|
||||||
|
void reverse(uint32_t& x) noexcept;
|
||||||
|
void reverse(uint64_t& x) noexcept;
|
||||||
|
void reverse(float& x) noexcept;
|
||||||
|
void reverse(double& x) noexcept;
|
||||||
|
|
||||||
// reverse bytes unless native endianness is little
|
// reverse byte order unless native endianness is big
|
||||||
//
|
|
||||||
template <class ReversibleValue >
|
template <class ReversibleValue >
|
||||||
inline ReversibleValue little_endian_value(ReversibleValue x) noexcept;
|
ReversibleValue big_endian_value(ReversibleValue x) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
|
void big_endian(Reversible& x) noexcept;
|
||||||
|
|
||||||
|
// reverse byte order unless native endianness is little
|
||||||
|
template <class ReversibleValue >
|
||||||
|
ReversibleValue little_endian_value(ReversibleValue x) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
|
void little_endian(Reversible& x) noexcept;
|
||||||
|
|
||||||
// synonyms, based on names popularized by BSD (e.g. OS X, Linux)
|
// synonyms, based on names popularized by BSD (e.g. OS X, Linux)
|
||||||
// "h" stands for "host" (i.e. native), "be" for "big endian", "le" for "little endian"
|
// "h" for "host" (i.e. native), "be" for "big endian",
|
||||||
//
|
// "le" for "little endian", "m" for "modify" in place
|
||||||
template <class T> T bswap(T x) {return reverse_value(x);}
|
template <class T> T bswap(T x) noexcept {return reverse_value(x);}
|
||||||
template <class T> T htobe(T host) {return big_endian_value(host);}
|
template <class T> T htobe(T host) noexcept {return big_endian_value(host);}
|
||||||
template <class T> T htole(T host) {return little_endian_value(host);}
|
template <class T> T htole(T host) noexcept {return little_endian_value(host);}
|
||||||
template <class T> T betoh(T big) {return big_endian_value(big);}
|
template <class T> T betoh(T big) noexcept {return big_endian_value(big);}
|
||||||
template <class T> T letoh(T little) {return little_endian_value(little);}
|
template <class T> T letoh(T little) noexcept {return little_endian_value(little);}
|
||||||
|
|
||||||
|
template <class T> void bswapm(T& x) noexcept {reverse(x);}
|
||||||
|
template <class T> void htobem(T& host) noexcept {big_endian(host);}
|
||||||
|
template <class T> void htole(mT& host noexcept) {little_endian(host);}
|
||||||
|
template <class T> void betohm(T& big) noexcept {big_endian(big);}
|
||||||
|
template <class T> void letohm(T& little) noexcept {little_endian(little);}
|
||||||
|
|
||||||
// compile-time generic byte order conversion
|
// compile-time generic byte order conversion
|
||||||
template <order From, order To, class ReversibleValue>
|
template <order From, order To, class ReversibleValue>
|
||||||
ReversibleValue convert_value(ReversibleValue from) noexcept;
|
ReversibleValue convert_value(ReversibleValue from) noexcept;
|
||||||
|
template <order From, order To, class Reversible>
|
||||||
|
void convert(Reversible& x) noexcept;
|
||||||
|
|
||||||
// runtime actual byte-order determination
|
// runtime actual byte-order determination
|
||||||
order actual_order(order o) noexcept;
|
order actual_order(order o) noexcept;
|
||||||
@@ -112,68 +130,28 @@ namespace endian
|
|||||||
template <class ReversibleValue>
|
template <class ReversibleValue>
|
||||||
ReversibleValue convert_value(ReversibleValue from,
|
ReversibleValue convert_value(ReversibleValue from,
|
||||||
order from_order, order to_order) noexcept;
|
order from_order, order to_order) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
//--------------------------------------------------------------------------------------//
|
void convert(Reversible& x,
|
||||||
// modify in place interface //
|
order from_order, order to_order) noexcept;
|
||||||
//--------------------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
// reverse byte order (i.e. endianness)
|
|
||||||
//
|
|
||||||
inline void reverse(int16_t& x) noexcept;
|
|
||||||
inline void reverse(int32_t& x) noexcept;
|
|
||||||
inline void reverse(int64_t& x) noexcept;
|
|
||||||
inline void reverse(uint16_t& x) noexcept;
|
|
||||||
inline void reverse(uint32_t& x) noexcept;
|
|
||||||
inline void reverse(uint64_t& x) noexcept;
|
|
||||||
inline void reverse(float& x) noexcept;
|
|
||||||
inline void reverse(double& x) noexcept;
|
|
||||||
|
|
||||||
// reverse unless native endianness is big
|
|
||||||
template <class Reversible>
|
|
||||||
inline void big_endian(Reversible& x) noexcept;
|
|
||||||
// Effects: none if native endian order is big, otherwise reverse(x)
|
|
||||||
|
|
||||||
// reverse unless native endianness is little
|
|
||||||
template <class Reversible>
|
|
||||||
inline void little_endian(Reversible& x) noexcept;
|
|
||||||
// Effects: none if native endian order is little, otherwise reverse(x);
|
|
||||||
|
|
||||||
// synonyms based on names popularized by BSD, e.g. OS X, Linux.
|
|
||||||
// "h" stands for "host" (i.e. native), "be" for "big endian",
|
|
||||||
// "le" for "little endian", "m" for "modify in place"
|
|
||||||
template <class T> void mbswap(T& x) {reverse(x);}
|
|
||||||
template <class T> void mhtobe(T& host_) {big_endian(host_);}
|
|
||||||
template <class T> void mhtole(T& host_) {little_endian(host_);}
|
|
||||||
template <class T> void mbetoh(T& big_endian_) {big_endian(big_endian_);}
|
|
||||||
template <class T> void mletoh(T& little_endian_) {little_endian(little_endian_);}
|
|
||||||
|
|
||||||
// compile-time generic byte order conversion
|
|
||||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
|
||||||
void convert(Reversible& x) noexcept;
|
|
||||||
|
|
||||||
// runtime byte-order conversion
|
|
||||||
template <class Reversible>
|
|
||||||
void convert(Reversible& x, BOOST_SCOPED_ENUM(order) from_order,
|
|
||||||
BOOST_SCOPED_ENUM(order) to_order) noexcept;
|
|
||||||
|
|
||||||
} // namespace endian
|
} // namespace endian
|
||||||
} // namespace boost</pre>
|
} // namespace boost</pre>
|
||||||
<h3 dir="ltr"><a name="Members">Members</a></h3>
|
<h3 dir="ltr"><a name="Members">Members</a></h3>
|
||||||
<pre dir="ltr">inline void reorder(int16_t& x);
|
<pre dir="ltr">void reorder(int16_t& x);
|
||||||
inline void reorder(int32_t& x);
|
void reorder(int32_t& x);
|
||||||
inline void reorder(int64_t& x);
|
void reorder(int64_t& x);
|
||||||
inline void reorder(uint16_t& x);
|
void reorder(uint16_t& x);
|
||||||
inline void reorder(uint32_t& x);
|
void reorder(uint32_t& x);
|
||||||
inline void reorder(uint64_t& x);</pre>
|
void reorder(uint64_t& x);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p dir="ltr"><i>Effects:</i> Reverses the byte order of <i><code>x</code></i>.</p>
|
<p dir="ltr"><i>Effects:</i> Reverses the byte order of <i><code>x</code></i>.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre dir="ltr">inline void reorder(int16_t source, int16_t& target);
|
<pre dir="ltr">void reorder(int16_t source, int16_t& target);
|
||||||
inline void reorder(int32_t source, int32_t& target);
|
void reorder(int32_t source, int32_t& target);
|
||||||
inline void reorder(int64_t source, int64_t& target);
|
void reorder(int64_t source, int64_t& target);
|
||||||
inline void reorder(uint16_t source, uint16_t& target);
|
void reorder(uint16_t source, uint16_t& target);
|
||||||
inline void reorder(uint32_t source, uint32_t& target);
|
void reorder(uint32_t source, uint32_t& target);
|
||||||
inline void reorder(uint64_t source, uint64_t& target);</pre>
|
void reorder(uint64_t source, uint64_t& target);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p dir="ltr"><i>Effects:</i> Copies <code>source</code> to <code>target</code>,
|
<p dir="ltr"><i>Effects:</i> Copies <code>source</code> to <code>target</code>,
|
||||||
reversing the byte order.</p>
|
reversing the byte order.</p>
|
||||||
|
Reference in New Issue
Block a user