source: NonGTP/FCollada/FUtils/Platforms.h @ 964

Revision 964, 4.5 KB checked in by igarcia, 19 years ago (diff)
Line 
1/*
2        Copyright (C) 2005-2006 Feeling Software Inc.
3        MIT License: http://www.opensource.org/licenses/mit-license.php
4*/
5/*
6        Based on the FS Import classes:
7        Copyright (C) 2005-2006 Feeling Software Inc
8        Copyright (C) 2005-2006 Autodesk Media Entertainment
9        MIT License: http://www.opensource.org/licenses/mit-license.php
10*/
11
12#ifndef _PLATFORMS_H_
13#define _PLATFORMS_H_
14
15#ifdef FCOLLADA_DLL
16// Disable the "private member not available for export" warning,
17// because I don't feel like writing interfaces
18#pragma warning(disable:4251)
19#ifdef FCOLLADA_INTERNAL
20#define FCOLLADA_EXPORT __declspec(dllexport)
21#else
22#define FCOLLADA_EXPORT __declspec(dllimport)
23#endif
24#else
25#define FCOLLADA_EXPORT
26#endif
27
28#ifdef __PPU__
29#define UNICODE
30#endif // __PPU__
31
32// Ensure that both UNICODE and _UNICODE are set.
33#ifdef UNICODE
34#ifndef _UNICODE
35#define _UNICODE
36#endif
37#else
38#ifdef _UNICODE
39#define UNICODE
40#endif
41#endif
42
43#include <math.h>
44
45#ifdef WIN32
46#pragma warning(disable:4702)
47#include <windows.h>
48#else
49#ifdef MAC_TIGER
50#include <ctype.h>
51#include <wctype.h>
52#else // MAC_TIGER
53#if defined(LINUX) || defined(__PPU__)
54#else // LINUX
55#error "Unsupported platform."
56#endif // LINUX || __PPU__
57#endif // MAC_TIGER
58
59#endif // WIN32
60
61// Cross-platform type definitions
62#ifdef WIN32
63
64#define int8 char
65typedef short int16;
66typedef long int32;
67typedef __int64 int64;
68typedef unsigned char uint8;
69typedef unsigned short uint16;
70typedef unsigned long uint32;
71typedef unsigned __int64 uint64;
72
73#else // For LINUX and MAC_TIGER
74
75#define int8 char
76typedef short int16;
77typedef long int32;
78typedef long long int64;
79typedef unsigned char uint8;
80typedef unsigned short uint16;
81typedef unsigned long uint32;
82typedef unsigned long long uint64;
83#endif
84
85// Important functions that some OSes have missing!
86#ifdef MAC_TIGER
87inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; }
88inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; }
89#ifndef isinf
90#define isinf __isinff
91#endif
92#define stricmp strcasecmp
93
94#elif defined(__PPU__)
95#define glClearDepth glClearDepthf
96
97#endif // MAC_TIGER
98
99// Cross-platform needed functions
100#ifdef WIN32
101
102#define vsnprintf _vsnprintf
103#define snprintf _snprintf
104#define vsnwprintf _vsnwprintf
105#define snwprintf _snwprintf
106#define strlower _strlwr
107
108#else // WIN32
109
110#define vsnwprintf vswprintf
111#define snwprintf swprintf
112
113#endif // WIN32
114
115// For Doxygen purposes, we stopped using the "using namespace std;" statement and use shortcuts instead.
116
117/** A STL string. */
118typedef std::string string;
119
120/** A STL map. */
121template <typename _Kty, typename _Ty>
122class map : public std::map<_Kty, _Ty> {};
123
124// fstring and character definition
125#ifdef UNICODE
126#ifdef WIN32
127
128#include <tchar.h>
129        typedef TCHAR fchar;
130        typedef std::basic_string<fchar> fstring;
131        #define FC(a) __T(a)
132
133        #define fstrlen _tcslen
134        #define fstrcmp _tcscmp
135        #define fstricmp _tcsicmp
136        #define fstrncpy _tcsncpy
137        #define fstrrchr _tcsrchr
138        #define fstrlower _tcslwr
139        #define fsnprintf _sntprintf
140        #define fvsnprintf _vsntprintf
141
142        #define fchdir _tchdir
143
144#elif __PPU__
145
146        #define fchar wchar_t
147        typedef std::wstring fstring;
148        #define FC(a) L ## a
149
150        #define fstrlen wcslen
151        #define fstrcmp wcscmp
152        #define fstricmp wcscmp         // [claforte] TODO: Implement __PPU__ version of wcsicmp
153        #define fstrncpy wcsncpy
154        #define fstrrchr wcsrchr
155        #define fstrlower(x) iswlower(*(x))
156        #define fsnprintf swprintf
157        #define fvsnprintf vswprintf
158
159        #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str())
160
161#else // For MacOSX and Linux platforms
162
163        #define fchar wchar_t
164        typedef std::wstring fstring;
165        #define FC(a) L ## a
166
167        #define fstrlen wcslen
168        #define fstrcmp wcscmp
169        #define fstricmp wcsicmp
170        #define fstrncpy wcsncpy
171        #define fstrrchr wcsrchr
172        #define fstrlower wcslwr
173        #define fsnprintf swprintf
174        #define fvsnprintf vswprintf
175
176        #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str())
177
178#endif // WIN32
179
180#else // UNICODE
181
182typedef char fchar;
183typedef std::basic_string<fchar> fstring;
184#define FC(a) a
185
186#define fstrlen strlen
187#define fstrcmp strcmp
188#define fstricmp stricmp
189#define fstrncpy strncpy
190#define fstrrchr strrchr
191#define fstrlower strlower
192#define fsnprintf snprintf
193#define fvsnprintf vsnprintf
194
195#define fatol atol
196#define fatof atof
197#define fchdir chdir
198
199#endif // UNICODE
200
201#ifndef WIN32
202#define MAX_PATH 1024
203#endif // !WIN32
204
205#endif // _PLATFORMS_H_
Note: See TracBrowser for help on using the repository browser.