LCOV - code coverage report
Current view: top level - gfx/2d - BigEndianInts.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 12 33.3 %
Date: 2017-07-14 16:53:18 Functions: 1 5 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_BigEndianInts_h
       8             : #define mozilla_BigEndianInts_h
       9             : 
      10             : #include "mozilla/EndianUtils.h"
      11             : 
      12             : namespace mozilla {
      13             : 
      14             : #pragma pack(push, 1)
      15             : 
      16             : struct BigEndianUint16
      17             : {
      18             : #ifdef __SUNPRO_CC
      19             :   BigEndianUint16& operator=(const uint16_t aValue)
      20             :   {
      21             :     value = NativeEndian::swapToBigEndian(aValue);
      22             :     return *this;
      23             :   }
      24             : #else
      25          39 :   MOZ_IMPLICIT BigEndianUint16(const uint16_t aValue)
      26          39 :   {
      27          39 :     value = NativeEndian::swapToBigEndian(aValue);
      28          39 :   }
      29             : #endif
      30             : 
      31           0 :   operator uint16_t() const
      32             :   {
      33           0 :     return NativeEndian::swapFromBigEndian(value);
      34             :   }
      35             : 
      36             :   friend inline bool
      37           0 :   operator==(const BigEndianUint16& lhs, const BigEndianUint16& rhs)
      38             :   {
      39           0 :     return lhs.value == rhs.value;
      40             :   }
      41             : 
      42             :   friend inline bool
      43           0 :   operator!=(const BigEndianUint16& lhs, const BigEndianUint16& rhs)
      44             :   {
      45           0 :     return !(lhs == rhs);
      46             :   }
      47             : 
      48             : private:
      49             :   uint16_t value;
      50             : };
      51             : 
      52             : struct BigEndianUint32
      53             : {
      54             : #ifdef __SUNPRO_CC
      55             :   BigEndianUint32& operator=(const uint32_t aValue)
      56             :   {
      57             :     value = NativeEndian::swapToBigEndian(aValue);
      58             :     return *this;
      59             :   }
      60             : #else
      61             :   MOZ_IMPLICIT BigEndianUint32(const uint32_t aValue)
      62             :   {
      63             :     value = NativeEndian::swapToBigEndian(aValue);
      64             :   }
      65             : #endif
      66             : 
      67           0 :   operator uint32_t() const
      68             :   {
      69           0 :     return NativeEndian::swapFromBigEndian(value);
      70             :   }
      71             : 
      72             : private:
      73             :   uint32_t  value;
      74             : };
      75             : 
      76             : #pragma pack(pop)
      77             : 
      78             : } // mozilla
      79             : 
      80             : #endif // mozilla_BigEndianInts_h

Generated by: LCOV version 1.13