CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
OdPlatform.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25
26
27#ifndef _OD_PLATFORM_H_
28#define _OD_PLATFORM_H_
29
30
31#include "OdPlatformSettings.h"
32#include "OdGUID.h"
33#ifndef ODA_WINDOWS
34#include <type_traits>
35#endif
36// Moved from OdaCommon.h, to be used in string functions
37template<class T>
38ODRX_CONSTEXPR const T& odmax(const T& a, const T& b)
39{
40 return a < b ? b : a;
41}
42template<class T, class U, typename std::enable_if<sizeof(T) >= sizeof(U) && std::is_arithmetic<T>::value && std::is_arithmetic<U>::value && std::is_unsigned<T>::value == std::is_unsigned<U>::value, bool>::type = true>
44{
45 return odmax(a, static_cast<T>(b));
46}
47template<class T, class U, typename std::enable_if<sizeof(T) >= sizeof(U) && std::is_arithmetic<T>::value && std::is_arithmetic<U>::value && std::is_unsigned<T>::value && std::is_signed<U>::value, bool>::type = true>
48ODRX_CONSTEXPR T odmax(T a, U b)
49{
50 return b < 0 ? a : odmax(a, static_cast<T>(b));
51}
52template<class T, class U, typename std::enable_if<(sizeof(T) > sizeof(U)) && std::is_arithmetic<T>::value && std::is_arithmetic<U>::value && std::is_signed<T>::value && std::is_unsigned<U>::value, bool>::type = true>
54{
55 return a < 0 ? static_cast<T>(b) : odmax(a, static_cast<T>(b));
56}
57template<class T, class U, typename std::enable_if<(sizeof(T) < sizeof(U)) || (sizeof(T) == sizeof(U) && std::is_signed<T>::value && std::is_unsigned<U>::value), bool>::type = true>
58ODRX_CONSTEXPR U odmax(T a, U b)
59{
60 return odmax(b, a);
61}
62
63template<class T>
64ODRX_CONSTEXPR const T& odmin(const T& a, const T& b)
65{
66 return a < b ? a : b;
67}
68template<class T, class U, typename std::enable_if<sizeof(T) >= sizeof(U) && std::is_arithmetic<T>::value && std::is_arithmetic<U>::value && std::is_unsigned<T>::value == std::is_unsigned<U>::value, bool>::type = true>
70{
71 return odmin(a, static_cast<T>(b));
72}
73template<class T, class U, typename std::enable_if<sizeof(T) >= sizeof(U) && std::is_arithmetic<T>::value && std::is_arithmetic<U>::value && std::is_unsigned<T>::value && std::is_signed<U>::value, bool>::type = true>
75{
76 return b < 0 ? b : static_cast<U>(odmin(a, static_cast<T>(b)));
77}
78template<class T, class U, typename std::enable_if<(sizeof(T) > sizeof(U)) && std::is_arithmetic<T>::value && std::is_arithmetic<U>::value && std::is_signed<T>::value && std::is_unsigned<U>::value, bool>::type = true>
80{
81 return a < 0 ? a : odmin(a, static_cast<T>(b));
82}
83template<class T, class U, typename std::enable_if<sizeof(T) <= sizeof(U) && std::is_signed<T>::value && std::is_unsigned<U>::value, bool>::type = true>
84ODRX_CONSTEXPR T odmin(T a, U b)
85{
86 return odmin(b, a);
87}
88template<class T, class U, typename std::enable_if<sizeof(T) < sizeof(U) && !(std::is_signed<T>::value && std::is_unsigned<U>::value), bool>::type = true>
89ODRX_CONSTEXPR U odmin(T a, U b)
90{
91 return odmin(b, a);
92}
93
94#if defined(ODA_WINDOWS)
95#include <math.h>
96#include <float.h>
97#define Odisnan(x) (::_isnan(x) != 0)
98#define Odfinite(x) (::_finite(x) != 0)
99#ifndef OD_USE_EXTENDED_FUNCTIONS
100#define GETSS(s,n) ::fgets(s, n, stdin)
101#define OdWprintf wprintf
102#define OdPrintf printf
103#else
104#define GETSS(s,n) ::gets_s(s,n)
105#define OdWprintf _wprintf_p
106#define OdPrintf _printf_p
107#endif
108
109#ifdef ODA_WINDOWS_GCC
110#include <ctype.h>
111#endif
112
113#if defined(_MSC_VER) && (_MSC_VER < 1400)
114#ifndef GET_X_LPARAM
115#define GET_X_LPARAM(lParam) ((int)(short)LOWORD(lParam))
116#endif
117#ifndef GET_Y_LPARAM
118#define GET_Y_LPARAM(lParam) ((int)(short)HIWORD(lParam))
119#endif
120#endif
121
122#else
123#include <stdio.h>
124#include <limits.h>
125#define GETSS(s, n) fgets(s, n, stdin)
126
127#ifndef MAX_PATH
128#define MAX_PATH PATH_MAX
129#endif
130
131#define OdWprintf wprintf
132#define OdPrintf printf
133
134#if defined(__APPLE__) || defined(__GNUC__) && ( __GNUC__>=5 || __GNUC__==4 && __GNUC_MINOR__>=9 )
135#include <math.h>
136#define Odisnan(x) std::isnan(x)
137#define Odfinite(x) std::isfinite(x)
138#else
139#if defined(__sun)
140#include <ieeefp.h>
141#else
142#include <math.h>
143#endif
144#define Odisnan(x) std::isnan(x)
145#define Odfinite(x) (finite(x) != 0)
146#endif
147#endif
148
149#ifdef ANDROID
150 //r9d have disabled acosl function
151 #ifndef acosl
152 #define acosl acos
153 #endif
154#endif
155
156#ifdef _WIN32_WCE
157// Safe to avoid #ifndef/#endif here due to WinCE specific
158#define sinf sin
159#define cosf cos
160#define atanf atan
161#endif
162
163#ifdef ANDROID_WCHAR
164#include "../../ThirdParty/wchar/stdlib_.h"
165#include "../../ThirdParty/wchar/wchar_.h"
166#define Od_atof Citrus::atof
167#define Od_abs Citrus::abs
168#define Od_labs Citrus::labs
169#define Od_llabs Citrus::llabs
170#define Od_srand Citrus::srand
171#define Od_rand Citrus::rand
172#define Od_wcstombs Citrus::wcstombs
173#define Od_wcscpy Citrus::wcscpy
174#define Od_wcscmp Citrus::wcscmp
175#define Od_wcscat Citrus::wcscat
176#define Od_wcschr Citrus::wcschr
177#define Od_wcscpy Citrus::wcscpy
178#define Od_wcslen Citrus::wcslen
179#define Od_wcsncpy Citrus::wcsncpy
180#else
181
182#if defined(_MSC_VER) && (_MSC_VER < 1600)
183#include <stdlib.h>
184#else
185#include <cstdlib>
186#include <cmath>
187#endif
188
189#if defined(__BCPLUSPLUS__) || defined(__BORLANDC__) || defined(__sun)
190inline long Od_abs(OdInt64 val) { return std::labs(val); }
191inline int Od_abs(OdInt32 val) { return std::abs(val); }
192#if OD_SIZEOF_LONG == 4
193inline int Od_abs(int val) { return std::abs(val); }
194#endif
195inline double Od_abs(double val) { return std::fabs(val); }
196#else
197#define Od_abs std::abs
198#endif
199
200#define Od_atof atof
201#define Od_labs std::labs
202#define Od_llabs std::llabs
203#define Od_srand srand
204#define Od_rand rand
205#define Od_wcstombs wcstombs
206#define Od_wcscpy wcscpy
207#define Od_wcscmp wcscmp
208#define Od_wcscat wcscat
209#define Od_wcschr wcschr
210#define Od_wcslen wcslen
211#define Od_wcsncpy wcsncpy
212#endif
213
214#if defined(_MSC_VER) && (_MSC_VER < 1800)
215template<typename T>
216inline T Od_round(T a)
217{
218 T result;
219 if (a - floor(a) >= 0.5)
220 result = floor(a) + 1;
221 else
222 result = floor(a);
223 return result;
224}
225#else
226#define Od_round std::round
227#endif
228
229#ifndef odStrChr
230#define odStrChr(str, ch) strchr(str, ch)
231#endif
232
233#ifndef odWStrChr
234#define odWStrChr(str, ch) Od_wcschr(str, ch)
235#endif
236
237#ifdef OD_STRING_FNS
238
239
240FIRSTDLL_EXPORT extern int Od_stricmp(const OdChar*str, const OdChar* str2);
241FIRSTDLL_EXPORT extern int Od_strnicmp(const OdChar *s1, const OdChar *s2, int len);
242FIRSTDLL_EXPORT extern OdChar* Od_strupr(OdChar* str);
243FIRSTDLL_EXPORT extern OdChar* Od_strlwr(OdChar* str);
244FIRSTDLL_EXPORT extern OdChar* Od_strrev(OdChar* str);
245FIRSTDLL_EXPORT extern int Od_strnicmpA(const char *s1, const char *s2, int len);
246FIRSTDLL_EXPORT extern int Od_stricmpA(const char* str, const char* str2);
247FIRSTDLL_EXPORT extern char* Od_struprA(char* str);
248FIRSTDLL_EXPORT extern char* Od_strlwrA(char* str);
249FIRSTDLL_EXPORT extern char* Od_strrevA(char* str);
250
251#if !defined(_WIN32_WCE)
252#define odStrUpr(str) Od_strupr(str)
253#define odStrLwr(str) Od_strlwr(str)
254#define odStrRev(str) Od_strrev(str)
255#endif
256//FELIX_CHANGE_BEGIN
257/*
258#if !defined(__linux__) && !defined(_WIN32_WCE)
259*/
260#if !defined(__linux__) && !defined(_WIN32_WCE) || defined(ANDROID)//FELIX_CHANGE_END
261#define odStrICmp(str, str2) Od_stricmp(str, str2)
262#define odStrnICmp(str, str2, n) Od_strnicmp(str, str2, n)
263#define odStrnICmpA Od_strnicmpA
264#define odStrICmpA(str, str2) Od_stricmpA(str, str2)
265#define odStrUprA(str) Od_struprA(str)
266#define odStrLwrA(str) Od_strlwrA(str)
267#define odStrRevA(str) Od_strrevA(str)
268
269#endif // !defined(__linux__)
270
271#endif /* OD_STRING_FNS */
272
273/* strings functions */
274//FELIX_CHANGE_BEGIN
275/*
276#if defined(ANDROID_WCHAR)
277 #include <string>
278 #if !defined(OD_WSTRING_DEFINED) && (!defined(_STRINGFWD_H) || !defined(_GLIBCXX_USE_WCHAR_T))
279 #define OD_WSTRING_DEFINED
280 #include <bits/basic_string.h>
281 //#include <iosfwd>
282 namespace std
283 {
284 typedef basic_string<wchar_t> wstring;
285 typedef basic_istringstream<wchar_t> wistringstream;
286 typedef basic_stringstream<wchar_t> wstringstream;
287 }
288 #endif
289 #include "../../ThirdParty/wchar/wchar_.h" // #include <wchar_.h>
290
291 #define odStrLen(str) Citrus::wcslen(str)
292 #define odStrCmp(str, str2) Citrus::wcscmp(str, str2)
293 inline long Od_strtoint(const OdChar* str)
294 {
295 return Citrus::wcstol((const wchar_t*)str, 0, 10);
296 }
297 #define odStrToInt(str) Od_strtoint(str)
298
299 #pragma MARKMESSAGE("DNA: odStrToInt() looses highest bit of UInt32: FFFFFFFF -> 7FFFFFFF (at least on WIN64)")
300 #define odStrToUInt(str) (unsigned long)(Od_strtoint(str))
301 // TODO
302 //inline unsigned long Od_strtouint(const OdChar* str)
303 //{
304 // return Citrus::wcstoul((const wchar_t*)str, 0, 10);
305 //}
306 //#define odStrToUInt(str) Od_strtouint(str)
307
308 // #define odSScanf Citrus::swscanf
309 // #define odSprintf Citrus::swprintf
310 inline double Od_wtof(const wchar_t* str)
311 {
312 wchar_t *endptr = 0;
313 return Citrus::wcstold(str, &endptr);
314 }
315 #define odStrToF Od_wtof
316 #define odStrStr Citrus::wcsstr
317 // see OdDToStr.h and TD/Source/fltcvt/OdGdtoa.cpp for odDToStr and odStrToD
318 #define wcsicmp Citrus::wcscasecmp
319 #define wcsnicmp Citrus::wcsncasecmp
320#else
321 #include <wchar.h>
322#endif
323*/
324#include <wchar.h>
325//FELIX_CHANGE_END
326
327#ifndef odStrLen
328#define odStrLen(str) wcslen(str)
329#endif
330
331#ifndef odStrLenA
332#define odStrLenA(str) strlen(str)
333#endif
334
335#ifndef odStrCmp
336#define odStrCmp(str, str2) wcscmp(str, str2)
337#endif
338
339#ifndef odStrCmpA
340#define odStrCmpA(str, str2) strcmp(str, str2)
341#endif
342
343#if defined(ODA_WINDOWS)
344#ifndef NOMINMAX
345#define NOMINMAX
346#endif
347#endif
348
349#if defined(ODA_WINDOWS)
350#ifndef WIN32_LEAN_AND_MEAN
351#define WIN32_LEAN_AND_MEAN
352#endif
353#include <Windows.h>
354#endif
355#if defined( ANDROID ) || defined ( _WIN32_WCE ) || (defined (_MSC_VER) && _MSC_VER < 1400) || defined(_WINRT)
356 #define FSEEK fseek
357 #define FTELL ftell
358 #define FOPEN fopen
359 #define OFFSETTYPE(offset) (long)offset
360
361#elif defined(__APPLE__) || defined( __hpux )
362 #define FSEEK fseeko
363 #define FTELL ftello
364 #define FOPEN fopen
365 #define OFFSETTYPE(offset) offset
366#else
367 #define FSEEK fseeko64
368 #define FTELL ftello64
369 #define FOPEN fopen64
370 #define OFFSETTYPE(offset) offset
371#endif
372
373#if defined(__linux__) || defined(EMCC)
374#include <wctype.h> // towlower, towupper
375#if !defined(EMCC) && !defined(__clang__)
376#include <bits/stl_algobase.h> // For std::swap (gcc 3.3 and 3.4)
377#endif
378#include <utility> // std::swap
379
380#ifndef wcsicmp
381#define wcsicmp wcscasecmp
382#endif
383
384#ifndef wcsnicmp
385#define wcsnicmp wcsncasecmp
386#endif
387
388#ifndef wcsupr
389inline wchar_t* wcsupr(wchar_t* s)
390{
391 if(!s)
392 return 0;
393 for(wchar_t* p = s; *p; ++p)
394 *p = towupper(*p);
395 return s;
396}
397#endif
398
399#ifndef wcslwr
400inline wchar_t* wcslwr(wchar_t* s)
401{
402 if(!s)
403 return 0;
404 for(wchar_t* p = s; *p; ++p)
405 *p = towlower(*p);
406 return s;
407}
408#endif
409#ifndef wcsrev
410inline wchar_t* wcsrev(wchar_t* s)
411{
412 if(!s)
413 return 0;
414 wchar_t* e = s + wcslen(s) - 1;
415 wchar_t* s_ = s;
416 while(s < e)
417 {
418 std::swap(*s, *e);
419 ++s;
420 --e;
421 }
422 return s_;
423}
424#endif
425
426#ifdef OD_STRING_FNS
427
428#ifndef stricmp
429#define stricmp Od_stricmpA
430#endif
431
432#ifndef strupr
433#define strupr Od_struprA
434#endif
435
436#ifndef strlwr
437#define strlwr Od_strlwrA
438#endif
439
440#ifndef strrev
441#define strrev Od_strrevA
442#endif
443
444#ifndef strnicmp
445#define strnicmp Od_strnicmpA
446#endif
447
448#endif //OD_STRING_FNS
449
450#endif //defined(__linux__) || defined(EMCC)
451
452#ifndef odStrICmp
453
454#if defined(_WINRT)
455#include <WinNls.h>
456#include <stringapiset.h>
457inline int Od_stricmpW(const OdChar* str, const OdChar* str2){ return CompareStringEx( LOCALE_NAME_INVARIANT, NORM_IGNORECASE, (const wchar_t*)str, -1, (const wchar_t*)str2, -1, NULL, NULL, 0) - 2; }
458#elif defined(_WIN32) ||defined(_WIN64) || defined(_WIN32_WCE)
459inline int Od_stricmpW(const OdChar* str, const OdChar* str2){ return CompareStringW( LOCALE_NEUTRAL, NORM_IGNORECASE, (const wchar_t*)str, -1, (const wchar_t*)str2, -1) - 2; }
460#elif (defined ( __BORLANDC__ ) && (__BORLANDC__) >= 0x530) ||(defined(_MSC_VER) && _MSC_VER > 1200)
461inline int Od_stricmpW(const OdChar* str, const OdChar* str2){ return _wcsicmp(str, str2); }
462#else
463inline int Od_stricmpW(const OdChar* str, const OdChar* str2){ return wcsicmp(str, str2); }
464#endif
465#define odStrICmp Od_stricmpW
466#endif
467
468#ifndef odStrICmpA
469#if defined(ODA_WINDOWS)
470#define odStrICmpA(str, str2) _stricmp(str, str2)
471#else
472#define odStrICmpA(str, str2) stricmp(str, str2)
473#endif
474#endif
475
476#ifndef odStrnICmp
477#if defined(_WINRT)
478#include <stringapiset.h>
479inline int Od_stricmpW(const OdChar* str, const OdChar* str2, size_t n){ return CompareStringEx( LOCALE_NAME_INVARIANT, NORM_IGNORECASE, (const wchar_t*)str, (int)odmin(wcslen((const wchar_t*)str), n), (const wchar_t*)str2, (int)odmin(wcslen((const wchar_t*)str), n), NULL, NULL, 0) - 2; }
480#elif defined(_WIN32) ||defined(_WIN64) || defined(_WIN32_WCE)
481inline int Od_stricmpW(const OdChar* str, const OdChar* str2, size_t n){ return CompareStringW( LOCALE_NEUTRAL, NORM_IGNORECASE, (const wchar_t*)str, (int)odmin(wcslen((const wchar_t*)str), n), (const wchar_t*)str2, (int)odmin(wcslen((const wchar_t*)str2), n))-2;}
482#elif (defined ( __BORLANDC__ ) && (__BORLANDC__) >= 0x530) || (defined(_MSC_VER) && _MSC_VER > 1200)
483inline int Od_stricmpW(const OdChar* str, const OdChar* str2, size_t n){ return _wcsnicmp(str, str2, n);}
484#else
485inline int Od_stricmpW(const OdChar* str, const OdChar* str2, size_t n){ return wcsnicmp(str, str2, n);}
486#endif
487#define odStrnICmp Od_stricmpW
488#endif
489
490#ifndef odStrnICmpA
491#if defined(ODA_WINDOWS)
492#define odStrnICmpA(str, str2, n) _strnicmp(str, str2, n)
493#else
494#define odStrnICmpA(str, str2, n) strnicmp(str, str2, n)
495#endif
496#endif
497
498
499#ifndef odStrUpr
500#if defined(ODA_WINDOWS) && !defined(_WINRT)
501inline OdChar* Od_struprW(OdChar* str){return (OdChar*)CharUpperW((wchar_t*)str);}
502#elif defined(_WINRT)
503inline OdChar* Od_struprW(OdChar* str){return (OdChar*)_wcsupr((wchar_t*)str);}
504#else
505inline OdChar* Od_struprW(OdChar* str){return (OdChar*)wcsupr((OdChar*)str);}
506#endif
507#define odStrUpr(str) Od_struprW(str)
508#endif
509
510#ifndef odStrUprA
511#if defined(ODA_WINDOWS)
512#define odStrUprA(str) _strupr(str)
513#else
514#define odStrUprA(str) strupr(str)
515#endif
516#endif
517
518#ifndef odStrLwr
519#if defined(ODA_WINDOWS) && !defined(_WINRT) && !defined(_WIN32_WCE)
520inline OdChar* Od_strlwrW(OdChar* str){return (OdChar*)CharLowerW((wchar_t*)str);}
521#elif defined (_WINRT) || defined(_WIN32_WCE)
522inline OdChar* Od_strlwrW(OdChar* str){return (OdChar*)_wcslwr((wchar_t*)str);}
523#else
524inline OdChar* Od_strlwrW(OdChar* str){return (OdChar*)wcslwr((OdChar*)str);}
525#endif
526#define odStrLwr(str) Od_strlwrW(str)
527#endif
528
529#ifndef odStrLwrA
530#if defined(ODA_WINDOWS)
531#define odStrLwrA(str) _strlwr(str)
532#else
533#define odStrLwrA(str) strlwr(str)
534#endif
535#endif
536
537#ifndef odStrRev
538#if defined(ODA_WINDOWS)
539inline OdChar* Od_strrevW(OdChar* str) {return (OdChar*)_wcsrev((wchar_t*)str);}
540#else
541inline OdChar* Od_strrevW(OdChar* str) {return (OdChar*)wcsrev((wchar_t*)str);}
542#endif
543#define odStrRev(str) Od_strrevW(str)
544#endif
545
546#ifndef odStrRevA
547#if defined(ODA_WINDOWS)
548#define odStrRevA(str) _strrev(str)
549#else
550#define odStrRevA(str) strrev(str)
551#endif
552#endif
553
554#ifndef odStrToInt
555inline long Od_strtoint(const OdChar* str){ return wcstol((const wchar_t*)str, 0, 10);}
556#define odStrToInt(str) Od_strtoint(str)
557#endif
558
559#ifndef odStrToUInt
560inline unsigned long Od_strtouint(const OdChar* str){ return wcstoul((const wchar_t*)str, 0, 10);}
561#define odStrToUInt(str) Od_strtouint(str)
562#endif
563
564#ifndef Od_isspace
565#define Od_isspace(ch) isspace(ch)
566#endif
567
568#ifndef Od_iswspace
569#if defined(_MSC_VER) && (_MSC_VER <= 1310)
570 #define Od_iswspace(ch) iswctype(ch,_SPACE)
571#else
572 #define Od_iswspace(ch) iswspace(ch)
573#endif
574#endif
575
576#ifndef Od_isdigit
577#define Od_isdigit(ch) isdigit(ch)
578#endif
579
580#ifndef Od_iswdigit
581#if defined(_MSC_VER) && (_MSC_VER <= 1310)
582 #define Od_iswdigit(ch) iswctype(ch,_DIGIT)
583#else
584 #define Od_iswdigit(ch) iswdigit(ch)
585#endif
586#endif
587
588
589#if (defined(sgi) || defined(_AIX) || defined(sparc)) && !defined(__GNUC__)
590#define TD_NEED_SWFNS
591#endif
592//FELIX_CHANGE_BEGIN
593/*
594#if defined(TD_NEED_SWFNS) || defined(__APPLE__) || defined(EMCC)// #7324
595*/
596#if defined(TD_NEED_SWFNS) || defined(__APPLE__) || defined(ANDROID) // #7324
597//FELIX_CHANGE_END
598#define TD_NEED_SWFNS_SCANF
599#endif
600//FELIX_CHANGE_BEGIN
601/*
602#if defined(TD_NEED_SWFNS) || defined(__APPLE__) || defined(__hpux) || defined(ANDROID) || defined(EMCC) || defined(ODA_WINDOWS_GCC) // #7324 & #8357 & #9786
603*/
604#if defined(TD_NEED_SWFNS) || defined(__APPLE__) || defined(__hpux) || (defined(ANDROID)) || defined(ODA_WINDOWS_GCC)
605//FELIX_CHANGE_END
606#define TD_NEED_SWFNS_PRINTF
607#endif
608
609#ifndef odSScanf
610 #if defined(TD_NEED_SWFNS_SCANF)
611 #ifdef ANDROID_WCHAR
612 #include "../../ThirdParty/wchar/wchar_.h"
613 #else
614 #include <wchar.h>
615 #endif
616 #include <stdio.h>
617 #include <stdarg.h>
618 #include <string>
619 FIRSTDLL_EXPORT int Od_vswscanfV(const wchar_t* buffer, const wchar_t* lpszFormat, va_list argList);
620 inline int ddswscanf(const wchar_t* buffer, const wchar_t* format, ...)
621 {
622 va_list argList;
623 va_start(argList, format);
624 int count = Od_vswscanfV(buffer, format, argList);
625 va_end(argList);
626 return count;
627 }
628 #define odSScanf ddswscanf
629 #else
630 #if defined(_WINRT)
631 #define odSScanf swscanf_s
632 #else
633 #define odSScanf swscanf
634 #endif
635 #endif
636#endif
637
638#ifndef odSprintf
639 #if defined(ODA_WINDOWS)
640 #define odSprintf _snwprintf
641 #elif defined(TD_NEED_SWFNS_PRINTF)
642 #include <stdio.h>
643 #include <stdarg.h>
644 #include <string>
645 FIRSTDLL_EXPORT extern std::wstring Od_vswprintfV(const wchar_t* lpszFormat, va_list argList);
646 inline int ddswprintf(wchar_t *buffer, size_t count, const wchar_t *format, ...)
647 {
648 va_list argList;
649 va_start(argList, format);
650 std::wstring ws = Od_vswprintfV(format, argList);
651 va_end(argList);
652 size_t toCopy = ws.length() < count - 1 ? ws.length() : count - 1;
653 Od_wcsncpy(buffer, ws.c_str(), toCopy);
654 buffer[toCopy] = '\0';
655 return 0;
656 }
657 #define odSprintf ddswprintf
658 #else
659 #define odSprintf swprintf
660 #endif
661#endif
662
663#ifndef odSprintfA
664 #if defined(ODA_WINDOWS)
665 #define odSprintfA _snprintf
666 #else
667 #define odSprintfA snprintf
668 #endif
669#endif
670
671#ifndef odStrToF
672#if defined (ODA_WINDOWS) && !defined(_WIN32_WCE)
673#define odStrToF _wtof
674#else
675#include <wchar.h>
676inline double Od_wtof(const wchar_t* str)
677{
678 wchar_t *endptr = 0;
679 return wcstod(str, &endptr);
680}
681#define odStrToF Od_wtof
682#endif
683#endif
684
685
686#ifndef OD_TYPENAME
687#define OD_TYPENAME
688#endif
689
690#ifndef OD_TYPENAME2
691#define OD_TYPENAME2
692#endif
693
694#ifndef OD_TYPENAME3
695#define OD_TYPENAME3
696#endif
697
698#ifndef OD_BSEARCH
699#define OD_BSEARCH ::bsearch
700#endif
701
702#ifndef TD_USING
703#define TD_USING(a) using a
704#endif
705
706#ifndef OD_LINKEDARRAY_SCOPE
707#define OD_LINKEDARRAY_SCOPE
708#endif
709
710#ifndef odStrStr
711 #ifdef TD_NEED_WCSSTR
712 // This is missing on some older HP compiler versions.
713 extern wchar_t *wcsstr(const wchar_t* wcs1, const wchar_t* wcs2);
714 #endif
715 #define odStrStr ::wcsstr
716#endif
717
719#define OD_MAKEWORD(a, b) ((OdUInt16)(((OdUInt8)(a)) | ((OdUInt16)((OdUInt8)(b))) << 8))
720#define OD_MAKELONG(a, b) ((OdInt32)(((OdUInt16)(a)) | ((OdUInt32)((OdUInt16)(b))) << 16))
721#define OD_LOWORD(l) ((OdUInt16)(l))
722#define OD_HIWORD(l) ((OdUInt16)(((OdUInt32)(l) >> 16) & 0xFFFF))
723#define OD_LOBYTE(w) ((OdUInt8)(w))
724#define OD_HIBYTE(w) ((OdUInt8)(((OdUInt16)(w) >> 8) & 0xFF))
725
726inline void odSwapBytes(OdUInt8& xX, OdUInt8& yY) { xX ^= yY; yY ^= xX; xX ^= yY; }
727inline void odSwapWords(OdUInt16& xX, OdUInt16& yY) { xX ^= yY; yY ^= xX; xX ^= yY; }
728
729#ifdef ODA_BIGENDIAN
730
731inline void odSwap2BytesNumber(OdUInt16& W)
732{
733 odSwapBytes(((OdUInt8*)&(W))[0], ((OdUInt8*)&(W))[1]);
734}
735
736inline void odSwap2BytesNumber(OdInt16& W)
737{
738 odSwapBytes(((OdUInt8*)&(W))[0], ((OdUInt8*)&(W))[1]);
739}
740
741inline void odSwap4BytesNumber(OdUInt32& DW)
742{
743 odSwapWords(((OdUInt16*)&(DW))[0], ((OdUInt16*)&(DW))[1]);
744 odSwapBytes(((OdUInt8*)&(DW))[0], ((OdUInt8*)&(DW))[1]);
745 odSwapBytes(((OdUInt8*)&(DW))[2], ((OdUInt8*)&(DW))[3]);
746}
747
748inline void odSwap4BytesNumber(OdInt32& DW)
749{
750 // NOTE: Using above unsigned version on AIX results in runtime errors.
751 // Macro version also causes errors on AIX.
752 OdInt8* p = (OdInt8*)&DW;
753 OdInt8 tmp;
754 tmp = p[0]; p[0] = p[3]; p[3] = tmp;
755 tmp = p[1]; p[1] = p[2]; p[2] = tmp;
756}
757
758#if OD_SIZEOF_LONG == 4
759inline void odSwap4BytesNumber(unsigned int& DW)
760{
761 odSwapWords(((OdUInt16*)&(DW))[0], ((OdUInt16*)&(DW))[1]);
762 odSwapBytes(((OdUInt8*)&(DW))[0], ((OdUInt8*)&(DW))[1]);
763 odSwapBytes(((OdUInt8*)&(DW))[2], ((OdUInt8*)&(DW))[3]);
764}
765#endif
766
767inline void odSwap8Bytes(void* pBytes)
768{
769 odSwapBytes(((OdUInt8*)(pBytes))[0], ((OdUInt8*)(pBytes))[7]);
770 odSwapBytes(((OdUInt8*)(pBytes))[1], ((OdUInt8*)(pBytes))[6]);
771 odSwapBytes(((OdUInt8*)(pBytes))[2], ((OdUInt8*)(pBytes))[5]);
772 odSwapBytes(((OdUInt8*)(pBytes))[3], ((OdUInt8*)(pBytes))[4]);
773}
774
775inline void odSwap4Bytes(void* pBytes)
776{
777 odSwapBytes(((OdUInt8*)(pBytes))[0], ((OdUInt8*)(pBytes))[3]);
778 odSwapBytes(((OdUInt8*)(pBytes))[1], ((OdUInt8*)(pBytes))[2]);
779}
780
781#define odSwapInt64(n)
782
783#else
784
785#define odSwap2BytesNumber(n)
786#define odSwap4BytesNumber(n)
787#define odSwap8Bytes(bytes)
788#define odSwap4Bytes(bytes)
789
790inline void odSwapInt64(void* pBytes)
791{
792 odSwapBytes(((OdUInt8*)(pBytes))[0], ((OdUInt8*)(pBytes))[7]);
793 odSwapBytes(((OdUInt8*)(pBytes))[1], ((OdUInt8*)(pBytes))[6]);
794 odSwapBytes(((OdUInt8*)(pBytes))[2], ((OdUInt8*)(pBytes))[5]);
795 odSwapBytes(((OdUInt8*)(pBytes))[3], ((OdUInt8*)(pBytes))[4]);
796}
797
798#endif // ODA_BIGENDIAN
799
804inline bool isValidNonZeroIEEEDouble(const OdUInt8 * buf)
805{
806#ifdef ODA_BIGENDIAN
807 int nExponent = (buf[0] & 0x7F) << 4 | (buf[1] & 0xF0) >> 4;
808#else
809 int nExponent = (buf[7] & 0x7F) << 4 | (buf[6] & 0xF0) >> 4;
810#endif
811 switch (nExponent)
812 {
813 case 0: // The value is zero or possibly denormalized
814 case 2047: // -INF, +INF or Nan
815 return false;
816 }
817 return true;
818}
819
820inline void fixDouble(double * pD)
821{
822 ODA_ASSUME(sizeof(double) == 8)
823 odSwap8Bytes(pD);
824 if (!isValidNonZeroIEEEDouble((OdUInt8 *)pD))
825 { // if unnormalized or NaN or infinity, set it to 0.0
826 //*pD = 0.;
827 ::memset((void*)pD, 0, sizeof(double)); // Support TD_STRICT_ALIGNMENT (#8352)
828 }
829}
830
831
832#define OD_INT8_FROM_BUFFPTR(pBuffPtr) *(pBuffPtr++)
833
834inline OdUInt64 OD_INT64_FROM_BUFFPTR(const OdUInt8 *pBuffPtr)
835{
836 OdUInt32 low(*pBuffPtr++);
837 low |= ((OdUInt32)*pBuffPtr++) << 8;
838 low |= ((OdUInt32)*pBuffPtr++) << 16;
839 low |= ((OdUInt32)*pBuffPtr++) << 24;
840
841 OdUInt32 high(*pBuffPtr++);
842 high |= ((OdUInt32)*pBuffPtr++) << 8;
843 high |= ((OdUInt32)*pBuffPtr++) << 16;
844 high |= ((OdUInt32)*pBuffPtr++) << 24;
845
846 OdUInt64 res(high);
847 res <<= 32;
848 res |= low;
849 return res;
850}
851
852#define OD_BYTES_FROM_BUFFPTR(pBuffPtr, ResBuff, nCount) (pBuffPtr+=nCount, ::memcpy(ResBuff, pBuffPtr-nCount, nCount))
853
854#define OD_INT8_TO_BUFFPTR(pBuffPtr, val) (++pBuffPtr, pBuffPtr[-1] = OdUInt8(val))
855#define OD_BYTES_TO_BUFFPTR(pBuffPtr, FromBuff, nCount) (pBuffPtr+=nCount, ::memcpy(pBuffPtr-nCount, FromBuff, nCount))
856
857
858
859#ifndef ODA_BIGENDIAN
860
861#ifdef TD_STRICT_ALIGNMENT
862
863#if defined(_WIN32_WCE) || defined FX_TOUCH_VERSION // FELIX_CHANGE
864#define VISIBILITY_ATTR FIRSTDLL_EXPORT
865FIRSTDLL_EXPORT void *bsearch(const void *key, const void *base, size_t numeles, size_t widthele, int(__cdecl *cfunc)(const void *elem1, const void *elem2));
866#else
867#define VISIBILITY_ATTR extern
868#endif
869
870VISIBILITY_ATTR double getStrictDouble(OdUInt8** ppBuff);
871VISIBILITY_ATTR void setStrictDouble(OdUInt8** ppBuff, double d);
872VISIBILITY_ATTR void setStrictInt16(OdUInt8** ppBuff, OdInt16 val);
873VISIBILITY_ATTR void setStrictInt32(OdUInt8** ppBuff, OdInt32 val);
874VISIBILITY_ATTR void setStrictInt64(OdUInt8** ppBuff, OdInt64 val);
875
876#define OD_INT16_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 2, (OdInt16)( *(pBuffPtr - 2) \
877 | (*(pBuffPtr - 1) << 8)))
878#define OD_INT32_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 4, (OdInt32)( *(pBuffPtr - 4) \
879 | (*(pBuffPtr - 3) << 8) \
880 | (*(pBuffPtr - 2) << 16) \
881 | (*(pBuffPtr - 1) << 24)))
882
883#define OD_INT64_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 8, (OdInt64)( *(pBuffPtr - 8) \
884 | (OdInt64(*(pBuffPtr - 7)) << 8) \
885 | (OdInt64(*(pBuffPtr - 6)) << 16) \
886 | (OdInt64(*(pBuffPtr - 5)) << 24) \
887 | (OdInt64(*(pBuffPtr - 4)) << 32) \
888 | (OdInt64(*(pBuffPtr - 3)) << 40) \
889 | (OdInt64(*(pBuffPtr - 2)) << 48) \
890 | (OdInt64(*(pBuffPtr - 1)) << 56)))
891
892#define OD_DOUBLE_FROM_BUFFPTR(pBuffPtr) getStrictDouble(&pBuffPtr)
893
894#define OD_INT16_TO_BUFFPTR(pBuffPtr, val) setStrictInt16(&pBuffPtr, val)
895#define OD_INT32_TO_BUFFPTR(pBuffPtr, val) setStrictInt32(&pBuffPtr, val)
896#define OD_INT64_TO_BUFFPTR(pBuffPtr, val) setStrictInt64(&pBuffPtr, val)
897
898#define OD_DOUBLE_TO_BUFFPTR(pBuffPtr, val) setStrictDouble(&pBuffPtr, val)
899
900
901#else
902
903inline double getValidDouble(OdUInt8** ppBuff)
904{
905 double d = isValidNonZeroIEEEDouble(*ppBuff) ? *((double*)(*ppBuff)) : 0.0;
906 *ppBuff+=8;
907 return d;
908}
909
910#define OD_INT16_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 2, *((OdInt16*)(pBuffPtr - 2)))
911#define OD_INT32_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 4, *((OdInt32*)(pBuffPtr - 4)))
912#define OD_INT64_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 8, *((OdInt64*)(pBuffPtr - 8)))
913
914#define OD_DOUBLE_FROM_BUFFPTR(pBuffPtr) getValidDouble(&pBuffPtr)
915//#define OD_POINT3D_FROM_BUFFPTR(pBuffPtr) (pBuffPtr+=24, *((OdGePoint3d*)(pBuffPtr-24)))
916
917#define OD_INT16_TO_BUFFPTR(pBuffPtr, val) (pBuffPtr+=2, *((OdInt16*)(pBuffPtr-2)) = OdInt16(val))
918#define OD_INT32_TO_BUFFPTR(pBuffPtr, val) (pBuffPtr+=4, *((OdInt32*)(pBuffPtr-4)) = OdInt32(val))
919#define OD_INT64_TO_BUFFPTR(pBuffPtr, val) (pBuffPtr+=8, *((OdInt64*)(pBuffPtr-8)) = OdInt64(val))
920
921#define OD_DOUBLE_TO_BUFFPTR(pBuffPtr, val) (pBuffPtr+=8, *((double*)(pBuffPtr-8)) = double(val))
922//#define OD_POINT3D_TO_BUFFPTR(pBuffPtr, val) (pBuffPtr+=24, *((OdGePoint3d*)(pBuffPtr-24)) = val)
923
924#endif // TD_STRICT_ALIGNMENT
925
926
927#else
928
929
930extern double getBeDouble(OdUInt8** ppBuff);
931//extern OdGePoint3d getBePnt3d(OdUInt8** ppBuff);
932extern void setStrictInt16(OdUInt8** ppBuff, OdInt16 val);
933extern void setStrictInt32(OdUInt8** ppBuff, OdInt32 val);
934extern void setStrictInt64(OdUInt8** ppBuff, OdInt64 val);
935extern void setBeDouble(OdUInt8** ppBuff, double d);
936//extern void setBePnt3(OdUInt8** ppBuff, const OdGePoint3d& p);
937
938
939// SGI doesn't like these versions.
940//#define OD_INT16_FROM_BUFFPTR(pBuffPtr) ((OdInt16)(*pBuffPtr++ | (*pBuffPtr++ << 8)))
941//#define OD_INT32_FROM_BUFFPTR(pBuffPtr) ((OdInt32)(*pBuffPtr++ | (*pBuffPtr++ << 8) | (*pBuffPtr++ << 16) | (*pBuffPtr++ << 24)))
942// So use these instead
943#define OD_INT16_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 2, (OdInt16)( *(pBuffPtr - 2) \
944 | (*(pBuffPtr - 1) << 8)))
945#define OD_INT32_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 4, (OdInt32)( *(pBuffPtr - 4) \
946 | (*(pBuffPtr - 3) << 8) \
947 | (*(pBuffPtr - 2) << 16) \
948 | (*(pBuffPtr - 1) << 24)))
949#define OD_INT64_FROM_BUFFPTR(pBuffPtr) (pBuffPtr += 8, (OdInt64)( *(pBuffPtr - 8) \
950 | (((OdInt64)(*(pBuffPtr - 7))) << 8) \
951 | (((OdInt64)(*(pBuffPtr - 6))) << 16) \
952 | (((OdInt64)(*(pBuffPtr - 5))) << 24) \
953 | (((OdInt64)(*(pBuffPtr - 4))) << 32) \
954 | (((OdInt64)(*(pBuffPtr - 3))) << 40) \
955 | (((OdInt64)(*(pBuffPtr - 2))) << 48) \
956 | (((OdInt64)(*(pBuffPtr - 1))) << 56)))
957
958#define OD_DOUBLE_FROM_BUFFPTR(pBuffPtr) getBeDouble(&pBuffPtr)
959//#define OD_POINT3D_FROM_BUFFPTR(pBuffPtr) getBePnt3d(&pBuffPtr)
960
961#define OD_INT16_TO_BUFFPTR(pBuffPtr, val) setStrictInt16(&pBuffPtr, val)
962#define OD_INT32_TO_BUFFPTR(pBuffPtr, val) setStrictInt32(&pBuffPtr, val)
963#define OD_INT64_TO_BUFFPTR(pBuffPtr, val) setStrictInt64(&pBuffPtr, val)
964
965#define OD_DOUBLE_TO_BUFFPTR(pBuffPtr, val) setBeDouble(&pBuffPtr, val)
966//#define OD_POINT3D_TO_BUFFPTR(pBuffPtr, val) setBePnt3(&pBuffPtr, val)
967
968#endif // ODA_BIGENDIAN
969
970
971#if defined(ODA_WINDOWS)
972#include "WINDOWS.H"
973#include "WINGDI.H"
974#endif
975
976#define ODCOLORREF OdUInt32
977#define ODRGB(r,g,b) ((ODCOLORREF)(((OdUInt8)(r)|((OdUInt16)((OdUInt8)(g))<<8))|(((OdUInt32)(OdUInt8)(b))<<16)))
978#define ODRGBA(r,g,b,a) (((ODCOLORREF)ODRGB(r,g,b))|(((OdUInt32)(OdUInt8)(a))<<24))
979
980#if defined(_WIN32) && !defined(WIN64) && !defined(_WINRT)
981
982#define ODGETRED(rgb) GetRValue(rgb)
983#define ODGETGREEN(rgb) GetGValue(rgb)
984#define ODGETBLUE(rgb) GetBValue(rgb)
985#define ODGETALPHA(rgba) ((BYTE)((rgba)>>24))
986#define ODRECT RECT
987
988#else //#ifdef _WIN32
989
990#define ODGETRED(rgb) ((OdUInt8)(rgb))
991#define ODGETGREEN(rgb) ((OdUInt8)(((OdUInt16)(rgb)) >> 8))
992#define ODGETBLUE(rgb) ((OdUInt8)((rgb)>>16))
993#define ODGETALPHA(rgba) ((OdUInt8)((rgba)>>24))
994
995typedef struct OdTagRECT{
996 OdInt32 left;
997 OdInt32 top;
998 OdInt32 right;
999 OdInt32 bottom;
1000} ODRECT;
1001
1002#if (!defined(WIN64) && !defined(ODA_WINDOWS_GCC)) || defined(_WINRT)
1003
1004#if !defined(_WINRT)
1005#ifndef RGBQUAD_DEFINED
1006#define RGBQUAD_DEFINED
1007#if defined(__sun)
1008#pragma pack(2)
1009#else
1010#pragma pack(push,2)
1011#endif
1015 typedef struct tagRGBQUAD
1016{
1017 OdUInt8 rgbBlue;
1018 OdUInt8 rgbGreen;
1019 OdUInt8 rgbRed;
1020 OdUInt8 rgbReserved;
1021} RGBQUAD, *LPRGBQUAD;
1022#if defined(__sun)
1023#pragma pack()
1024#else
1025#pragma pack(pop)
1026#endif
1027#endif
1028
1029#ifndef BITMAPINFOHEADER_DEFINED
1030#define BITMAPINFOHEADER_DEFINED
1034#if defined(__sun)
1035#pragma pack(2)
1036#else
1037#pragma pack(push,2)
1038#endif
1039
1040typedef struct tagBITMAPINFOHEADER {
1041 OdUInt32 biSize;
1042 OdInt32 biWidth;
1043 OdInt32 biHeight;
1044 OdUInt16 biPlanes;
1045 OdUInt16 biBitCount;
1046 OdUInt32 biCompression;
1047 OdUInt32 biSizeImage;
1048 OdInt32 biXPelsPerMeter;
1049 OdInt32 biYPelsPerMeter;
1050 OdUInt32 biClrUsed;
1051 OdUInt32 biClrImportant;
1052} BITMAPINFOHEADER, *PBITMAPINFOHEADER;
1053
1054//FELIX_CHANGE_BEGIN
1055typedef OdInt32 FXPT2DOT30;
1056
1057typedef struct tagCIEXYZ
1058{
1059 FXPT2DOT30 ciexyzX;
1060 FXPT2DOT30 ciexyzY;
1061 FXPT2DOT30 ciexyzZ;
1062} CIEXYZ;
1063
1064typedef struct tagICEXYZTRIPLE
1065{
1066 CIEXYZ ciexyzRed;
1067 CIEXYZ ciexyzGreen;
1068 CIEXYZ ciexyzBlue;
1069} CIEXYZTRIPLE;
1070
1071typedef struct tagBITMAPV4HEADER {
1072 OdUInt32 bV4Size;
1073 OdInt32 bV4Width;
1074 OdInt32 bV4Height;
1075 OdUInt16 bV4Planes;
1076 OdUInt16 bV4BitCount;
1077 OdUInt32 bV4V4Compression;
1078 OdUInt32 bV4SizeImage;
1079 OdInt32 bV4XPelsPerMeter;
1080 OdInt32 bV4YPelsPerMeter;
1081 OdUInt32 bV4ClrUsed;
1082 OdUInt32 bV4ClrImportant;
1083 OdUInt32 bV4RedMask;
1084 OdUInt32 bV4GreenMask;
1085 OdUInt32 bV4BlueMask;
1086 OdUInt32 bV4AlphaMask;
1087 OdUInt32 bV4CSType;
1088 CIEXYZTRIPLE bV4Endpoints;
1089 OdUInt32 bV4GammaRed;
1090 OdUInt32 bV4GammaGreen;
1091 OdUInt32 bV4GammaBlue;
1092} BITMAPV4HEADER, *PBITMAPV4HEADER;
1093//FELIX_CHANGE_BEGIN
1094
1095#if defined(__sun)
1096#pragma pack()
1097#else
1098#pragma pack(pop)
1099#endif
1100
1101#endif
1102
1103#ifndef BITMAPINFO_DEFINED
1104#define BITMAPINFO_DEFINED
1105typedef struct tagBITMAPINFO {
1106 BITMAPINFOHEADER bmiHeader;
1107 RGBQUAD bmiColors[1];
1108} BITMAPINFO, *PBITMAPINFO;
1109
1110#endif //BITMAPINFO_DEFINED
1111
1112#endif //_WINRT
1113#ifndef BITMAPFILEHEADER_DEFINED
1114#define BITMAPFILEHEADER_DEFINED
1115#if defined(__sun)
1116#pragma pack(2)
1117#else
1118#pragma pack(push,2)
1119#endif
1123 typedef struct tagBITMAPFILEHEADER
1124{
1125 OdUInt16 bfType;
1126 OdUInt32 bfSize;
1127 OdUInt16 bfReserved1;
1128 OdUInt16 bfReserved2;
1129 OdUInt32 bfOffBits;
1130} BITMAPFILEHEADER, *PBITMAPFILEHEADER;
1131#if defined(__sun)
1132#pragma pack()
1133#else
1134#pragma pack(pop)
1135#endif
1136#endif
1137
1138#endif //#ifndef WIN64
1139#endif //#ifdef _WIN32
1140
1141#ifndef ODA_WINDOWS
1142#ifndef CLSID
1143#define CLSID OdGUID
1144#endif
1145#endif
1146
1147#define ODTOCMCOLOR(colorref) OdCmEntityColor( ODGETRED(colorref), ODGETGREEN(colorref), ODGETBLUE(colorref) )
1148#define ODTOCOLORREF(cmColor) ODRGB( cmColor.red(), cmColor.green(), cmColor.blue() )
1149
1151// IR.111706. MacOS X dynamic library loading.
1152// Some code taken from Dlcompat open source library.
1153// www.opendarwin.org/projects/dlcompat/
1154
1155#if defined(_TOOLKIT_IN_DLL_) && defined(__GNUC__) && defined(__APPLE__) // GNU compiler MacOS X
1156
1157#include <mach-o/dyld.h>
1158
1159# ifndef RTLD_LAZY
1160# define RTLD_LAZY 0x1
1161# endif
1162# ifndef RTLD_NOW
1163# define RTLD_NOW 0x2
1164# endif
1165# ifndef RTLD_LOCAL
1166# define RTLD_LOCAL 0x4
1167# endif
1168# ifndef RTLD_GLOBAL
1169# define RTLD_GLOBAL 0x8
1170# endif
1171# ifndef RTLD_NOLOAD
1172# define RTLD_NOLOAD 0x10
1173# endif
1174# ifndef RTLD_NODELETE
1175# define RTLD_NODELETE 0x80
1176# endif
1177
1178class OdString;
1179void* LoadSharedLibrary(const OdString& path, int mode = 2);
1180void *GetFunction(void *handle, char *symbol);
1181bool FreeSharedLibrary(void *handle);
1182
1183#endif //defined(__GNUC__) && defined(__APPLE__) // GNU compiler MacOS X
1184
1185#if defined(_TOOLKIT_IN_DLL_) && defined(__GNUC__) && !defined(__APPLE__) // GNU compiler Linux
1186
1187#include <dlfcn.h>
1188
1189#endif // defined(_TOOLKIT_IN_DLL_) && defined(__GNUC__) && !defined(__APPLE__) // GNU compiler Linux
1190
1191#include <time.h>
1192
1193FIRSTDLL_EXPORT size_t od_strftime(char *s, size_t maxsize, const char *format, const struct tm *t);
1194
1195#ifdef _WIN32_WCE
1196#include <winbase.h>
1197FIRSTDLL_EXPORT time_t TimeFromSystemTime(const SYSTEMTIME * pTime);
1198#endif
1199
1201// memory manipulation functions
1202// secure (with check params and throw exceptions)
1203FIRSTDLL_EXPORT void *Od_memcpy_s(void *dest, size_t destSize, const void *src, size_t count);
1204FIRSTDLL_EXPORT void *Od_memcpy_s(void *dest, const void *src, size_t count);
1205FIRSTDLL_EXPORT void *Od_memmove_s(void *dest, size_t destSize, const void *src, size_t count);
1206FIRSTDLL_EXPORT void *Od_memmove_s(void *dest, const void *src, size_t count);
1207// always insecure wrappers
1208FIRSTDLL_EXPORT inline void *Od_memcpy(void *dest, const void *src, size_t count) { return memcpy(dest, src, count); };
1209FIRSTDLL_EXPORT inline void *Od_memmove(void *dest, const void *src, size_t count) { return memmove(dest, src, count); };
1210#endif // _OD_PLATFORM_H_
#define ODA_ASSUME(expr)
Definition DebugStuff.h:180
tm
#define odSwap4BytesNumber(n)
#define Od_abs
#define odSwap4Bytes(bytes)
ODRX_CONSTEXPR const T & odmin(const T &a, const T &b)
Definition OdPlatform.h:64
ODRX_CONSTEXPR const T & odmax(const T &a, const T &b)
Definition OdPlatform.h:38
#define odSwap8Bytes(bytes)
#define OD_INT64_FROM_BUFFPTR(pBuffPtr)
#define Od_wcsncpy
#define Od_round
#define odSwap2BytesNumber(n)
unsigned int OdUInt32
short OdInt16
signed char OdInt8
#define ODRX_CONSTEXPR
unsigned short OdUInt16
int OdInt32
unsigned char OdUInt8
wchar_t OdChar
#define FIRSTDLL_EXPORT
Definition RootExport.h:39
GLuint buffer
Definition gles2_ext.h:178
GLsizei GLsizei * count
Definition gles2_ext.h:276
GLuint GLsizei GLsizei GLint GLenum * type
Definition gles2_ext.h:274
GLint GLint GLint GLsizei GLsizei GLenum format
Definition gles2_ext.h:111