Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

win32/Core.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2003-2005 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 #ifndef DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE
00136 #define DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE( a, b )   \
00137         ::stricmp( a, b )
00138 #endif
00139 
00140     //
00141     // compare wide strings
00142     //
00143 #ifndef DWFCORE_COMPARE_WIDE_STRINGS
00144 #define DWFCORE_COMPARE_WIDE_STRINGS( a, b )   \
00145         ::wcscmp( a, b )
00146 #endif
00147 
00148     //
00149     // compare wide strings
00150     //
00151 #ifndef DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE
00152 #define DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE( a, b )   \
00153         ::wcsicmp( a, b )
00154 #endif
00155 
00156 
00157     //
00158     // calculate length of ascii string
00159     //
00160 #ifndef DWFCORE_ASCII_STRING_LENGTH
00161 #define DWFCORE_ASCII_STRING_LENGTH( s )    \
00162         ::strlen( s )
00163 #endif
00164 
00165     //
00166     // calculate length of wide string in wchar_t
00167     //
00168 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS
00169 #define DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS( s )    \
00170         ::wcslen( s )
00171 #endif
00172 
00173     //
00174     // calculate length of wide string in bytes
00175     //
00176 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_BYTES
00177 #define DWFCORE_WIDE_STRING_LENGTH_IN_BYTES( s )    \
00178         (::wcslen( s ) * sizeof(wchar_t))
00179 #endif
00180 
00181     //
00182     // copy ascii strings
00183     //
00184 #ifndef DWFCORE_ASCII_STRING_COPY
00185 #define DWFCORE_ASCII_STRING_COPY( a, b )    \
00186         ::strcpy(a, b)
00187 #endif
00188 
00189     //
00190     // copy wide strings
00191     //
00192 #ifndef DWFCORE_WIDE_STRING_COPY
00193 #define DWFCORE_WIDE_STRING_COPY( a, b )    \
00194         ::wcscpy(a, b)
00195 #endif
00196 
00197     //
00198     // copy ascii strings with a given length
00199     //
00200 #ifndef DWFCORE_ASCII_STRING_COPY_LENGTH
00201 #define DWFCORE_ASCII_STRING_COPY_LENGTH( a, b, n )    \
00202         ::strncpy(a, b, n)
00203 #endif
00204 
00205     //
00206     // copy wide strings with a given length
00207     //
00208 #ifndef DWFCORE_WIDE_STRING_COPY_LENGTH
00209 #define DWFCORE_WIDE_STRING_COPY_LENGTH( a, b, n )    \
00210         ::wcsncpy(a, b, n)
00211 #endif
00212 
00213     //
00214     // concatenate ascii strings
00215     //
00216 #ifndef DWFCORE_ASCII_STRING_CONCATENATE
00217 #define DWFCORE_ASCII_STRING_CONCATENATE( a, b )    \
00218         ::strcat(a, b)
00219 #endif
00220 
00221     //
00222     // concatenate wide strings
00223     //
00224 #ifndef DWFCORE_WIDE_STRING_CONCATENATE
00225 #define DWFCORE_WIDE_STRING_CONCATENATE( a, b )    \
00226         ::wcscat(a, b)
00227 #endif
00228 
00229 
00230     //
00231     // Win32 swprintf doesn't work with count parameter
00232     //
00233 #define _DWFCORE_SWPRINTF   _snwprintf
00234 
00235 
00236 //
00237 //
00238 // Configuration
00239 //
00240 //
00241 
00242     //
00243     // Builds Win9x support checks into the library
00244     //
00245 #ifndef DWFCORE_WIN32_INCLUDE_WIN9X_CODE
00246 #define DWFCORE_WIN32_INCLUDE_WIN9X_CODE
00247 #endif
00248 
00249     //
00250     // use the ANSI string implementation
00251     //
00252 #ifndef DWFCORE_USE_ANSI_STRING
00253 #define DWFCORE_USE_ANSI_STRING
00254 #endif
00255 
00256     //
00257     // use Win32 specific file implementations
00258     //
00259 #define DWFCORE_USE_WIN32_FILE
00260 #undef  DWFCORE_USE_ANSI_FILE
00261 
00262 
00263 
00264 
00265 //
00266 //
00267 // Platform specific utility prototypes
00268 //
00269 //
00270 
00271 namespace DWFCore
00272 {
00273 
00274 
00275 #ifdef  DWFCORE_WIN32_INCLUDE_WIN9X_CODE
00276 
00277 
00278 extern _DWFCORE_API bool IsWindows9x();
00279 #endif
00280 
00281 
00282 }
00283 
00284 
00285 #else
00286 #error  This is a Win32 header file and is incompatible with your current system configuration
00287 #endif
00288 
00289 #endif
00290 
00291 
00292 
00293     //
00294     // Never explicitly define this macro - it is ONLY for use by Doxygen.
00295     //
00296 #ifdef  _DWFCORE_DEFINE_FOR_DOXYGEN_ONLY
00297 
00298 namespace DWFCore
00299 {
00309     _DWFCORE_API bool IsWindows9x();
00310 }
00311 
00312 #endif

Generated on Tue May 17 12:05:10 2005 for Autodesk DWF Core Library by  doxygen 1.4.1