Logo Search packages:      
Sourcecode: lttoolbox version File versions  Download package

template<class T>
static void EndianUtil< T >::write ( ostream &  os,
T const &  val 
) [inline, static]

Write procedure, C++ I/O version.

Parameters:
output the stream to write to
val the value of the generic object to write to the stream

Definition at line 114 of file EndianUtil.H.

  {
    T val2 = val;
#if __BYTE_ORDER == __BIG_ENDIAN
    os.write(reinterpret_cast<char *>(&val2), sizeof(T));
#else
    char *s = reinterpret_cast<char *>(&val2);
    
    for(int i = sizeof(T)-1; i != -1; i--)
    {
      os.write(&(s[i]), sizeof(char));
    }
#endif
  }


Generated by  Doxygen 1.6.0   Back to index