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

ansi/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_ANSI_H
00023 #define _DWFCORE_CORE_ANSI_H
00024 
00025 
00026 
00033 
00034 
00035 
00036 #include <time.h>
00037 #include <stdio.h>
00038 #include <wchar.h>
00039 #include <string.h>
00040 #include <stdlib.h>
00041 #include <unistd.h>
00042 #include <sys/types.h>
00043 #include <sys/stat.h>
00044 
00045 //
00046 //
00047 // Macros
00048 //
00049 //
00050 
00051     //
00052     // byte block memory allocator
00053     //
00054 #ifndef DWFCORE_ALLOC_MEMORY
00055 #define DWFCORE_ALLOC_MEMORY( primitive_type, bytes )  \
00056         (primitive_type*) new primitive_type[bytes]
00057 #endif
00058 
00059     //
00060     // byte block memory deallocator
00061     //
00062 #ifndef DWFCORE_FREE_MEMORY
00063 #define DWFCORE_FREE_MEMORY( pointer ) \
00064         delete [] pointer; pointer = NULL;
00065 #endif
00066 
00067     //
00068     // object memory allocator
00069     //
00070 #ifndef DWFCORE_ALLOC_OBJECT
00071 #define DWFCORE_ALLOC_OBJECT( object_type ) \
00072         new object_type
00073 #endif
00074 
00075     //
00076     // object memory deallocator
00077     //
00078 #ifndef DWFCORE_FREE_OBJECT
00079 #define DWFCORE_FREE_OBJECT( pointer )  \
00080         delete pointer; pointer = NULL;
00081 #endif
00082 
00083     //
00084     // zero fill memory
00085     //
00086 #ifndef DWFCORE_ZERO_MEMORY
00087 #define DWFCORE_ZERO_MEMORY( pointer, bytes )   \
00088         ::memset( (void*)pointer, 0, bytes )
00089 #endif
00090 
00091     //
00092     // copy memory
00093     //
00094 #ifndef DWFCORE_COPY_MEMORY
00095 #define DWFCORE_COPY_MEMORY( dest, src, bytes ) \
00096         ::memcpy( (void*)dest, (const void*)src, bytes )
00097 #endif
00098 
00099     //
00100     // compare memory regions
00101     //
00102 #ifndef DWFCORE_COMPARE_MEMORY
00103 #define DWFCORE_COMPARE_MEMORY( a, b, bytes )   \
00104         ::memcmp( (const void*)a, (const void*)b, bytes )
00105 #endif
00106 
00107     //
00108     // compare ascii strings
00109     //
00110 #ifndef DWFCORE_COMPARE_ASCII_STRINGS
00111 #define DWFCORE_COMPARE_ASCII_STRINGS( a, b )   \
00112         ::strcmp( a, b )
00113 #endif
00114 
00115     //
00116     // compare ascii strings
00117     //
00118 #ifndef DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE
00119 #define DWFCORE_COMPARE_ASCII_STRINGS_NO_CASE( a, b )   \
00120         ::strcasecmp( a, b )
00121 #endif
00122 
00123     //
00124     // compare wide strings
00125     //
00126 #ifndef DWFCORE_COMPARE_WIDE_STRINGS
00127 #define DWFCORE_COMPARE_WIDE_STRINGS( a, b )   \
00128         ::wcscmp( a, b )
00129 #endif
00130 
00131     //
00132     // compare wide strings
00133     //
00134 #ifndef DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE
00135 #define DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE( a, b )   \
00136         ::wcsicmp( a, b )
00137 #endif
00138 
00139     //
00140     // calculate length of ascii string
00141     //
00142 #ifndef DWFCORE_ASCII_STRING_LENGTH
00143 #define DWFCORE_ASCII_STRING_LENGTH( s )    \
00144         ::strlen( s )
00145 #endif
00146 
00147     //
00148     // calculate length of wide string in wchar_t
00149     //
00150 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS
00151 #define DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS( s )    \
00152         ::wcslen( s )
00153 #endif
00154 
00155     //
00156     // calculate length of wide string in bytes
00157     //
00158 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_BYTES
00159 #define DWFCORE_WIDE_STRING_LENGTH_IN_BYTES( s )    \
00160         (::wcslen( s ) * sizeof(wchar_t))
00161 #endif
00162 
00163     //
00164     // copy ascii strings
00165     //
00166 #ifndef DWFCORE_ASCII_STRING_COPY
00167 #define DWFCORE_ASCII_STRING_COPY( a, b )    \
00168         ::strcpy(a, b)
00169 #endif
00170 
00171     //
00172     // copy wide strings
00173     //
00174 #ifndef DWFCORE_WIDE_STRING_COPY
00175 #define DWFCORE_WIDE_STRING_COPY( a, b )    \
00176         ::wcscpy(a, b)
00177 #endif
00178 
00179     //
00180     // copy ascii strings with a given length
00181     //
00182 #ifndef DWFCORE_ASCII_STRING_COPY_LENGTH
00183 #define DWFCORE_ASCII_STRING_COPY_LENGTH( a, b, n )    \
00184         ::strncpy(a, b, n)
00185 #endif
00186 
00187     //
00188     // copy wide strings with a given length
00189     //
00190 #ifndef DWFCORE_WIDE_STRING_COPY_LENGTH
00191 #define DWFCORE_WIDE_STRING_COPY_LENGTH( a, b, n )    \
00192         ::wcsncpy(a, b, n)
00193 #endif
00194 
00195     //
00196     // concatenate ascii strings
00197     //
00198 #ifndef DWFCORE_ASCII_STRING_CONCATENATE
00199 #define DWFCORE_ASCII_STRING_CONCATENATE( a, b )    \
00200         ::strcat(a, b)
00201 #endif
00202 
00203     //
00204     // concatenate wide strings
00205     //
00206 #ifndef DWFCORE_WIDE_STRING_CONCATENATE
00207 #define DWFCORE_WIDE_STRING_CONCATENATE( a, b )    \
00208         ::wcscat(a, b)
00209 #endif
00210 
00211 
00212     //
00213     //
00214     //
00215 #define _DWFCORE_SWPRINTF   swprintf
00216 
00217 
00218     //
00219     // max
00220     //
00221 #ifndef max
00222 #define max( a, b )    a >? b
00223 #endif
00224 
00225     //
00226     // min
00227     //
00228 #ifndef min
00229 #define min( a, b )    a <? b
00230 #endif
00231 
00232 
00233 //
00234 //
00235 // Configuration
00236 //
00237 //
00238 
00239     //
00240     // use the ANSI string implementation
00241     //
00242 #define DWFCORE_USE_ANSI_STRING
00243 
00244     //
00245     // use ANSI specific file implementations
00246     //
00247 #define DWFCORE_USE_ANSI_FILE
00248 
00249 
00250 
00251 #endif
00252 
00253 

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