From 1d055261b4144dbf86b2658437015b15d4dd9bff Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 4 Sep 2022 00:32:56 +0100 Subject: initial --- include/jsoncons/detail/endian.hpp | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 include/jsoncons/detail/endian.hpp (limited to 'include/jsoncons/detail/endian.hpp') diff --git a/include/jsoncons/detail/endian.hpp b/include/jsoncons/detail/endian.hpp new file mode 100644 index 0000000..d47a0f7 --- /dev/null +++ b/include/jsoncons/detail/endian.hpp @@ -0,0 +1,44 @@ +// Copyright 2020 Daniel Parker +// Distributed under the Boost license, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See https://github.com/danielaparker/jsoncons for latest version + +#ifndef JSONCONS_DETAIL_ENDIAN_HPP +#define JSONCONS_DETAIL_ENDIAN_HPP + +#if defined(__sun) +# include +#endif + +namespace jsoncons { +namespace detail { + + enum class endian + { + #if defined(_MSC_VER) + // MSVC, which implies Windows, which implies little-endian + little = 0, + big = 1, + native = little + #elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__) + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ + #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) + little = 0, + big = 1, + native = big + #elif !defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) + little = 0, + big = 1, + native = little + #else + #error "Unable to determine byte order!" + #endif + }; + +} // namespace detail +} // namespace jsoncons + +#endif -- cgit v1.2.3