Sha256: edc71b7773784e663fd765ffc266a2a901f3a629e16fe629354a221b94360634

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/json/

#ifndef TAO_JSON_INTERNAL_ENDIAN_HPP
#define TAO_JSON_INTERNAL_ENDIAN_HPP

#include <cstdint>
#include <cstring>

#if defined( _WIN32 ) && !defined( __MINGW32__ )
#include "endian_win.hpp"
#else
#include "endian_gcc.hpp"
#endif

namespace tao::json::internal
{
   template< typename N >
   [[nodiscard]] N h_to_be( const N n ) noexcept
   {
      return N( to_and_from_be< sizeof( N ) >::convert( n ) );
   }

   template< typename N >
   [[nodiscard]] N be_to_h( const N n ) noexcept
   {
      return h_to_be( n );
   }

   template< typename N >
   [[nodiscard]] N be_to_h( const void* p ) noexcept
   {
      N n;
      std::memcpy( &n, p, sizeof( n ) );
      return internal::be_to_h( n );
   }

   template< typename N >
   [[nodiscard]] N h_to_le( const N n ) noexcept
   {
      return N( to_and_from_le< sizeof( N ) >::convert( n ) );
   }

   template< typename N >
   [[nodiscard]] N le_to_h( const N n ) noexcept
   {
      return h_to_le( n );
   }

   template< typename N >
   [[nodiscard]] N le_to_h( const void* p ) noexcept
   {
      N n;
      std::memcpy( &n, p, sizeof( n ) );
      return internal::le_to_h( n );
   }

}  // namespace tao::json::internal

#endif

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
couchbase-3.4.5 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp
couchbase-3.4.4 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp
couchbase-3.4.3 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp
couchbase-3.4.2 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp
couchbase-3.4.1 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp
couchbase-3.4.0 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp
couchbase-3.3.0 ext/couchbase/third_party/json/include/tao/json/internal/endian.hpp