Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
endianess.hpp
00001 // ArduinoJson - arduinojson.org 00002 // Copyright Benoit Blanchon 2014-2021 00003 // MIT License 00004 00005 #pragma once 00006 00007 #include <ArduinoJson/Polyfills/type_traits.hpp> 00008 #include <ArduinoJson/Polyfills/utility.hpp> 00009 00010 namespace ARDUINOJSON_NAMESPACE { 00011 00012 #if ARDUINOJSON_LITTLE_ENDIAN 00013 inline void fixEndianess(uint8_t *p, integral_constant<size_t, 8>) { 00014 swap(p[0], p[7]); 00015 swap(p[1], p[6]); 00016 swap(p[2], p[5]); 00017 swap(p[3], p[4]); 00018 } 00019 00020 inline void fixEndianess(uint8_t *p, integral_constant<size_t, 4>) { 00021 swap(p[0], p[3]); 00022 swap(p[1], p[2]); 00023 } 00024 00025 inline void fixEndianess(uint8_t *p, integral_constant<size_t, 2>) { 00026 swap(p[0], p[1]); 00027 } 00028 00029 inline void fixEndianess(uint8_t *, integral_constant<size_t, 1>) {} 00030 00031 template <typename T> 00032 inline void fixEndianess(T &value) { 00033 fixEndianess(reinterpret_cast<uint8_t *>(&value), 00034 integral_constant<size_t, sizeof(T)>()); 00035 } 00036 #else 00037 template <typename T> 00038 inline void fixEndianess(T &) {} 00039 #endif 00040 00041 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2