FUtils/Platforms.h

00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     Based on the FS Import classes:
00007     Copyright (C) 2005-2006 Feeling Software Inc
00008     Copyright (C) 2005-2006 Autodesk Media Entertainment
00009     MIT License: http://www.opensource.org/licenses/mit-license.php
00010 */
00011 
00012 #ifndef _PLATFORMS_H_
00013 #define _PLATFORMS_H_
00014 
00015 #ifdef FCOLLADA_DLL
00016 // Disable the "private member not available for export" warning,
00017 // because I don't feel like writing interfaces
00018 #pragma warning(disable:4251) 
00019 #ifdef FCOLLADA_INTERNAL
00020 #define FCOLLADA_EXPORT __declspec(dllexport)
00021 #else
00022 #define FCOLLADA_EXPORT __declspec(dllimport)
00023 #endif
00024 #else
00025 #define FCOLLADA_EXPORT
00026 #endif
00027 
00028 #ifdef __PPU__
00029 #define UNICODE
00030 #endif // __PPU__
00031 
00032 // Ensure that both UNICODE and _UNICODE are set.
00033 #ifdef UNICODE
00034 #ifndef _UNICODE
00035 #define _UNICODE
00036 #endif
00037 #else
00038 #ifdef _UNICODE
00039 #define UNICODE
00040 #endif
00041 #endif
00042 
00043 #include <math.h>
00044 
00045 #ifdef WIN32
00046 #pragma warning(disable:4702)
00047 #include <windows.h>
00048 #else
00049 #ifdef MAC_TIGER
00050 #include <ctype.h>
00051 #include <wctype.h>
00052 #else // MAC_TIGER
00053 #if defined(LINUX) || defined(__PPU__)
00054 #else // LINUX
00055 #error "Unsupported platform."
00056 #endif // LINUX || __PPU__
00057 #endif // MAC_TIGER
00058 
00059 #endif // WIN32
00060 
00061 // Cross-platform type definitions
00062 #ifdef WIN32
00063 
00064 #define int8 char
00065 typedef short int16;
00066 typedef long int32;
00067 typedef __int64 int64;
00068 typedef unsigned char uint8;
00069 typedef unsigned short uint16;
00070 typedef unsigned long uint32;
00071 typedef unsigned __int64 uint64;
00072 
00073 #else // For LINUX and MAC_TIGER
00074 
00075 #define int8 char
00076 typedef short int16;
00077 typedef long int32;
00078 typedef long long int64;
00079 typedef unsigned char uint8;
00080 typedef unsigned short uint16;
00081 typedef unsigned long uint32;
00082 typedef unsigned long long uint64;
00083 #endif
00084 
00085 // Important functions that some OSes have missing!
00086 #ifdef MAC_TIGER
00087 inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; }
00088 inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; }
00089 #ifndef isinf
00090 #define isinf __isinff
00091 #endif
00092 #define stricmp strcasecmp
00093 
00094 #elif defined(__PPU__)
00095 #define glClearDepth glClearDepthf
00096 
00097 #endif // MAC_TIGER
00098 
00099 // Cross-platform needed functions
00100 #ifdef WIN32
00101 
00102 #define vsnprintf _vsnprintf
00103 #define snprintf _snprintf
00104 #define vsnwprintf _vsnwprintf
00105 #define snwprintf _snwprintf
00106 #define strlower _strlwr
00107 
00108 #else // WIN32
00109 
00110 #define vsnwprintf vswprintf
00111 #define snwprintf swprintf
00112 
00113 #endif // WIN32
00114 
00115 // For Doxygen purposes, we stopped using the "using namespace std;" statement and use shortcuts instead.
00116 
00118 typedef std::string string;
00119 
00121 template <typename _Kty, typename _Ty>
00122 class map : public std::map<_Kty, _Ty> {};
00123 
00124 // fstring and character definition
00125 #ifdef UNICODE
00126 #ifdef WIN32
00127 
00128 #include <tchar.h>
00129     typedef TCHAR fchar;
00130     typedef std::basic_string<fchar> fstring;
00131     #define FC(a) __T(a)
00132 
00133     #define fstrlen _tcslen
00134     #define fstrcmp _tcscmp
00135     #define fstricmp _tcsicmp
00136     #define fstrncpy _tcsncpy
00137     #define fstrrchr _tcsrchr
00138     #define fstrlower _tcslwr
00139     #define fsnprintf _sntprintf
00140     #define fvsnprintf _vsntprintf
00141 
00142     #define fchdir _tchdir
00143 
00144 #elif __PPU__
00145 
00146     #define fchar wchar_t
00147     typedef std::wstring fstring;
00148     #define FC(a) L ## a
00149 
00150     #define fstrlen wcslen
00151     #define fstrcmp wcscmp
00152     #define fstricmp wcscmp     // [claforte] TODO: Implement __PPU__ version of wcsicmp
00153     #define fstrncpy wcsncpy
00154     #define fstrrchr wcsrchr
00155     #define fstrlower(x) iswlower(*(x))
00156     #define fsnprintf swprintf
00157     #define fvsnprintf vswprintf
00158 
00159     #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str())
00160 
00161 #else // For MacOSX and Linux platforms
00162 
00163     #define fchar wchar_t
00164     typedef std::wstring fstring;
00165     #define FC(a) L ## a
00166 
00167     #define fstrlen wcslen
00168     #define fstrcmp wcscmp
00169     #define fstricmp wcsicmp
00170     #define fstrncpy wcsncpy
00171     #define fstrrchr wcsrchr
00172     #define fstrlower wcslwr
00173     #define fsnprintf swprintf
00174     #define fvsnprintf vswprintf
00175 
00176     #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str())
00177 
00178 #endif // WIN32
00179 
00180 #else // UNICODE
00181 
00182 typedef char fchar;
00183 typedef std::basic_string<fchar> fstring;
00184 #define FC(a) a
00185 
00186 #define fstrlen strlen
00187 #define fstrcmp strcmp
00188 #define fstricmp stricmp
00189 #define fstrncpy strncpy
00190 #define fstrrchr strrchr
00191 #define fstrlower strlower
00192 #define fsnprintf snprintf
00193 #define fvsnprintf vsnprintf
00194 
00195 #define fatol atol
00196 #define fatof atof
00197 #define fchdir chdir
00198 
00199 #endif // UNICODE
00200 
00201 #ifndef WIN32
00202 #define MAX_PATH 1024
00203 #endif // !WIN32
00204 
00205 #endif // _PLATFORMS_H_

Generated on Fri May 12 16:44:39 2006 for FCollada by  doxygen 1.4.6-NO