ansi/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_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 atmost n characters in ascii strings 
00125     //
00126 #ifndef DWFCORE_COMPARE_ASCII_STRINGS_NCHARS
00127 #define DWFCORE_COMPARE_ASCII_STRINGS_NCHARS( a, b, n )   \
00128         ::strncmp( a, b, n )
00129 #endif
00130 
00131     //
00132     // compare wide strings
00133     //
00134 #ifndef DWFCORE_COMPARE_WIDE_STRINGS
00135 #define DWFCORE_COMPARE_WIDE_STRINGS( a, b )   \
00136         ::wcscmp( a, b )
00137 #endif
00138 
00139     //
00140     // compare wide strings
00141     //
00142 #ifndef DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE
00143 #define DWFCORE_COMPARE_WIDE_STRINGS_NO_CASE( a, b )   \
00144         ::wcsicmp( a, b )
00145 #endif
00146 
00147     //
00148     // compare atmost n characters in wide strings 
00149     //
00150 #ifndef DWFCORE_COMPARE_WIDE_STRINGS_NCHARS
00151 #define DWFCORE_COMPARE_WIDE_STRINGS_NCHARS( a, b, n )   \
00152         ::wcsncmp( a, b, n )
00153 #endif
00154 
00155     //
00156     // calculate length of ascii string
00157     //
00158 #ifndef DWFCORE_ASCII_STRING_LENGTH
00159 #define DWFCORE_ASCII_STRING_LENGTH( s )    \
00160         ::strlen( s )
00161 #endif
00162 
00163     //
00164     // calculate length of wide string in wchar_t
00165     //
00166 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS
00167 #define DWFCORE_WIDE_STRING_LENGTH_IN_WCHARS( s )    \
00168         ::wcslen( s )
00169 #endif
00170 
00171     //
00172     // calculate length of wide string in bytes
00173     //
00174 #ifndef DWFCORE_WIDE_STRING_LENGTH_IN_BYTES
00175 #define DWFCORE_WIDE_STRING_LENGTH_IN_BYTES( s )    \
00176         (::wcslen( s ) * sizeof(wchar_t))
00177 #endif
00178 
00179     //
00180     // copy ascii strings
00181     //
00182 #ifndef DWFCORE_ASCII_STRING_COPY
00183 #define DWFCORE_ASCII_STRING_COPY( a, b )    \
00184         ::strcpy(a, b)
00185 #endif
00186 
00187     //
00188     // copy wide strings
00189     //
00190 #ifndef DWFCORE_WIDE_STRING_COPY
00191 #define DWFCORE_WIDE_STRING_COPY( a, b )    \
00192         ::wcscpy(a, b)
00193 #endif
00194 
00195     //
00196     // copy ascii strings with a given length
00197     //
00198 #ifndef DWFCORE_ASCII_STRING_COPY_LENGTH
00199 #define DWFCORE_ASCII_STRING_COPY_LENGTH( a, b, n )    \
00200         ::strncpy(a, b, n)
00201 #endif
00202 
00203     //
00204     // copy wide strings with a given length
00205     //
00206 #ifndef DWFCORE_WIDE_STRING_COPY_LENGTH
00207 #define DWFCORE_WIDE_STRING_COPY_LENGTH( a, b, n )    \
00208         ::wcsncpy(a, b, n)
00209 #endif
00210 
00211     //
00212     // concatenate ascii strings
00213     //
00214 #ifndef DWFCORE_ASCII_STRING_CONCATENATE
00215 #define DWFCORE_ASCII_STRING_CONCATENATE( a, b )    \
00216         ::strcat(a, b)
00217 #endif
00218 
00219     //
00220     // concatenate wide strings
00221     //
00222 #ifndef DWFCORE_WIDE_STRING_CONCATENATE
00223 #define DWFCORE_WIDE_STRING_CONCATENATE( a, b )    \
00224         ::wcscat(a, b)
00225 #endif
00226 
00227     //
00228     // tokenize ascii strings
00229     //
00230 #ifndef DWFCORE_ASCII_STRING_TOKENIZE
00231 #define DWFCORE_ASCII_STRING_TOKENIZE( str, delim, state )    \
00232     ::strtok_r(str, delim, state)
00233 #endif
00234 
00235     //
00236     // tokenize wide strings
00237     //
00238 #ifndef DWFCORE_WIDE_STRING_TOKENIZE
00239 #define DWFCORE_WIDE_STRING_TOKENIZE( str, delim, state )    \
00240     ::wcstok(str, delim, state)
00241 #endif
00242 
00243     //
00244     //
00245     //
00246 #define _DWFCORE_SWPRINTF   swprintf
00247 #define _DWFCORE_SPRINTF    snprintf
00248 
00249 
00250     //
00251     // max
00252     //
00253 #ifndef max
00254 #define max( a, b )    ((a) < (b) ? (b) : (a))
00255 #endif
00256 
00257     //
00258     // min
00259     //
00260 #ifndef min
00261 #define min( a, b )    ((a) < (b) ? (a) : (b))
00262 #endif
00263 
00264 
00265 //
00266 //
00267 // Configuration
00268 //
00269 //
00270 
00271     //
00272     // use the ANSI string implementation
00273     //
00274 #define DWFCORE_USE_ANSI_STRING
00275 
00276     //
00277     // use ANSI specific file implementations
00278     //
00279 #define DWFCORE_USE_ANSI_FILE
00280 
00281 
00282 
00283 #endif
00284 
00285 

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