Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - ssrc/wispers/utility - endian.h (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 3 3 100.0 %
Date: 2012-04-09 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright 2010 Savarese Software Research Corporation
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :            :  * you may not use this file except in compliance with the License.
       6                 :            :  * You may obtain a copy of the License at
       7                 :            :  *
       8                 :            :  *     https://www.savarese.com/software/ApacheLicense-2.0
       9                 :            :  *
      10                 :            :  * Unless required by applicable law or agreed to in writing, software
      11                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :            :  * See the License for the specific language governing permissions and
      14                 :            :  * limitations under the License.
      15                 :            :  */
      16                 :            : 
      17                 :            : /**
      18                 :            :  * @file
      19                 :            :  * This header defines functions for determining endianness.
      20                 :            :  */
      21                 :            : 
      22                 :            : #ifndef __SSRC_WSPR_UTILITY_ENDIAN_H
      23                 :            : #define __SSRC_WSPR_UTILITY_ENDIAN_H
      24                 :            : 
      25                 :            : #include <ssrc/wispers-packages.h>
      26                 :            : 
      27                 :            : #include <cstdint>
      28                 :            : 
      29                 :            : __BEGIN_NS_SSRC_WSPR_UTILITY
      30                 :            : 
      31                 :          1 : inline bool is_little_endian() {
      32                 :          1 :   const std::int32_t num = 1;
      33                 :          1 :   return (*reinterpret_cast<const char*>(&num) == 1);
      34                 :            : }
      35                 :            : 
      36                 :            : inline bool is_big_endian() {
      37                 :            :   return !is_little_endian();
      38                 :            : }
      39                 :            : 
      40                 :            : __END_NS_SSRC_WSPR_UTILITY
      41                 :            : 
      42                 :            : #endif