win32/Core.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2003-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #ifndef _DWFCORE_CORE_WIN32_H
00023 #define _DWFCORE_CORE_WIN32_H
00024 
00025 
00032 
00033 
00034 #ifdef  _DWFCORE_WIN32_SYSTEM
00035 
00036 #include <io.h>
00037 #include <sys/types.h>
00038 #include <sys/stat.h>
00039 
00040 
00041     //
00042     // Win32 build always uses custom ZLIB
00043     //
00044 #ifndef DWFTK_BUILD_ZLIB
00045 #define DWFTK_BUILD_ZLIB
00046 #endif
00047 
00048 
00049 //
00050 // Desired functionality
00051 //
00052 #ifdef  _WIN32_WINNT
00053 #if     (_WIN32_WINNT < 0x0400)
00054 #define _WIN32_WINNT    0x0400
00055 #endif
00056 #else
00057 #define _WIN32_WINNT    0x0400
00058 #endif
00059 
00060 //
00061 // NOTE:
00062 // Using the c-runtime functions will generally produce smaller object files
00063 // than if you include <windows.h> and use the Win32 APIs.
00064 //
00065 #include <windows.h>
00066 
00067 
00068     //
00069     // byte block memory allocator
00070     //
00071 #ifndef DWFCORE_ALLOC_MEMORY
00072 #define DWFCORE_ALLOC_MEMORY( primitive_type, bytes )  \
00073         (primitive_type*) new primitive_type[bytes]
00074 #endif
00075 
00076     //
00077     // byte block memory deallocator
00078     //
00079 #ifndef DWFCORE_FREE_MEMORY
00080 #define DWFCORE_FREE_MEMORY( pointer ) \
00081         delete [] pointer; pointer = NULL;
00082 #endif
00083 
00084     //
00085     // object memory allocator
00086     //
00087 #ifndef DWFCORE_ALLOC_OBJECT
00088 #define DWFCORE_ALLOC_OBJECT( object_type ) \
00089         new object_type
00090 #endif
00091 
00092     //
00093     // object memory deallocator
00094     //
00095 #ifndef DWFCORE_FREE_OBJECT
00096 #define DWFCORE_FREE_OBJECT( pointer )  \
00097         delete pointer; pointer = NULL;
00098 #endif
00099 
00100     //
00101     // zero fill memory
00102     //
00103 #ifndef DWFCORE_ZERO_MEMORY
00104 #define DWFCORE_ZERO_MEMORY( pointer, bytes )   \
00105         ::memset( (void*)pointer, 0, bytes )
00106 #endif
00107 
00108     //
00109     // copy memory
00110     //
00111 #ifndef DWFCORE_COPY_MEMORY
00112 #define DWFCORE_COPY_MEMORY( dest, src, bytes ) \
00113         ::memcpy( (void*)dest, (const void*)src, bytes )
00114 #endif
00115 
00116     //
00117     // compare memory regions
00118     //
00119 #ifndef DWFCORE_COMPARE_MEMORY
00120 #define DWFCORE_COMPARE_MEMORY( a, b, bytes )   \
00121         ::memcmp( (const void*)a, (const void*)b, bytes )
00122 #endif
00123 
00124     //
00125     // compare ascii strings
00126     //
00127 #ifndef DWFCORE_COMPARE_ASCII_STRINGS
00128 #define DWFCORE_COMPARE_ASCII_STRINGS( a, b )   \
00129         ::strcmp( a, b )
00130 #endif
00131 
00132     //
00133     // compare ascii strings
00134     //
00135 #if _MSC_VER < 1400 
00136     #ifndef DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE
00137     #define DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE( a, b )   \
00138             ::stricmp( a, b )
00139     #endif
00140 #else
00141     #ifndef DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE
00142     #define DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE( a, b )   \
00143             ::_stricmp( a, b )
00144     #endif
00145 #endif
00146 
00147     //
00148     // compare atmost n characters in ascii strings 
00149     //
00150 #ifndef DWFCORE_COMPARE_ASCII_STRINGS_NCHARS
00151 #define DWFCORE_COMPARE_ASCII_STRINGS_NCHARS( a, b, n )   \
00152         ::strncmp( a, b, n )
00153 #endif
00154 
00155     //
00156     // compare wide strings
00157     //
00158 #ifndef DWFCORE_COMPARE_WIDE_STRINGS
00159 #define DWFCORE_COMPARE_WIDE_STRINGS( a, b )   \
00160         ::wcscmp( a, b )
00161 #endif
00162 
00163     //
00164     // compare wide strings
00165     //
00166 #ifndef DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE
00167 #define DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE( a, b )   \
00168         ::wcsicmp( a, b )
00169 #endif
00170 
00171 
00172     //
00173     // compare atmost n characters in wide strings 
00174     //
00175 #ifndef DWFCORE_COMPARE_WIDE_STRINGS_NCHARS
00176 #define DWFCORE_COMPARE_WIDE_STRINGS_NCHARS( a, b, n )   \
00177         ::wcsncmp( a, b, n )
00178 #endif
00179 
00180     //
00181     // calculate length of ascii string
00182     //
00183 #ifndef DWFCORE_ASCII_STRING_LENGTH
00184 #define DWFCORE_ASCII_STRING_LENGTH( s )    \
00185         ::strlen( s )
00186 #endif
00187 
00188     //
00189     // calculate length of wide string in wchar_t
00190     //
00191 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS
00192 #define DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS( s )    \
00193         ::wcslen( s )
00194 #endif
00195 
00196     //
00197     // calculate length of wide string in bytes
00198     //
00199 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_BYTES
00200 #define DWFCORE_WIDE_STRING_LENGTH_IN_BYTES( s )    \
00201         (::wcslen( s ) * sizeof(wchar_t))
00202 #endif
00203 
00204     //
00205     // copy ascii strings
00206     //
00207 #ifndef DWFCORE_ASCII_STRING_COPY
00208 #define DWFCORE_ASCII_STRING_COPY( a, b )    \
00209         ::strcpy(a, b)
00210 #endif
00211 
00212     //
00213     // copy wide strings
00214     //
00215 #ifndef DWFCORE_WIDE_STRING_COPY
00216 #define DWFCORE_WIDE_STRING_COPY( a, b )    \
00217         ::wcscpy(a, b)
00218 #endif
00219 
00220     //
00221     // copy ascii strings with a given length
00222     //
00223 #ifndef DWFCORE_ASCII_STRING_COPY_LENGTH
00224 #define DWFCORE_ASCII_STRING_COPY_LENGTH( a, b, n )    \
00225         ::strncpy(a, b, n)
00226 #endif
00227 
00228     //
00229     // copy wide strings with a given length
00230     //
00231 #ifndef DWFCORE_WIDE_STRING_COPY_LENGTH
00232 #define DWFCORE_WIDE_STRING_COPY_LENGTH( a, b, n )    \
00233         ::wcsncpy(a, b, n)
00234 #endif
00235 
00236     //
00237     // concatenate ascii strings
00238     //
00239 #ifndef DWFCORE_ASCII_STRING_CONCATENATE
00240 #define DWFCORE_ASCII_STRING_CONCATENATE( a, b )    \
00241         ::strcat(a, b)
00242 #endif
00243 
00244     //
00245     // concatenate wide strings
00246     //
00247 #ifndef DWFCORE_WIDE_STRING_CONCATENATE
00248 #define DWFCORE_WIDE_STRING_CONCATENATE( a, b )    \
00249         ::wcscat(a, b)
00250 #endif
00251 
00252     //
00253     // tokenize ascii strings
00254     //
00255 #ifndef DWFCORE_ASCII_STRING_TOKENIZE
00256 #if _MSC_VER < 1400 
00257 #define DWFCORE_ASCII_STRING_TOKENIZE( str, delim, state )    \
00258         (state, ::strtok(str, delim))
00259 #else
00260 #define DWFCORE_ASCII_STRING_TOKENIZE( str, delim, state )    \
00261         ::strtok_s(str, delim, state)
00262 #endif    
00263 #endif
00264 
00265     //
00266     // tokenize wide strings
00267     //
00268 #ifndef DWFCORE_WIDE_STRING_TOKENIZE
00269 #if _MSC_VER < 1400 
00270 #define DWFCORE_WIDE_STRING_TOKENIZE( str, delim, state )    \
00271         (state, ::wcstok(str, delim))
00272 #else
00273 #define DWFCORE_WIDE_STRING_TOKENIZE( str, delim, state )    \
00274         ::wcstok_s(str, delim, state)
00275 #endif
00276 #endif
00277 
00278 
00279     //
00280     // Win32 swprintf doesn't work with count parameter
00281     //
00282 #define _DWFCORE_SWPRINTF   _snwprintf
00283 #define _DWFCORE_SPRINTF    _snprintf
00284 
00285 
00286 //
00287 //
00288 // Configuration
00289 //
00290 //
00291 
00292     //
00293     // Builds Win9x support checks into the library
00294     //
00295 #ifndef DWFCORE_WIN32_INCLUDE_WIN9X_CODE
00296 #define DWFCORE_WIN32_INCLUDE_WIN9X_CODE
00297 #endif
00298 
00299     //
00300     // use the ANSI string implementation
00301     //
00302 #ifndef DWFCORE_USE_ANSI_STRING
00303 #define DWFCORE_USE_ANSI_STRING
00304 #endif
00305 
00306     //
00307     // use Win32 specific file implementations
00308     //
00309 #define DWFCORE_USE_WIN32_FILE
00310 #undef  DWFCORE_USE_ANSI_FILE
00311 
00312 
00313 //
00314 // The MSVC 7.0 compiler is unaware of the 'LL' suffix
00315 // for 64-bit constant values so this unfortunate check must occur.
00316 //
00317 #if defined( _DWFCORE_WIN32_SYSTEM ) && ( _MSC_VER <= 1300 )
00318 #define _DWFCORE_LARGE_CONSTANT(x) x
00319 #else
00320 #define _DWFCORE_LARGE_CONSTANT(x) x##LL
00321 #endif
00322 
00323 
00324 
00325 
00326 //
00327 //
00328 // Platform specific utility prototypes
00329 //
00330 //
00331 
00332 namespace DWFCore
00333 {
00334 
00335 
00336 #ifdef  DWFCORE_WIN32_INCLUDE_WIN9X_CODE
00337 
00338 
00339 extern _DWFCORE_API bool IsWindows9x();
00340 #endif
00341 
00342 
00343 }
00344 
00345 
00346 #else
00347 #error  This is a Win32 header file and is incompatible with your current system configuration
00348 #endif
00349 
00350 #endif
00351 
00352 
00353 
00354     //
00355     // Never explicitly define this macro - it is ONLY for use by Doxygen.
00356     //
00357 #ifdef  _DWFCORE_DEFINE_FOR_DOXYGEN_ONLY
00358 
00359 namespace DWFCore
00360 {
00370     _DWFCORE_API bool IsWindows9x();
00371 }
00372 
00373 #endif

Generated on Tue Jan 6 22:39:28 2009 for Autodesk DWF Core Library by  doxygen 1.4.5