Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

endianess.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: endianess.cpp,v 1.4 2001/02/11 02:03:46 plasmoid Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 
00014         File purpose:
00015                 Implementation of the CL_Endian class.
00016 
00017 */
00018 
00019 #include "Core/precomp.h"
00020 
00021 #ifdef BORLAND
00022 #pragma hdrstop
00023 #endif
00024 
00025 #include "API/Core/IOData/cl_endian.h"
00026 /*
00027 void CL_Endian::swap(void *data, int type_size)
00028 {
00029         if (type_size == 1) return;
00030 
00031         unsigned char *d = (unsigned char *) data;
00032         
00033         for (int i=0; i<type_size/2; i++)
00034         {
00035                 unsigned char a = d[i];
00036                 d[i] = d[type_size-1-i];
00037                 d[type_size-1-i] = a;
00038         }
00039 }
00040 */
00041 
00042 void CL_Endian::swap(void *data, int type_size, int total_times)
00043 {
00044         if (type_size == 1) return;
00045 
00046         unsigned char *d = (unsigned char *) data;
00047         
00048         for (int j=0; j<total_times; j++)
00049         {
00050                 for (int i=0; i<type_size/2; i++)
00051                 {
00052                         unsigned char a = d[i];
00053                         d[i] = d[type_size-1-i];
00054                         d[type_size-1-i] = a;
00055                 }
00056                 
00057                 d += type_size;
00058         }
00059 }
00060 
00061 bool CL_Endian::is_system_big()
00062 {
00063 #ifdef USE_BIG_ENDIAN
00064         return true;
00065 #else
00066         return false;
00067 #endif
00068 }
00069 
00070 bool CL_Endian::is_system_64bit()
00071 {
00072         if (sizeof(int*) == 8) return true;
00073         return false;
00074 }

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001