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

Utils.h

Go to the documentation of this file.
00001 // ZenLib::Utils - Very small utilities
00002 // Copyright (C) 2002-2004 Jérôme Martinez, Zen@MediaArea.net
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 //
00008 // Permission is granted to anyone to use this software for any purpose,
00009 // including commercial applications, and to alter it and redistribute it
00010 // freely, subject to the following restrictions:
00011 //
00012 // 1. The origin of this software must not be misrepresented; you must not
00013 //    claim that you wrote the original software. If you use this software
00014 //    in a product, an acknowledgment in the product documentation would be
00015 //    appreciated but is not required.
00016 // 2. Altered source versions must be plainly marked as such, and must not be
00017 //    misrepresented as being the original software.
00018 // 3. This notice may not be removed or altered from any source distribution.
00019 //
00020 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00021 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022 // ZenUtils
00023 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00024 //
00025 // Version 0.1.0
00026 // -------------
00027 // BigEndianToInt    (8-64 bits)
00028 // LittleEndianToInt (8-64 bits)
00029 //
00030 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00031 //
00032 // 0.1.0 (Zen@MediaArea.net)
00033 // BigEndianToInt    (8-64 bits)
00034 // LittleEndianToInt (8-64 bits)
00035 //
00036 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00037 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00038 
00039 //---------------------------------------------------------------------------
00040 #ifndef ZenUtilsH
00041 #define ZenUtilsH
00042 //---------------------------------------------------------------------------
00043 
00044 //---------------------------------------------------------------------------
00045 #include <ZenLib/Conf.h>
00046 //---------------------------------------------------------------------------
00047 
00048 namespace ZenLib
00049 {
00050 
00051 //***************************************************************************
00052 // Integer transformations
00053 //***************************************************************************
00054 
00055 //---------------------------------------------------------------------------
00056 //Little Endians
00057 int8s  LittleEndian2int8s  (const char* List);
00058 int8u  LittleEndian2int8u  (const char* List);
00059 int16s LittleEndian2int16s (const char* List);
00060 int16u LittleEndian2int16u (const char* List);
00061 int32s LittleEndian2int32s (const char* List);
00062 int32u LittleEndian2int32u (const char* List);
00063 #if (MAXTYPE_INT >= 64)
00064 int64s LittleEndian2int64s (const char* List);
00065 int64u LittleEndian2int64u (const char* List);
00066 #endif
00067 
00068 //---------------------------------------------------------------------------
00069 //Big Endians
00070 int8s  BigEndian2int8s     (const char* List);
00071 int8u  BigEndian2int8u     (const char* List);
00072 int16s BigEndian2int16s    (const char* List);
00073 int16u BigEndian2int16u    (const char* List);
00074 int32s BigEndian2int32s    (const char* List);
00075 int32u BigEndian2int32u    (const char* List);
00076 #if (MAXTYPE_INT >= 64)
00077 int64s BigEndian2int64s    (const char* List);
00078 int64u BigEndian2int64u    (const char* List);
00079 #endif
00080 
00081 //---------------------------------------------------------------------------
00082 // int32 - int64
00083 #if (MAXTYPE_INT >= 64)
00084     int64s int32s_int64s (                int32s  High, int32u  Low);
00085     int64u int32u_int64u (                int32u  High, int32u  Low);
00086     void   int32s_int64s (int64s &BigInt, int32s  High, int32u  Low);
00087     void   int32u_int64u (int64s &BigInt, int32u  High, int32u  Low);
00088     void   int64s_int32s (int64s  BigInt, int32s &High, int32u &Low);
00089     void   int64u_int32u (int64u  BigInt, int32u &High, int32u &Low);
00090 #endif
00091 
00092 //---------------------------------------------------------------------------
00093 // Floats and ints
00094 int32s float32_int32s  (float32 F, bool Rounded=true);
00095 int64s float32_int64s  (float32 F, bool Rounded=true);
00096 int32s float64_int32s  (float64 F, bool Rounded=true);
00097 int64s float64_int64s  (float64 F, bool Rounded=true);
00098 
00099 // These functions are used because MSVC6 isn't able to convert an unsigned int64 to a floating-point value, and I couldn't think of a cleaner way to handle it.
00100 #if _MSC_VER <= 1200
00101     inline float32 int64u_float32  (int64u v) { return static_cast<float32>(static_cast<int64s>(v>>1))*2.0f + static_cast<float32>(static_cast<int64s>(v & 1)); }
00102     inline float64 int64u_float64  (int64u v) { return static_cast<float64>(static_cast<int64s>(v>>1))*2.0f + static_cast<float32>(static_cast<int64s>(v & 1)); }
00103 #else
00104     #pragma
00105     #pragma warning( disable : 4244 )
00106     inline float32 int64u_float32  (int64u v) { return v; }
00107     inline float64 int64u_float64  (int64u v) { return v; }
00108     #pragma warning( default : 4244 )
00109 #endif
00110 
00111 } //namespace ZenLib
00112 #endif

Generated on Sun Oct 16 20:41:19 2005 for ZenLib by doxygen1.3-rc3