nux-0.9.48

NuxCore/NuxCore.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 #ifndef NUXCORE_H
00023 #define NUXCORE_H
00024 
00025 
00026 #include "System.h"
00027 
00028 #include <cassert>  // (assert.h)
00029 #include <cctype>   // (ctype.h)
00030 #include <cerrno>   // (errno.h)
00031 #include <cfloat>   // (float.h)
00032 #include <ciso646>  // (iso646.h)
00033 #include <climits>  // (limits.h)
00034 #include <clocale>  // (locale.h)
00035 #include <cmath>    // (math.h)
00036 //#include <csetjmp>  // (setjmp.h) conflict with libpng on GNU systems
00037 //#include <csignal>  // (signal.h)
00038 #include <cstdarg>  // (stdarg.h)
00039 #include <cstddef>  // (stddef.h)
00040 #include <cstdio>   // (stdio.h)
00041 #include <cstdlib>  // (stdlib.h)
00042 #include <cstring>  // (string.h)
00043 #include <ctime>    // (time.h)
00044 #include <cwchar>   // (wchar.h)
00045 #include <cwctype>  // (wctype.h)
00046 #include <exception>
00047 #include <stdexcept>
00048 
00049 #include <iostream>
00050 #include <stdexcept>
00051 #include <iostream>
00052 #include <fstream>
00053 #include <sstream>
00054 #include <stdexcept>
00055 #include <string>
00056 #include <iomanip>
00057 #include <map>
00058 #include <vector>
00059 #include <list>
00060 #include <stack>
00061 #include <queue>
00062 #include <algorithm>
00063 #include <new>
00064 #include <set>
00065 
00066 
00067 #include "Namespace.h"
00068 #include "SystemTypes.h"
00069 
00070 
00071 // WIN32_SECURE if define for the latest version of Visual Studio starting at VS 2005. We use it for security improvement.
00072 #if (defined NUX_VISUAL_STUDIO_2005) || (defined NUX_VISUAL_STUDIO_2008)
00073 #define WIN32_SECURE
00074 #endif
00075 
00076 #define NUX_STATIC_CAST(a, b)       static_cast<a>(b)
00077 #define NUX_REINTERPRET_CAST(a, b)  reinterpret_cast<a>(b)
00078 #define NUX_CONST_CAST(a, b)        const_cast<a>(b)
00079 #define NUX_DYNAMIC_CAST(a, b)      dynamic_cast<a>(b)
00080 
00081 #define NUX_INVALID_INDEX           -1
00082 #define NUX_INVALID_HANDLE          -1
00083 
00084 #define NUX_IN
00085 #define NUX_OUT
00086 
00087 #define NUX_0       0
00088 #define NUX_1       1
00089 #define NUX_2       2
00090 #define NUX_4       4
00091 #define NUX_8       8
00092 #define NUX_16      16
00093 #define NUX_32      32
00094 #define NUX_64      64
00095 #define NUX_128     128
00096 #define NUX_256     256
00097 #define NUX_512     512
00098 #define NUX_1024    1024
00099 #define NUX_2048    2048
00100 #define NUX_4096    4096
00101 #define NUX_8192    8192
00102 #define NUX_16384   16384
00103 #define NUX_65536   65536
00104 
00105 #define NUX_MAKEFOURCHARTAG(ch0, ch1, ch2, ch3)  \
00106     ((DWORD)(BYTE)(ch0) |               \
00107     ((DWORD)(BYTE)(ch1) << 8) |         \
00108     ((DWORD)(BYTE)(ch2) << 16) |        \
00109     ((DWORD)(BYTE)(ch3) << 24 ))
00110 
00111 
00112 #define INLNEW new
00113 #define INLDELETE delete
00114 #define INLDELETEARRAY delete []
00115 
00116 #define NUX_RUNTIME_ERROR(str, ...)             LogOutputErrorMessage(__FILE__, __LINE__, str, ##__VA_ARGS__);
00117 #define NUX_ERROR_IF_NULL(test, str, ...)       if(test == 0)   LogOutputErrorMessage(__FILE__, __LINE__, str, ##__VA_ARGS__);
00118 #define NUX_ERROR_IF_TRUE(test, str, ...)       if(test)        LogOutputErrorMessage(__FILE__, __LINE__, str, ##__VA_ARGS__);
00119 #define NUX_ERROR_IF_FALSE(test, str, ...)      if(!(test))     LogOutputErrorMessage(__FILE__, __LINE__, str, ##__VA_ARGS__);
00120 
00121 #define NUX_RETURN_IF_NULL(test)                if(test == 0)   return;
00122 #define NUX_RETURN_IF_TRUE(test)                if(test)        return;
00123 #define NUX_RETURN_IF_FALSE(test)               if(!(test))     return;
00124 
00125 #define NUX_RETURN_VALUE_IF_NULL(test, value)   if(test == 0)   return value;
00126 #define NUX_RETURN_VALUE_IF_TRUE(test, value)   if(test)        return value;
00127 #define NUX_RETURN_VALUE_IF_FALSE(test, value)  if(!(test))     return value;
00128 
00129 
00130 // Structure Alignment
00131 #if defined(NUX_MICROSOFT_COMPILER)
00132 #define NUX_DATA_ALIGN(declaration, alignment) __declspec(align(alignment)) declaration
00133 #elif defined (NUX_GNUCPP_COMPILER)
00134 #define NUX_DATA_ALIGN(declaration, alignment) declaration __attribute__ ((aligned (alignment)))
00135 #endif
00136 
00137 // Sizeof is a compile time function. So array must be totally defined if sizeof is used on it.
00138 // The number of elements in array must be a constant at compile time.
00139 // Example: int array[10] is valid.
00140 #define NUX_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
00141 
00142 // Compiler specific include.
00143 #if defined(NUX_OS_WINDOWS) && defined (NUX_MICROSOFT_COMPILER)
00144     #include "SystemWindows.h"
00145 #elif defined (NUX_OS_LINUX) && defined (NUX_GNUCPP_COMPILER)
00146     #include "SystemGNU.h"
00147 #elif defined (NUX_OS_MACOSX) && defined (NUX_GNUCPP_COMPILER)
00148     #error Unknown Compiler
00149 #else
00150     #error Unknown Compiler
00151 #endif
00152 
00153 
00154 namespace nux
00155 {
00156 
00157 // Variable arguments.
00158   t_u32 GetVariableArgs (TCHAR *Dest, t_u32 Size, t_u32 Count, const TCHAR*& Fmt, va_list ArgPtr);
00159   t_u32 GetVariableArgsAnsi (ANSICHAR *Dest, t_u32 Size, t_u32 Count, const ANSICHAR*& Fmt, va_list ArgPtr);
00160 
00161 
00162 #define GET_VARARGS(msg, size, len, fmt)            \
00163 {                                                   \
00164     va_list arg_list;                               \
00165     va_start(arg_list,fmt);                         \
00166     VSNTPRINTF_S( msg, size, len, fmt, arg_list );  \
00167     va_end( arg_list );                             \
00168 }
00169 #define GET_VARARGS_ANSI(msg, size, len, fmt)       \
00170 {                                                   \
00171     va_list arg_list;                               \
00172     va_start(arg_list,fmt);                         \
00173     VSNPRINTF_S( msg, size, len, fmt, arg_list );   \
00174     va_end( arg_list );                             \
00175 }
00176 #define GET_VARARGS_RESULT(msg, size, len, fmt, result)         \
00177 {                                                               \
00178     va_list arg_list;                                           \
00179     va_start(arg_list, fmt);                                    \
00180     result = GetVariableArgs(msg, size, len, fmt, arg_list);    \
00181 }
00182 
00184 //      Check macros for assertions.                                        //
00186   typedef enum
00187   {
00188     NUX_MSG_SEVERITY_CRITICAL   = 0,
00189     NUX_MSG_SEVERITY_ALERT      = 1,
00190     NUX_MSG_SEVERITY_WARNING    = 2,
00191     NUX_MSG_SEVERITY_INFO       = 3,
00192     NUX_MSG_SEVERITY_NONE       = 4,
00193 
00194   } MessageSeverity;
00195 
00196 #define nuxWarningMsg(str, ...)   { nux::LogOutputSeverityMessage(nux::NUX_MSG_SEVERITY_WARNING, str, ##__VA_ARGS__);}
00197 #define nuxAlertMsg(str, ...)     { nux::LogOutputSeverityMessage(nux::NUX_MSG_SEVERITY_ALERT, str, ##__VA_ARGS__);}
00198 #define nuxCriticalMsg(str, ...)  { nux::LogOutputSeverityMessage(nux::NUX_MSG_SEVERITY_CRITICAL, str, ##__VA_ARGS__);}
00199 
00200 #ifdef NUX_ENABLE_ASSERT_MACROS
00201 #define nuxAssert(expr)             { if(!(expr)) nuxFailAssert(TEXT(#expr)); }
00202   // Expression is always evaluated no matter if NUX_ENABLE_ASSERT_MACROS is enabled. nuxFailAssert is called if enabled.
00203 #define nuxVerifyExpr(expr)         { if(!(expr)) nuxFailAssert(TEXT(#expr)); }
00204 
00205 #define DEBUGTRACE(str, ...)    nuxDebugMsg(str, ##__VA_ARGS__)
00206 
00207 #ifdef NUX_VARIADIC_MACROS_SUPPORT
00208 #define nuxFailAssert(str, ...)         { if(nuxIsDebuggerPresent()){nux::LogOutputAssertMessage(__FILE__, __LINE__, str, ##__VA_ARGS__);} inlDebugBreak();}
00209 #define nuxError(str, ...)              { if(nuxIsDebuggerPresent()){nux::LogOutputErrorMessage(__FILE__, __LINE__, str, ##__VA_ARGS__);} inlDebugBreak();}
00210 #define nuxDebugMsg(str, ...)           { if(nuxIsDebuggerPresent()) nux::LogOutputDebugMessage(str, ##__VA_ARGS__);}
00211 
00212 #define nuxAssertMsg(expr, a, ...)      { if(!(expr)) nuxFailAssert( TEXT(#expr) TEXT(" : ") a, ##__VA_ARGS__); }
00213 #define nuxVerifyExprMsg(expr, a, ...)  { if(!(expr)) nuxFailAssert( TEXT(#expr) TEXT(" : ") a, ##__VA_ARGS__); }   // Expression is always evaluated. nuxFailAssert is called if enabled.
00214 #else
00215 #define nuxFailAssert(a,b,c,d,e,f,g,h,i,j,k,l)          { if(nuxIsDebuggerPresent()){nux::LogOutputAssertMessage(__FILE__,__LINE__,VARG(a),VARG(b),VARG(c),VARG(d),VARG(e),VARG(f),VARG(g),VARG(h),VARG(i),VARG(j),VARG(k),VARG(l));} inlDebugBreak();}
00216 #define nuxError(a,b,c,d,e,f,g,h,i,j,k,l)               { if(nuxIsDebuggerPresent()) {nux::LogOutputErrorMessage(__FILE__,__LINE__,VARG(a),VARG(b),VARG(c),VARG(d),VARG(e),VARG(f),VARG(g),VARG(h),VARG(i),VARG(j),VARG(k),VARG(l));} inlDebugBreak();}
00217 #define nuxAssertMsg(expr,a,b,c,d,e,f,g,h,i,j,k,l)      { if(!(expr)) { nuxFailAssert( TEXT(#expr) TEXT(" : ") a,b,c,d,e,f,g,h,i,j,k,l); } }
00218 #define nuxVerifyExprMsg(expr,a,b,c,d,e,f,g,h,i,j,k,l)  { if(!(expr)) { nuxFailAssert( TEXT(#expr) TEXT(" : ") a,b,c,d,e,f,g,h,i,j,k,l); } }    // Expression is always evaluated. nuxFailAssert is called if enabled.
00219 #define nuxDebugMsg(a,b,c,d,e,f,g,h,i,j,k,l)            { if(nuxIsDebuggerPresent() && LogOutputRedirector::Ready()) GLogDevice.LogFunction(a,b,c,d,e,f,g,h,i,j,k,l); }
00220 #endif
00221 
00222   // Break if codepaths should never be reached.
00223 #define nuxAssertNoEntry()           { nuxFailAssert( TEXT("This section of code should not be executed.") ); }
00224   // Break if codepaths should not be executed more than once.
00225 #define nuxAssertNoReEntry() \
00226     { \
00227         static bool s_inlRuntimeHasBeenHere##__LINE__ = false; \
00228         nuxAssertMsg( !s_inlRuntimeHasBeenHere##__LINE__, TEXT("This section of code has already been called.") ); \
00229         s_inlRuntimeHasBeenHere##__LINE__ = true; \
00230     }
00231 
00232   class NRecursionScopeCounter
00233   {
00234   public:
00235     NRecursionScopeCounter (WORD &InCounter) : Counter ( InCounter )
00236     {
00237       ++Counter;
00238     }
00239     ~NRecursionScopeCounter()
00240     {
00241       --Counter;
00242     }
00243   private:
00244     WORD &Counter;
00245   };
00246 
00247   // Break if codepaths should never be called recursively.
00248 #define nuxAssertNoRecursion()  \
00249         static WORD RecursionCounter##__LINE__ = 0; \
00250         nuxAssertMsg( RecursionCounter##__LINE__ == 0, TEXT("This section of code was entered recursively.") ); \
00251         const NRecursionScopeCounter ScopeMarker##__LINE__( RecursionCounter##__LINE__ )
00252 
00253   // Compile time assertion. Break if the assertion fails.
00254   // @param expr  Must be evaluated at compile time.
00255 #define nuxAssertAtCompileTime(expr)  typedef BYTE CompileTimeCheckType##__LINE__[(expr) ? 1 : -1]
00256 #else
00257 #ifdef NUX_MICROSOFT_COMPILER
00258 #define nuxAssert(expr)                     NUX_NOOP
00259 #define nuxVerifyExpr(expr)                 { if(!(expr)) {} }
00260 #define nuxDebugMsg(a, ...)                 NUX_NOOP
00261 #ifdef NUX_VARIADIC_MACROS_SUPPORT
00262 #define nuxAssertMsg(expr, a, ...)      NUX_NOOP
00263 #define nuxVerifyExprMsg(expr, a, ...)  { if(!(expr)) {} }
00264 #define nuxError(a, ...)                NUX_NOOP
00265 #else
00266 #define nuxAssertMsg(expr,a,b,c,d,e,f,g,h,i,j,k,l)      NUX_NOOP
00267 #define nuxVerifyExprMsg(expr,a,b,c,d,e,f,g,h,i,j,k,l)  { if(!(expr)) {} }
00268 #define nuxError(a,b,c,d,e,f,g,h,i,j,k,l)               NUX_NOOP
00269 #endif
00270 #define nuxAssertNoEntry()              NUX_NOOP
00271 #define nuxAssertNoReentry()            NUX_NOOP
00272 #define nuxAssertNoRecursion()          NUX_NOOP
00273 #define nuxAssertAtCompileTime(expr)    NUX_NOOP
00274 #else
00275 #define nuxDebugMsg(a, ...)
00276 #define nuxError(a, ...)                {}
00277 #define nuxAssert(expr)                 {}
00278 #define nuxVerifyExpr(expr)             { if(!(expr)) {} }
00279 #define nuxAssertMsg(expr,msg, ...)     {}
00280 #define nuxVerifyExprMsg(expr, a, ...)  { if(!(expr)) {} }
00281 #define nuxAssertNoEntry()              {}
00282 #define nuxAssertNoReentry()            {}
00283 #define nuxAssertNoRecursion()          {}
00284 #define nuxAssertAtCompileTime(expr)    {}
00285 #endif
00286 #endif
00287 
00289 // String conversion classes                                            //
00291 
00292 #ifndef _UNICODE
00293 #define CALL_OS_TCHAR_FUNCTION(funcW,funcA) funcA
00294 #define TCHAR_TO_ANSI(str) str
00295 #define ANSI_TO_TCHAR(str) (const TCHAR*)((const ANSICHAR*)str)
00296 
00297 #define UTF8ToTCHAR(str) str
00298 #define TCHARToUTF8(str) str
00299 #define UTF16ToTCHAR(str) (const char*)NUTF8(str)
00300 #define TCHARToUTF16(str) (const wchar_t*)NUTF16(str)
00301 #else
00302 #define CALL_OS_TCHAR_FUNCTION(funcW,funcA) funcW
00303 
00313 #define TCHAR_TO_ANSI(str)  (ANSICHAR*)typedef NCharacterConversion<ANSICHAR, TCHAR, TCharToAnsiConvertion>((const TCHAR*)str)
00314 #define ANSI_TO_TCHAR(str)  (TCHAR*)NCharacterConversion<TCHAR, ANSICHAR, AnsiToTCharConversion>((const ANSICHAR*)str)
00315 
00316 #define UTF8ToTCHAR(str) (const wchar_t*)NUTF16(str)
00317 #define TCHARToUTF8(str) (const char*)NUTF8(str)
00318 #define UTF16ToTCHAR(str) str
00319 #define TCHARToUTF16(str) str
00320 #endif
00321 
00322 #define inlUTF16ToUTF8(s) (const char*)nux::NUTF8(s)
00323 #define inlUTF8ToUTF16(s) (const wchar_t*)nux::NUTF16(s)
00324 
00325 #define ANSICHAR_TO_UNICHAR(str)  (UNICHAR*)  nux::NCharacterConversion <UNICHAR,   ANSICHAR, nux::AnsicharToUnicharConvertion>((const ANSICHAR*)str)
00326 #define UNICHAR_TO_ANSICHAR(str)  (ANSICHAR*) nux::NCharacterConversion <ANSICHAR,  UNICHAR,  nux::UnicharToAnsicharConvertion>((const UNICHAR*)str)
00327 #define ANSICHAR_TO_TCHAR(str)    (UNICHAR*)  nux::NCharacterConversion <TCHAR,     ANSICHAR, nux::AnsiToTCharConversion>((const ANSICHAR*)str)
00328 #define TCHAR_TO_ANSICHAR(str)    (ANSICHAR*) nux::NCharacterConversion <ANSICHAR,  TCHAR,    nux::TCharToAnsiConvertion>((const TCHAR*)str)
00329 #define TCHAR_TO_UNICHAR(str)     (UNICHAR*)  nux::NCharacterConversion <UNICHAR,   TCHAR,    nux::TCharToUnicharConvertion>((const TCHAR*)str)
00330 
00331 #define NUX_WIN32_LINE_TERMINATOR   TEXT("\r\n")
00332 #define NUX_UNIX_LINE_TERMINATOR    TEXT("\n")
00333 #define NUX_MACOSX_LINE_TERMINATOR  TEXT("\n")
00334 
00335 #if defined(NUX_OS_WINDOWS)
00336     #define NUX_LINE_TERMINATOR NUX_WIN32_LINE_TERMINATOR
00337 #elif defined(NUX_OS_LINUX) || defined(NUX_OS_MACOSX)
00338     #define NUX_LINE_TERMINATOR NUX_UNIX_LINE_TERMINATOR
00339 #endif
00340 
00341 
00342 #if defined(NUX_OS_WINDOWS)
00343     #define NUX_PATH_SEPARATOR_STRING   NUX_BACKSLASH_STRING
00344     #define NUX_PATH_SEPARATOR_CHAR     NUX_BACKSLASH_CHAR
00345 #elif defined(NUX_OS_LINUX) || defined(NUX_OS_MACOSX)
00346     #define NUX_PATH_SEPARATOR_STRING   NUX_SLASH_STRING
00347     #define NUX_PATH_SEPARATOR_CHAR     NUX_SLASH_CHAR
00348 #endif
00349 
00350 #define NUX_BACKSLASH_CHAR      TEXT('\\')
00351 #define NUX_BACKSLASH_STRING    TEXT("\\")
00352 #define NUX_SLASH_CHAR          TEXT('/')
00353 #define NUX_SLASH_STRING        TEXT("/")
00354 
00355 #define NUX_MAX_FILEPATH_SIZE   1024
00356 
00357 
00358 
00359 #if (defined _WIN32) && (defined WIN32_SECURE)
00360 #define WCSNCPY_S(strDest, numberOfElements, strSource, count)  wcsncpy_s (strDest, numberOfElements, strSource, count)
00361 #define STRNCPY_S(strDest, numberOfElements, strSource, count)  _tcsncpy_s(strDest, numberOfElements, strSource, count)
00362 #define STRCPY_S(strDest, numberOfElements, strSource)          _tcscpy_s(strDest, numberOfElements, strSource)
00363 #define STRCAT_S(strDest, numberOfElements, strSource)          _tcscat_s(strDest, numberOfElements, strSource)
00364 
00365 #define VSNPRINTF_S(strDest, numberOfElements, Count, format, VA_Arg_List)  vsnprintf_s(strDest, numberOfElements, Count, format, VA_Arg_List)
00366 #define VSNTPRINTF_S(strDest, numberOfElements, Count, format, VA_Arg_List) _vsntprintf_s(strDest, numberOfElements, Count, format, VA_Arg_List)
00367 #define SPRINTF_S(strDest, numberOfElements, format, ...)                   _stprintf_s(strDest, numberOfElements, format, ##__VA_ARGS__)
00368 #define SNPRINTF_S(strDest, numberOfElements, Count, format, ...)           _sntprintf_s(strDest, numberOfElements, Count, format, ##__VA_ARGS__)
00369 
00370 #define STRDATE_S(strDest, numberOfElements) _tstrdate_s(strDest, numberOfElements)
00371 #define STRTIME_S(strDest, numberOfElements)       _tstrtime_s(strDest, numberOfElements)
00372 
00373 #define FOPEN_S(file, filename, mode)           _tfopen_s(file, filename, mode)
00374 
00375 #define STRLEN_S(str, numberOfElements)         _tcsnlen(str, numberOfElements)
00376 
00377 #define SPLITPATH_S(path, Drive, DriveNumElements, Dir, DirNumElements, Filename, FileNumElements, Extension, ExtNumElements) _tsplitpath_s(path, Drive, DriveNumElements, Dir, DirNumElements, Filename, FileNumElements, Extension, ExtNumElements)
00378 #define MAKEPATH_S(path, numberOfElements, Drive, Dir, Filename, Extension) _tmakepath_s(path, numberOfElements, Drive, Dir, Filename, Extension)
00379 
00380 #define SSCANF_S(buffer, format, ...)           _stscanf_s(buffer, format, ##__VA_ARGS__)
00381 #define SNSCANF_S(input, length, format, ...)   _sntscanf_s(input, length, format, ##__VA_ARGS__)
00382 #else
00383 #define WCSNCPY_S(strDest, numberOfElements, strSource, count)  wcsncpy (strDest, strSource, count)
00384 #define STRNCPY_S(strDest, numberOfElements, strSource, count)  _tcsncpy(strDest, strSource, count)
00385 #define STRCPY_S(strDest, numberOfElements, strSource)          _tcscpy(strDest, strSource)
00386 #define STRCAT_S(strDest, numberOfElements, strSource)          _tcscat(strDest, strSource)
00387 
00388 #define VSNPRINTF_S(strDest, numberOfElements, Count, format, VA_Arg_List)              vsnprintf(strDest, Count, format, VA_Arg_List)
00389 #define VSNTPRINTF_S(strDest, numberOfElements, Count, format, VA_Arg_List)             _vsntprintf(strDest, Count, format, VA_Arg_List)
00390 #define SPRINTF_S(strDest, numberOfElements, format, ...)                               _stprintf(strDest, format, ##__VA_ARGS__)
00391 #define SNPRINTF_S(strDest, numberOfElements, Count, format, ...)                       _sntprintf(strDest, Count, format, ##__VA_ARGS__)
00392 
00393 #define STRDATE_S(strDest, numberOfElements)        _tstrdate(strDest)
00394 #define STRTIME_S(strDest, numberOfElements)        _tstrtime(strDest)
00395 
00396 #define FOPEN_S(file, filename, mode)               (file = _tfopen(filename, mode))
00397 
00398 #define STRLEN_S(str, numberOfElements)             _tcslen(str)
00399 
00400 #define SPLITPATH_S(path, Drive, DriveNumElements, Dir, DirNumElements, Filename, FileNumElements, Extension, ExtNumElements) _tsplitpath(path, Drive, Dir, Filename, Extension)
00401 #define MAKEPATH_S(path, numberOfElements, Drive, Dir, Filename, Extension) _makepath(path, Drive, Dir, Filename, Extension)
00402 
00403 #define SSCANF_S(buffer, format, ...)           _stscanf(buffer, format, ##__VA_ARGS__)
00404 #define SNSCANF_S(input, length, format, ...)   _sntscanf(input, length, format, ##__VA_ARGS__)
00405 #endif
00406 
00408   extern const t_bool GNoDialog;         // Set to true to disable the popping of dialog box. The message will go to the log.
00409 
00410 #ifdef NUX_VISUAL_STUDIO_2003
00411   //Visual Studio C++ 2003 doesn't support it, but there is a workaround:
00412 #pragma warning(disable: 4002)          // Warning: too many actual parameters for macro 'ident'
00413 #pragma warning(disable: 4003)          // Warning: not enough actual parameters for macro 'ident'
00414   template <typename T>
00415   inline const T                &VARG ( const T &t )
00416   {
00417     return t;
00418   }
00419   inline const TCHAR    *VARG( )
00420   {
00421     return TEXT ("");
00422   }
00423 #endif
00424 
00425 #ifdef _UNICODE
00426 #define tstring std::wstring
00427 #define tostream std::wostream
00428 #define tistream std::wistream
00429 #define tiostream std::wiostream
00430 #define tofstream std::wofstream
00431 #define tfstream std::wfstream
00432 #else
00433 #define tstring std::string
00434 #define tostream std::ostream
00435 #define tistream std::istream
00436 #define tiostream std::iostream
00437 #define tofstream std::ofstream
00438 #define tfstream std::fstream
00439 #endif
00440 
00441 // // UTF-16 is the primary encoding mechanism used by Microsoft Windows 2000, Windows 2000 Server, Windows XP and Windows 2003 Server.
00442 // // Unicode Byte Order Mark (BOM)
00443 // enum {UNICODE_UTF32_BE   = 0x0000FEFF };
00444 // enum {UNICODE_UTF32_LE   = 0xFFFE0000 };
00445 // enum {UNICODE_UTF16_BE   = 0xFEFF };
00446 // enum {UNICODE_UTF16_LE   = 0xFFFE };
00447 // enum {UNICODE_UTF8       = 0xEFBBBF };
00448 
00449   const BYTE NUX_UTF32_BE[]   = {0x04 /*size*/, 0x00, 0x00, 0xFE, 0xFF };
00450   const BYTE NUX_UTF32_LE[]   = {0x04 /*size*/, 0xFF, 0xFE, 0x00, 0x00 };
00451   const BYTE NUX_UTF16_BE[]   = {0x02 /*size*/, 0xFE, 0xFF };
00452   const BYTE NUX_UTF16_LE[]   = {0x02 /*size*/, 0xFF, 0xFE };
00453   const BYTE NUX_UTF8[]       = {0x03 /*size*/, 0xEF, 0xBB, 0xBF };
00454 
00455 // enum {UNICODE_BOM   = 0xfeff     };
00456 
00457 
00458   class LogOutputDevice;
00459   class NFileManager;
00460 
00461 
00462 #define GNullDevice         NUX_GLOBAL_OBJECT_INSTANCE(nux::NullOutput)
00463 #define GLogDevice          NUX_GLOBAL_OBJECT_INSTANCE(nux::LogOutputRedirector)
00464 
00465 #if (defined NUX_OS_WINDOWS)
00466     #define GFileManager    NUX_GLOBAL_OBJECT_INSTANCE(nux::NFileManagerWindows)
00467 #elif (defined NUX_OS_LINUX)
00468     #define GFileManager    NUX_GLOBAL_OBJECT_INSTANCE(nux::NFileManagerGNU)
00469 #endif
00470 
00471 // Define architecture specific asm statements for hardware breakpoint
00472 #if defined(NUX_GNUC_COMPILER)
00473     #if (defined __i386__) || (defined __x86_64__)
00474         #define ARCH_HARDWARE_BREAK std::abort ()
00475     #elif defined (__arm__) || (defined __ppc__)
00476         #define ARCH_HARDWARE_BREAK do {} while(0)
00477     #else
00478         #define ARCH_HARDWARE_BREAK do {} while(0)
00479     #endif
00480 #endif
00481 
00482 
00483 // Breaks into the debugger.  Forces a GPF in non-debug builds.
00484 #if (defined NUX_DEBUG) && (defined NUX_MICROSOFT_COMPILER)
00485     #define nuxIsDebuggerPresent()  IsDebuggerPresent()
00486     #define inlDebugBreak()         ( IsDebuggerPresent() ? (DebugBreak(),1) : 1 )
00487 #elif (defined _WIN32)
00488     #define nuxIsDebuggerPresent()  IsDebuggerPresent()
00489     #define inlDebugBreak()         std::abort ()
00490 #elif (defined NUX_DEBUG) && (defined NUX_GNUCPP_COMPILER)
00491     #define nuxIsDebuggerPresent()  1
00492     #define inlDebugBreak()         ARCH_HARDWARE_BREAK
00493 #else
00494     #define nuxIsDebuggerPresent()  0
00495     #define inlDebugBreak()
00496 #endif
00497 
00498 #if defined(NUX_MICROSOFT_COMPILER)
00499     #define NUX_HARDWARE_BREAK      {__debugbreak();}
00500     #define NUX_BREAK_ASM_INT3      {__debugbreak();}
00501 #elif defined(NUX_GNUC_COMPILER)
00502     #define NUX_HARDWARE_BREAK     ARCH_HARDWARE_BREAK
00503     #define NUX_BREAK_ASM_INT3     ARCH_HARDWARE_BREAK
00504 #else
00505     #define NUX_HARDWARE_BREAK
00506     #define NUX_BREAK_ASM_INT3
00507 #endif
00508 
00509 // Simple version of the PURE_VIRTUAL. Use it before output macros nuxError is define.
00510 #if NUX_CHECK_PUREVIRTUALS
00511 #define NUX_PURE_VIRTUAL = 0;
00512 #else
00513 #define NUX_PURE_VIRTUAL { inlDebugBreak(); }
00514 #endif
00515 
00517 //      Variadic function prototypes.
00519 
00520 #define VARARG_EXTRA(A) A,
00521 #define VARARG_NONE
00522 #define VARARG_PURE =0
00523 
00524 #if _MSC_VER
00525 
00526   static inline DWORD         VAType (DWORD dw)
00527   {
00528     return dw;
00529   }
00530   static inline t_byte        VAType (t_byte b)
00531   {
00532     return b;
00533   }
00534   static inline t_u32        VAType (t_u32 ui)
00535   {
00536     return ui;
00537   }
00538   static inline t_int         VAType (t_s32 i)
00539   {
00540     return i;
00541   }
00542   static inline t_u64         VAType (t_u64 qw)
00543   {
00544     return qw;  // possible conflict with t_size when compiling in 64 bits
00545   }
00546   static inline t_s64         VAType (t_s64 sqw)
00547   {
00548     return sqw;
00549   }
00550   static inline double        VAType (double d)
00551   {
00552     return d;
00553   }
00554   static inline TCHAR         VAType (TCHAR c)
00555   {
00556     return c;
00557   }
00558   static inline ANSICHAR     *VAType (ANSICHAR *s)
00559   {
00560     return s;
00561   }
00562   static inline UNICHAR      *VAType (UNICHAR *s)
00563   {
00564     return s;
00565   }
00566   template<class T> T        *VAType (T *p)
00567   {
00568     return p;
00569   }
00570   template<class T> const T  *VAType (const T *p)
00571   {
00572     return p;
00573   }
00574 
00575   //  Declaration of prototypes with lots of arguments
00576   //  If(the function return nothing)
00577   //  {
00578   //      Return = {}
00579   //      StaticFuncRet = void
00580   //  }
00581   //  else
00582   //  {
00583   //      Return = return
00584   //      StaticFuncRet = type0
00585   //      FuncRet = type1
00586   //  }
00587   //
00588   //  If this is a pure virtual function then PURE is equal to: ==0
00589   //  ExtraParamDecl is declaration for additional parameters: VARARG_EXTRA(TCHAR* Dest) VARARG_EXTRA(INT Size) VARARG_EXTRA(INT Count)
00590   //  ExtraParam is the parameters presented in ExtraParamDecl: VARARG_EXTRA(Dest) VARARG_EXTRA(Size) VARARG_EXTRA(Count)
00591 #define VARARG_DECL( FuncRet, StaticFuncRet, Return, FuncName, Pure, FmtType, ExtraParamDecl, ExtraParam )      \
00592     FuncRet FuncName##__VA(ExtraParamDecl FmtType Fmt, ... ) Pure;  \
00593     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt) {Return FuncName##__VA(ExtraParam (Fmt));} \
00594     template<class T1> \
00595     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1) {T1 v1=VAType(V1);Return FuncName##__VA(ExtraParam (Fmt),(v1));} \
00596     template<class T1,class T2> \
00597     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2) {T1 v1=VAType(V1);T2 v2=VAType(V2);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2));} \
00598     template<class T1,class T2,class T3> \
00599     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3));} \
00600     template<class T1,class T2,class T3,class T4> \
00601     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4));} \
00602     template<class T1,class T2,class T3,class T4,class T5> \
00603     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5));} \
00604     template<class T1,class T2,class T3,class T4,class T5,class T6> \
00605     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6));} \
00606     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7> \
00607     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7));} \
00608     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> \
00609     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8));} \
00610     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> \
00611     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9));} \
00612     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> \
00613     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10));} \
00614     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11> \
00615     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11));} \
00616     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12> \
00617     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12));} \
00618     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13> \
00619     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13));} \
00620     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14> \
00621     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13,T14 V14) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);T14 v14=VAType(V14);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13),(v14));} \
00622     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14,class T15> \
00623     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13,T14 V14,T15 V15) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);T14 v14=VAType(V14);T15 v15=VAType(V15);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13),(v14),(v15));} \
00624     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14,class T15,class T16> \
00625     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13,T14 V14,T15 V15,T16 V16) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);T14 v14=VAType(V14);T15 v15=VAType(V15);T16 v16=VAType(V16);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13),(v14),(v15),(v16));} \
00626     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14,class T15,class T16,class T17> \
00627     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13,T14 V14,T15 V15,T16 V16,T17 V17) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);T14 v14=VAType(V14);T15 v15=VAType(V15);T16 v16=VAType(V16);T17 v17=VAType(V17);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13),(v14),(v15),(v16),(v17));} \
00628     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14,class T15,class T16,class T17,class T18> \
00629     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13,T14 V14,T15 V15,T16 V16,T17 V17,T18 V18) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);T14 v14=VAType(V14);T15 v15=VAType(V15);T16 v16=VAType(V16);T17 v17=VAType(V17);T18 v18=VAType(V18);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13),(v14),(v15),(v16),(v17),(v18));} \
00630     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14,class T15,class T16,class T17,class T18,class T19> \
00631     StaticFuncRet FuncName(ExtraParamDecl FmtType Fmt,T1 V1,T2 V2,T3 V3,T4 V4,T5 V5,T6 V6,T7 V7,T8 V8,T9 V9,T10 V10,T11 V11,T12 V12,T13 V13,T14 V14,T15 V15,T16 V16,T17 V17,T18 V18,T19 V19) {T1 v1=VAType(V1);T2 v2=VAType(V2);T3 v3=VAType(V3);T4 v4=VAType(V4);T5 v5=VAType(V5);T6 v6=VAType(V6);T7 v7=VAType(V7);T8 v8=VAType(V8);T9 v9=VAType(V9);T10 v10=VAType(V10);T11 v11=VAType(V11);T12 v12=VAType(V12);T13 v13=VAType(V13);T14 v14=VAType(V14);T15 v15=VAType(V15);T16 v16=VAType(V16);T17 v17=VAType(V17);T18 v18=VAType(V18);T19 v19=VAType(V19);Return FuncName##__VA(ExtraParam (Fmt),(v1),(v2),(v3),(v4),(v5),(v6),(v7),(v8),(v9),(v10),(v11),(v12),(v13),(v14),(v15),(v16),(v17),(v18),(v19));}
00632 
00633 #define VARARG_BODY( FuncRet, FuncName, FmtType, ExtraParamDecl )               \
00634     FuncRet FuncName##__VA( ExtraParamDecl  FmtType Fmt, ... )
00635 
00636 #else  // !_MSC_VER
00637 
00638 #define VARARG_DECL( FuncRet, StaticFuncRet, Return, FuncName, Pure, FmtType, ExtraParamDecl, ExtraParam )      \
00639     FuncRet FuncName( ExtraParamDecl FmtType Fmt, ... ) Pure
00640 #define VARARG_BODY( FuncRet, FuncName, FmtType, ExtraParamDecl )               \
00641     FuncRet FuncName( ExtraParamDecl FmtType Fmt, ... )
00642 
00643 #endif // _MSC_VER
00644 
00645 
00647   void PrintOutputDebugString (const TCHAR *Format, ...);
00648 
00650   void LogOutputAssertMessage (const ANSICHAR *File, int Line, const TCHAR *Format = TEXT (""), ...);
00651 
00653   void LogOutputErrorMessage (const ANSICHAR *File, int Line, const TCHAR *Format = TEXT (""), ...);
00654 
00656   void LogOutputDebugMessage (const TCHAR *Format, ...);
00657 
00659   void LogOutputSeverityMessage (int Severity, const TCHAR *Format/*=TEXT("")*/, ...);
00660 
00661 // Returns true is the output redirector is ready
00662   bool OutputRedirectorReady();
00663 
00664 
00665 
00666 #if CHECK_PUREVIRTUALS
00667 #define PURE_VIRTUAL(func,extra) =0;
00668 #else
00669 #define PURE_VIRTUAL(func,extra) { nuxError(TEXT("Pure virtual not implemented (%s)"), TEXT(#func)); extra }
00670 #endif
00671 
00672   enum EFileWrite
00673   {
00674     FILEWRITE_NOFAIL            = 0x01,
00675     FILEWRITE_NOREPLACEEXISTING = 0x02,
00676     FILEWRITE_EVENIFREADONLY    = 0x04,
00677     FILEWRITE_UNBUFFERED        = 0x08,
00678     FILEWRITE_APPEND            = 0x10,
00679     FILEWRITE_ALLOWREAD         = 0x20,
00680   };
00681 
00682   enum ECopyResult
00683   {
00684     COPY_OK                     = 0x00,
00685     COPY_MISCFAIL               = 0x01,
00686     COPY_READFAIL               = 0x02,
00687     COPY_WRITEFAIL              = 0x03,
00688     COPY_CANCELED               = 0x06,
00689   };
00690 
00691   enum NUX_STATUS
00692   {
00693     NUX_OK,
00694     NUX_ERROR,
00695     NUX_FILENOTFOUND,
00696     NUX_COPYFILE_ERROR,
00697     NUX_DELETEFILE_ERROR,
00698   };
00699 
00700 }
00701 
00702 
00703 #include "Macros.h"
00704 #include "Memory.h"
00705 
00706 #include "Character/NUni.h"
00707 
00708 #if defined(NUX_OS_WINDOWS)
00709     #include "Character/NUnicode.h"
00710 #elif defined(NUX_OS_LINUX)
00711     #include "Character/NUnicode.h"
00712 #endif
00713 
00714 #include "Template.h"
00715 #include "NumberConversion.h"
00716 
00717 #include "TextString.h"
00718 
00719 #if defined(NUX_OS_WINDOWS)
00720     #include "ThreadWin.h"
00721 #elif defined(NUX_OS_LINUX)
00722     #include "ThreadGNU.h"
00723 #endif
00724 
00725 /*#include "Memory/NMemoryAllocatorInterface.h"
00726 #include "Memory/NDefaultMemoryAllocator.h"
00727 #include "Memory/NMemoryHook.h"
00728 #include "Memory/NMemoryAllocator.h"
00729 */
00730 
00731 #include "NUniqueIndex.h"
00732 //#include "SmartPtr/ObjectPtr.h"
00733 
00734 //#include "GlobalInitializer.h"
00735 
00736 #ifdef NUX_OS_WINDOWS
00737 #include "Win32Dialogs/NWin32MessageBox.h"
00738 #endif
00739 
00740 #include "Character/NTChar.h"
00741 
00742 #include "TimeFunctions.h"
00743 #include "CPU.h"
00744 #include "Platform.h"
00745 #include "FileManager/NSerializer.h"
00746 #include "Process.h"
00747 
00748 #include "OutputDevice.h"
00749 #include "FileManager/NFileManagerGeneric.h"
00750 
00751 #ifdef NUX_OS_WINDOWS
00752     #include "FileManager/NFileManagerStandardAnsi.h"
00753     #include "FileManager/NFileManagerWindows.h"
00754 #elif defined NUX_OS_LINUX
00755     #include "FileManager/NFileManagerGNU.h"
00756 #endif
00757 
00758 #include "FileIO.h"
00759 #include "ObjectType.h"
00760 #include "FileName.h"
00761 #include "Color.h"
00762 #include "Colors.h"
00763 #include "Object.h"
00764 
00765 #ifdef NUX_OS_WINDOWS
00766   #include "Win32Dialogs/NWin32CustomDialog.h"
00767 #endif
00768 
00769 #ifdef NUX_OS_WINDOWS
00770   #include "Win32Dialogs/NWin32Clipboard.h"
00771 #endif
00772 //#include "NSocket.h"
00773 
00774 #include "GlobalInitializer.h"
00775 
00776 #endif // NUXCORE_H