/src/boost/boost/endian/conversion.hpp
Line | Count | Source |
1 | | // boost/endian/conversion.hpp -------------------------------------------------------// |
2 | | |
3 | | // Copyright Beman Dawes 2010, 2011, 2014 |
4 | | |
5 | | // Distributed under the Boost Software License, Version 1.0. |
6 | | // http://www.boost.org/LICENSE_1_0.txt |
7 | | |
8 | | #ifndef BOOST_ENDIAN_CONVERSION_HPP |
9 | | #define BOOST_ENDIAN_CONVERSION_HPP |
10 | | |
11 | | #include <boost/endian/detail/endian_reverse.hpp> |
12 | | #include <boost/endian/detail/endian_load.hpp> |
13 | | #include <boost/endian/detail/endian_store.hpp> |
14 | | #include <boost/endian/detail/order.hpp> |
15 | | #include <boost/endian/detail/static_assert.hpp> |
16 | | #include <boost/config.hpp> |
17 | | #include <type_traits> |
18 | | #include <cstdint> |
19 | | |
20 | | //------------------------------------- synopsis ---------------------------------------// |
21 | | |
22 | | namespace boost |
23 | | { |
24 | | namespace endian |
25 | | { |
26 | | |
27 | | //--------------------------------------------------------------------------------------// |
28 | | // // |
29 | | // return-by-value interfaces // |
30 | | // suggested by Phil Endecott // |
31 | | // // |
32 | | // user-defined types (UDTs) // |
33 | | // // |
34 | | // All return-by-value conversion function templates are required to be implemented in // |
35 | | // terms of an unqualified call to "endian_reverse(x)", a function returning the // |
36 | | // value of x with endianness reversed. This provides a customization point for any // |
37 | | // UDT that provides a "endian_reverse" free-function meeting the requirements. // |
38 | | // It must be defined in the same namespace as the UDT itself so that it will be found // |
39 | | // by argument dependent lookup (ADL). // |
40 | | // // |
41 | | //--------------------------------------------------------------------------------------// |
42 | | |
43 | | // reverse byte order |
44 | | // requires T to be a non-bool integral type |
45 | | // in detail/endian_reverse.hpp |
46 | | // |
47 | | // template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT; |
48 | | |
49 | | // reverse byte order unless native endianness is big |
50 | | template <class EndianReversible > |
51 | | inline BOOST_CONSTEXPR EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT; |
52 | | // Returns: x if native endian order is big, otherwise endian_reverse(x) |
53 | | template <class EndianReversible > |
54 | | inline BOOST_CONSTEXPR EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT; |
55 | | // Returns: x if native endian order is big, otherwise endian_reverse(x) |
56 | | |
57 | | // reverse byte order unless native endianness is little |
58 | | template <class EndianReversible > |
59 | | inline BOOST_CONSTEXPR EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT; |
60 | | // Returns: x if native endian order is little, otherwise endian_reverse(x) |
61 | | template <class EndianReversible > |
62 | | inline BOOST_CONSTEXPR EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT; |
63 | | // Returns: x if native endian order is little, otherwise endian_reverse(x) |
64 | | |
65 | | // generic conditional reverse byte order |
66 | | template <order From, order To, |
67 | | class EndianReversible> |
68 | | inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT; |
69 | | // Returns: If From == To have different values, from. |
70 | | // Otherwise endian_reverse(from). |
71 | | // Remarks: The From == To test, and as a consequence which form the return takes, is |
72 | | // is determined at compile time. |
73 | | |
74 | | // runtime conditional reverse byte order |
75 | | template <class EndianReversible > |
76 | | inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from, |
77 | | order from_order, order to_order) |
78 | | BOOST_NOEXCEPT; |
79 | | // Returns: from_order == to_order ? from : endian_reverse(from). |
80 | | |
81 | | //------------------------------------------------------------------------------------// |
82 | | |
83 | | |
84 | | // Q: What happened to bswap, htobe, and the other synonym functions based on names |
85 | | // popularized by BSD, OS X, and Linux? |
86 | | // A: Turned out these may be implemented as macros on some systems. Ditto POSIX names |
87 | | // for such functionality. Since macros would cause endless problems with functions |
88 | | // of the same names, and these functions are just synonyms anyhow, they have been |
89 | | // removed. |
90 | | |
91 | | |
92 | | //------------------------------------------------------------------------------------// |
93 | | // // |
94 | | // reverse in place interfaces // |
95 | | // // |
96 | | // user-defined types (UDTs) // |
97 | | // // |
98 | | // All reverse in place function templates are required to be implemented in terms // |
99 | | // of an unqualified call to "endian_reverse_inplace(x)", a function reversing // |
100 | | // the endianness of x, which is a non-const reference. This provides a // |
101 | | // customization point for any UDT that provides a "reverse_inplace" free-function // |
102 | | // meeting the requirements. The free-function must be declared in the same // |
103 | | // namespace as the UDT itself so that it will be found by argument-dependent // |
104 | | // lookup (ADL). // |
105 | | // // |
106 | | //------------------------------------------------------------------------------------// |
107 | | |
108 | | // reverse in place |
109 | | // in detail/endian_reverse.hpp |
110 | | // |
111 | | // template <class EndianReversible> |
112 | | // inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT; |
113 | | // |
114 | | // Effects: x = endian_reverse(x) |
115 | | |
116 | | // reverse in place unless native endianness is big |
117 | | template <class EndianReversibleInplace> |
118 | | inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT; |
119 | | // Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x) |
120 | | template <class EndianReversibleInplace> |
121 | | inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT; |
122 | | // Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x) |
123 | | |
124 | | // reverse in place unless native endianness is little |
125 | | template <class EndianReversibleInplace> |
126 | | inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT; |
127 | | // Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x); |
128 | | template <class EndianReversibleInplace> |
129 | | inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT; |
130 | | // Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x); |
131 | | |
132 | | // generic conditional reverse in place |
133 | | template <order From, order To, |
134 | | class EndianReversibleInplace> |
135 | | inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT; |
136 | | |
137 | | // runtime reverse in place |
138 | | template <class EndianReversibleInplace> |
139 | | inline void conditional_reverse_inplace(EndianReversibleInplace& x, |
140 | | order from_order, order to_order) |
141 | | BOOST_NOEXCEPT; |
142 | | |
143 | | //----------------------------------- end synopsis -------------------------------------// |
144 | | |
145 | | template <class EndianReversible> |
146 | | inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT |
147 | | { |
148 | | return boost::endian::conditional_reverse<order::big, order::native>( x ); |
149 | | } |
150 | | |
151 | | template <class EndianReversible> |
152 | | inline BOOST_CONSTEXPR EndianReversible native_to_big( EndianReversible x ) BOOST_NOEXCEPT |
153 | | { |
154 | | return boost::endian::conditional_reverse<order::native, order::big>( x ); |
155 | | } |
156 | | |
157 | | template <class EndianReversible> |
158 | | inline BOOST_CONSTEXPR EndianReversible little_to_native( EndianReversible x ) BOOST_NOEXCEPT |
159 | | { |
160 | | return boost::endian::conditional_reverse<order::little, order::native>( x ); |
161 | | } |
162 | | |
163 | | template <class EndianReversible> |
164 | | inline BOOST_CONSTEXPR EndianReversible native_to_little( EndianReversible x ) BOOST_NOEXCEPT |
165 | | { |
166 | | return boost::endian::conditional_reverse<order::native, order::little>( x ); |
167 | | } |
168 | | |
169 | | namespace detail |
170 | | { |
171 | | |
172 | | template<class EndianReversible> |
173 | | inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::true_type ) BOOST_NOEXCEPT |
174 | | { |
175 | | return x; |
176 | | } |
177 | | |
178 | | template<class EndianReversible> |
179 | | inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::false_type ) BOOST_NOEXCEPT |
180 | | { |
181 | | return endian_reverse( x ); |
182 | | } |
183 | | |
184 | | } // namespace detail |
185 | | |
186 | | // generic conditional reverse |
187 | | template <order From, order To, class EndianReversible> |
188 | | inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT |
189 | | { |
190 | | BOOST_ENDIAN_STATIC_ASSERT( std::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value ); |
191 | | return detail::conditional_reverse_impl( x, std::integral_constant<bool, From == To>() ); |
192 | | } |
193 | | |
194 | | // runtime conditional reverse |
195 | | template <class EndianReversible> |
196 | | inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x, |
197 | | order from_order, order to_order ) BOOST_NOEXCEPT |
198 | | { |
199 | | BOOST_ENDIAN_STATIC_ASSERT( std::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value ); |
200 | | return from_order == to_order? x: endian_reverse( x ); |
201 | | } |
202 | | |
203 | | //--------------------------------------------------------------------------------------// |
204 | | // reverse-in-place implementation // |
205 | | //--------------------------------------------------------------------------------------// |
206 | | |
207 | | template <class EndianReversibleInplace> |
208 | | inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT |
209 | | { |
210 | | boost::endian::conditional_reverse_inplace<order::big, order::native>( x ); |
211 | | } |
212 | | |
213 | | template <class EndianReversibleInplace> |
214 | | inline void native_to_big_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT |
215 | | { |
216 | | boost::endian::conditional_reverse_inplace<order::native, order::big>( x ); |
217 | | } |
218 | | |
219 | | template <class EndianReversibleInplace> |
220 | | inline void little_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT |
221 | 4.14M | { |
222 | 4.14M | boost::endian::conditional_reverse_inplace<order::little, order::native>( x ); |
223 | 4.14M | } void boost::endian::little_to_native_inplace<unsigned int>(unsigned int&) Line | Count | Source | 221 | 902k | { | 222 | 902k | boost::endian::conditional_reverse_inplace<order::little, order::native>( x ); | 223 | 902k | } |
void boost::endian::little_to_native_inplace<unsigned long>(unsigned long&) Line | Count | Source | 221 | 3.24M | { | 222 | 3.24M | boost::endian::conditional_reverse_inplace<order::little, order::native>( x ); | 223 | 3.24M | } |
|
224 | | |
225 | | template <class EndianReversibleInplace> |
226 | | inline void native_to_little_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT |
227 | 0 | { |
228 | 0 | boost::endian::conditional_reverse_inplace<order::native, order::little>( x ); |
229 | 0 | } |
230 | | |
231 | | namespace detail |
232 | | { |
233 | | |
234 | | template<class EndianReversibleInplace> |
235 | | inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, std::true_type ) BOOST_NOEXCEPT |
236 | 4.14M | { |
237 | 4.14M | } void boost::endian::detail::conditional_reverse_inplace_impl<unsigned int>(unsigned int&, std::__1::integral_constant<bool, true>) Line | Count | Source | 236 | 902k | { | 237 | 902k | } |
void boost::endian::detail::conditional_reverse_inplace_impl<unsigned long>(unsigned long&, std::__1::integral_constant<bool, true>) Line | Count | Source | 236 | 3.24M | { | 237 | 3.24M | } |
|
238 | | |
239 | | template<class EndianReversibleInplace> |
240 | | inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, std::false_type ) BOOST_NOEXCEPT |
241 | | { |
242 | | endian_reverse_inplace( x ); |
243 | | } |
244 | | |
245 | | } // namespace detail |
246 | | |
247 | | // generic conditional reverse in place |
248 | | template <order From, order To, class EndianReversibleInplace> |
249 | | inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT |
250 | 4.14M | { |
251 | 4.14M | BOOST_ENDIAN_STATIC_ASSERT( |
252 | 4.14M | std::is_class<EndianReversibleInplace>::value || |
253 | 4.14M | std::is_array<EndianReversibleInplace>::value || |
254 | 4.14M | detail::is_endian_reversible_inplace<EndianReversibleInplace>::value ); |
255 | | |
256 | 4.14M | detail::conditional_reverse_inplace_impl( x, std::integral_constant<bool, From == To>() ); |
257 | 4.14M | } void boost::endian::conditional_reverse_inplace<(boost::endian::order)1, (boost::endian::order)1, unsigned int>(unsigned int&) Line | Count | Source | 250 | 902k | { | 251 | 902k | BOOST_ENDIAN_STATIC_ASSERT( | 252 | 902k | std::is_class<EndianReversibleInplace>::value || | 253 | 902k | std::is_array<EndianReversibleInplace>::value || | 254 | 902k | detail::is_endian_reversible_inplace<EndianReversibleInplace>::value ); | 255 | | | 256 | 902k | detail::conditional_reverse_inplace_impl( x, std::integral_constant<bool, From == To>() ); | 257 | 902k | } |
void boost::endian::conditional_reverse_inplace<(boost::endian::order)1, (boost::endian::order)1, unsigned long>(unsigned long&) Line | Count | Source | 250 | 3.24M | { | 251 | 3.24M | BOOST_ENDIAN_STATIC_ASSERT( | 252 | 3.24M | std::is_class<EndianReversibleInplace>::value || | 253 | 3.24M | std::is_array<EndianReversibleInplace>::value || | 254 | 3.24M | detail::is_endian_reversible_inplace<EndianReversibleInplace>::value ); | 255 | | | 256 | 3.24M | detail::conditional_reverse_inplace_impl( x, std::integral_constant<bool, From == To>() ); | 257 | 3.24M | } |
|
258 | | |
259 | | // runtime reverse in place |
260 | | template <class EndianReversibleInplace> |
261 | | inline void conditional_reverse_inplace( EndianReversibleInplace& x, |
262 | | order from_order, order to_order ) BOOST_NOEXCEPT |
263 | | { |
264 | | BOOST_ENDIAN_STATIC_ASSERT( |
265 | | std::is_class<EndianReversibleInplace>::value || |
266 | | std::is_array<EndianReversibleInplace>::value || |
267 | | detail::is_endian_reversible_inplace<EndianReversibleInplace>::value ); |
268 | | |
269 | | if( from_order != to_order ) |
270 | | { |
271 | | endian_reverse_inplace( x ); |
272 | | } |
273 | | } |
274 | | |
275 | | // load/store convenience functions |
276 | | |
277 | | // load 16 |
278 | | |
279 | | inline std::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT |
280 | 0 | { |
281 | 0 | return boost::endian::endian_load<std::int16_t, 2, order::little>( p ); |
282 | 0 | } |
283 | | |
284 | | inline std::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT |
285 | 0 | { |
286 | 0 | return boost::endian::endian_load<std::uint16_t, 2, order::little>( p ); |
287 | 0 | } |
288 | | |
289 | | inline std::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT |
290 | 0 | { |
291 | 0 | return boost::endian::endian_load<std::int16_t, 2, order::big>( p ); |
292 | 0 | } |
293 | | |
294 | | inline std::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT |
295 | 0 | { |
296 | 0 | return boost::endian::endian_load<std::uint16_t, 2, order::big>( p ); |
297 | 0 | } |
298 | | |
299 | | // load 24 |
300 | | |
301 | | inline std::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT |
302 | 0 | { |
303 | 0 | return boost::endian::endian_load<std::int32_t, 3, order::little>( p ); |
304 | 0 | } |
305 | | |
306 | | inline std::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT |
307 | 0 | { |
308 | 0 | return boost::endian::endian_load<std::uint32_t, 3, order::little>( p ); |
309 | 0 | } |
310 | | |
311 | | inline std::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT |
312 | 0 | { |
313 | 0 | return boost::endian::endian_load<std::int32_t, 3, order::big>( p ); |
314 | 0 | } |
315 | | |
316 | | inline std::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT |
317 | 0 | { |
318 | 0 | return boost::endian::endian_load<std::uint32_t, 3, order::big>( p ); |
319 | 0 | } |
320 | | |
321 | | // load 32 |
322 | | |
323 | | inline std::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT |
324 | 0 | { |
325 | 0 | return boost::endian::endian_load<std::int32_t, 4, order::little>( p ); |
326 | 0 | } |
327 | | |
328 | | inline std::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT |
329 | 0 | { |
330 | 0 | return boost::endian::endian_load<std::uint32_t, 4, order::little>( p ); |
331 | 0 | } |
332 | | |
333 | | inline std::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT |
334 | 0 | { |
335 | 0 | return boost::endian::endian_load<std::int32_t, 4, order::big>( p ); |
336 | 0 | } |
337 | | |
338 | | inline std::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT |
339 | 0 | { |
340 | 0 | return boost::endian::endian_load<std::uint32_t, 4, order::big>( p ); |
341 | 0 | } |
342 | | |
343 | | // load 40 |
344 | | |
345 | | inline std::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT |
346 | 0 | { |
347 | 0 | return boost::endian::endian_load<std::int64_t, 5, order::little>( p ); |
348 | 0 | } |
349 | | |
350 | | inline std::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT |
351 | 0 | { |
352 | 0 | return boost::endian::endian_load<std::uint64_t, 5, order::little>( p ); |
353 | 0 | } |
354 | | |
355 | | inline std::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT |
356 | 0 | { |
357 | 0 | return boost::endian::endian_load<std::int64_t, 5, order::big>( p ); |
358 | 0 | } |
359 | | |
360 | | inline std::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT |
361 | 0 | { |
362 | 0 | return boost::endian::endian_load<std::uint64_t, 5, order::big>( p ); |
363 | 0 | } |
364 | | |
365 | | // load 48 |
366 | | |
367 | | inline std::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT |
368 | 0 | { |
369 | 0 | return boost::endian::endian_load<std::int64_t, 6, order::little>( p ); |
370 | 0 | } |
371 | | |
372 | | inline std::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT |
373 | 0 | { |
374 | 0 | return boost::endian::endian_load<std::uint64_t, 6, order::little>( p ); |
375 | 0 | } |
376 | | |
377 | | inline std::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT |
378 | 0 | { |
379 | 0 | return boost::endian::endian_load<std::int64_t, 6, order::big>( p ); |
380 | 0 | } |
381 | | |
382 | | inline std::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT |
383 | 0 | { |
384 | 0 | return boost::endian::endian_load<std::uint64_t, 6, order::big>( p ); |
385 | 0 | } |
386 | | |
387 | | // load 56 |
388 | | |
389 | | inline std::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT |
390 | 0 | { |
391 | 0 | return boost::endian::endian_load<std::int64_t, 7, order::little>( p ); |
392 | 0 | } |
393 | | |
394 | | inline std::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT |
395 | 0 | { |
396 | 0 | return boost::endian::endian_load<std::uint64_t, 7, order::little>( p ); |
397 | 0 | } |
398 | | |
399 | | inline std::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT |
400 | 0 | { |
401 | 0 | return boost::endian::endian_load<std::int64_t, 7, order::big>( p ); |
402 | 0 | } |
403 | | |
404 | | inline std::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT |
405 | 0 | { |
406 | 0 | return boost::endian::endian_load<std::uint64_t, 7, order::big>( p ); |
407 | 0 | } |
408 | | |
409 | | // load 64 |
410 | | |
411 | | inline std::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT |
412 | 0 | { |
413 | 0 | return boost::endian::endian_load<std::int64_t, 8, order::little>( p ); |
414 | 0 | } |
415 | | |
416 | | inline std::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT |
417 | 0 | { |
418 | 0 | return boost::endian::endian_load<std::uint64_t, 8, order::little>( p ); |
419 | 0 | } |
420 | | |
421 | | inline std::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT |
422 | 0 | { |
423 | 0 | return boost::endian::endian_load<std::int64_t, 8, order::big>( p ); |
424 | 0 | } |
425 | | |
426 | | inline std::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT |
427 | 0 | { |
428 | 0 | return boost::endian::endian_load<std::uint64_t, 8, order::big>( p ); |
429 | 0 | } |
430 | | |
431 | | // store 16 |
432 | | |
433 | | inline void store_little_s16( unsigned char * p, std::int16_t v ) |
434 | 0 | { |
435 | 0 | boost::endian::endian_store<std::int16_t, 2, order::little>( p, v ); |
436 | 0 | } |
437 | | |
438 | | inline void store_little_u16( unsigned char * p, std::uint16_t v ) |
439 | 0 | { |
440 | 0 | boost::endian::endian_store<std::uint16_t, 2, order::little>( p, v ); |
441 | 0 | } |
442 | | |
443 | | inline void store_big_s16( unsigned char * p, std::int16_t v ) |
444 | 0 | { |
445 | 0 | boost::endian::endian_store<std::int16_t, 2, order::big>( p, v ); |
446 | 0 | } |
447 | | |
448 | | inline void store_big_u16( unsigned char * p, std::uint16_t v ) |
449 | 0 | { |
450 | 0 | boost::endian::endian_store<std::uint16_t, 2, order::big>( p, v ); |
451 | 0 | } |
452 | | |
453 | | // store 24 |
454 | | |
455 | | inline void store_little_s24( unsigned char * p, std::int32_t v ) |
456 | 0 | { |
457 | 0 | boost::endian::endian_store<std::int32_t, 3, order::little>( p, v ); |
458 | 0 | } |
459 | | |
460 | | inline void store_little_u24( unsigned char * p, std::uint32_t v ) |
461 | 0 | { |
462 | 0 | boost::endian::endian_store<std::uint32_t, 3, order::little>( p, v ); |
463 | 0 | } |
464 | | |
465 | | inline void store_big_s24( unsigned char * p, std::int32_t v ) |
466 | 0 | { |
467 | 0 | boost::endian::endian_store<std::int32_t, 3, order::big>( p, v ); |
468 | 0 | } |
469 | | |
470 | | inline void store_big_u24( unsigned char * p, std::uint32_t v ) |
471 | 0 | { |
472 | 0 | boost::endian::endian_store<std::uint32_t, 3, order::big>( p, v ); |
473 | 0 | } |
474 | | |
475 | | // store 32 |
476 | | |
477 | | inline void store_little_s32( unsigned char * p, std::int32_t v ) |
478 | 0 | { |
479 | 0 | boost::endian::endian_store<std::int32_t, 4, order::little>( p, v ); |
480 | 0 | } |
481 | | |
482 | | inline void store_little_u32( unsigned char * p, std::uint32_t v ) |
483 | 0 | { |
484 | 0 | boost::endian::endian_store<std::uint32_t, 4, order::little>( p, v ); |
485 | 0 | } |
486 | | |
487 | | inline void store_big_s32( unsigned char * p, std::int32_t v ) |
488 | 0 | { |
489 | 0 | boost::endian::endian_store<std::int32_t, 4, order::big>( p, v ); |
490 | 0 | } |
491 | | |
492 | | inline void store_big_u32( unsigned char * p, std::uint32_t v ) |
493 | 0 | { |
494 | 0 | boost::endian::endian_store<std::uint32_t, 4, order::big>( p, v ); |
495 | 0 | } |
496 | | |
497 | | // store 40 |
498 | | |
499 | | inline void store_little_s40( unsigned char * p, std::int64_t v ) |
500 | 0 | { |
501 | 0 | boost::endian::endian_store<std::int64_t, 5, order::little>( p, v ); |
502 | 0 | } |
503 | | |
504 | | inline void store_little_u40( unsigned char * p, std::uint64_t v ) |
505 | 0 | { |
506 | 0 | boost::endian::endian_store<std::uint64_t, 5, order::little>( p, v ); |
507 | 0 | } |
508 | | |
509 | | inline void store_big_s40( unsigned char * p, std::int64_t v ) |
510 | 0 | { |
511 | 0 | boost::endian::endian_store<std::int64_t, 5, order::big>( p, v ); |
512 | 0 | } |
513 | | |
514 | | inline void store_big_u40( unsigned char * p, std::uint64_t v ) |
515 | 0 | { |
516 | 0 | boost::endian::endian_store<std::uint64_t, 5, order::big>( p, v ); |
517 | 0 | } |
518 | | |
519 | | // store 48 |
520 | | |
521 | | inline void store_little_s48( unsigned char * p, std::int64_t v ) |
522 | 0 | { |
523 | 0 | boost::endian::endian_store<std::int64_t, 6, order::little>( p, v ); |
524 | 0 | } |
525 | | |
526 | | inline void store_little_u48( unsigned char * p, std::uint64_t v ) |
527 | 0 | { |
528 | 0 | boost::endian::endian_store<std::uint64_t, 6, order::little>( p, v ); |
529 | 0 | } |
530 | | |
531 | | inline void store_big_s48( unsigned char * p, std::int64_t v ) |
532 | 0 | { |
533 | 0 | boost::endian::endian_store<std::int64_t, 6, order::big>( p, v ); |
534 | 0 | } |
535 | | |
536 | | inline void store_big_u48( unsigned char * p, std::uint64_t v ) |
537 | 0 | { |
538 | 0 | boost::endian::endian_store<std::uint64_t, 6, order::big>( p, v ); |
539 | 0 | } |
540 | | |
541 | | // store 56 |
542 | | |
543 | | inline void store_little_s56( unsigned char * p, std::int64_t v ) |
544 | 0 | { |
545 | 0 | boost::endian::endian_store<std::int64_t, 7, order::little>( p, v ); |
546 | 0 | } |
547 | | |
548 | | inline void store_little_u56( unsigned char * p, std::uint64_t v ) |
549 | 0 | { |
550 | 0 | boost::endian::endian_store<std::uint64_t, 7, order::little>( p, v ); |
551 | 0 | } |
552 | | |
553 | | inline void store_big_s56( unsigned char * p, std::int64_t v ) |
554 | 0 | { |
555 | 0 | boost::endian::endian_store<std::int64_t, 7, order::big>( p, v ); |
556 | 0 | } |
557 | | |
558 | | inline void store_big_u56( unsigned char * p, std::uint64_t v ) |
559 | 0 | { |
560 | 0 | boost::endian::endian_store<std::uint64_t, 7, order::big>( p, v ); |
561 | 0 | } |
562 | | |
563 | | // store 64 |
564 | | |
565 | | inline void store_little_s64( unsigned char * p, std::int64_t v ) |
566 | 0 | { |
567 | 0 | boost::endian::endian_store<std::int64_t, 8, order::little>( p, v ); |
568 | 0 | } |
569 | | |
570 | | inline void store_little_u64( unsigned char * p, std::uint64_t v ) |
571 | 0 | { |
572 | 0 | boost::endian::endian_store<std::uint64_t, 8, order::little>( p, v ); |
573 | 0 | } |
574 | | |
575 | | inline void store_big_s64( unsigned char * p, std::int64_t v ) |
576 | 0 | { |
577 | 0 | boost::endian::endian_store<std::int64_t, 8, order::big>( p, v ); |
578 | 0 | } |
579 | | |
580 | | inline void store_big_u64( unsigned char * p, std::uint64_t v ) |
581 | 0 | { |
582 | 0 | boost::endian::endian_store<std::uint64_t, 8, order::big>( p, v ); |
583 | 0 | } |
584 | | |
585 | | } // namespace endian |
586 | | } // namespace boost |
587 | | |
588 | | #endif // BOOST_ENDIAN_CONVERSION_HPP |