.. # split from OESystemFunctions.rst:1205

.. include:: ../substitutions

.. oe:namespace:: OESystem

.. meta::
   :keywords: OEGetFileEndian

.. oe:function:: OEGetFileEndian

   .. oe:api::

      template<class T>
      bool OEGetFileEndian(unsigned int)
      template<>
      bool OEGetFileEndian<int>(unsigned int byte)
      template<>
      bool OEGetFileEndian<unsigned int>(unsigned int byte)
      template<>
      bool OEGetFileEndian<float>(unsigned int byte)
      template<>
      bool OEGetFileEndian<double>(unsigned int byte)
      template<>
      bool OEGetFileEndian<short>(unsigned int byte)
      template<>
      bool OEGetFileEndian<oefpos_t>(unsigned int byte)
      template<>
      bool OEGetFileEndian<OEPlatform::OEHalfFloat>(unsigned int byte)

   Given the endianness encoded in the ``byte``, return whether this
   machine needs to swap bytes for the given data type ``T``. Always
   returns ``false`` if ``sizeof(T)`` is 1. Will fail to compile if
   the size is greater than 1 and an explicit template specialization
   is not given.

   .. seealso::

      Designed to work in conjunction with
      :oe:func:`OESystem::OEGetHostEndian`. The byte returned by
      :oe:func:`OESystem::OEGetHostEndian` should be written to the
      output file, then :oe:func:`OESystem::OEGetFileEndian` will
      determine whether the bytes of the given type ``T`` need to be
      swapped while being read by :oe:func:`OESystem::OEBReadData`.


