Main Page | Modules | Files | Functions | Code Elements | Data Structures | Deprecated

tc/tc_macros.h

Go to the documentation of this file.
00001 /*==============================================================================
00002                 Copyright (c) 2003-2005 UGS Corporation
00003                    Unpublished - All Rights Reserved
00004  ==============================================================================*/
00005 
00012 /*  */
00013 
00014 #ifndef TC_MACROS_H
00015 #define TC_MACROS_H
00016 
00017 #include <tc/tc_startup.h>
00018 #include <tc/emh.h>
00019 #include <itk/mem.h>
00020 #include <fclasses/tc_stdarg.h>
00021 #include <fclasses/tc_string.h>
00022 
00033 #define DATE_IS_NULL(d1)                            \
00034     ((d1.year == NULLDATE.year ) ?                  \
00035       ((d1.month == NULLDATE.month) ?               \
00036           ((d1.day == NULLDATE.day  ) ?             \
00037             ((d1.hour == NULLDATE.hour) ?           \
00038             ((d1.minute  == NULLDATE.minute) ?      \
00039               ((d1.second  == NULLDATE.second) ? 1  \
00040                                                : 0) \
00041                                              : 0)   \
00042                                         : 0)        \
00043                                       : 0)          \
00044                                     : 0)            \
00045                                 : 0)
00046 
00047 #define STRLEN(a)       tc_strlen(a)
00048 
00049 #define STRCPY(a, b)    tc_strcpy(a, b)
00050 
00051 #define STRNCPY(a,b,s)  tc_strncpy(a, b, s)
00052 
00053 #define ITKCALL( argument )                                             \
00054 {                                                                       \
00055     int retcode = argument;                                             \
00056     if ( retcode != ITK_ok ) {                                          \
00057         char* s;                                                        \
00058         printf( " "#argument "\n" );                                    \
00059         printf( "  returns [%d]\n", retcode );                          \
00060         EMH_ask_error_text (retcode, &s);                               \
00061         printf( "  Teamcenter ERROR: [%s]\n", s);           \
00062         printf( "  in file ["__FILE__"], line [%d]\n\n", __LINE__ );    \
00063         if (s != 0) MEM_free (s);                                       \
00064     }                                                                   \
00065 }
00066 
00069 #define ITKCHECK(x) \
00070 { \
00071     if ( retCode == ITK_ok ) \
00072     { \
00073         if ( ( retCode = (x)) != ITK_ok ) \
00074         { \
00075             char *errstring = NULL; \
00076             EMH_ask_error_text ( retCode, &errstring ); \
00077             lprintf ( "+++ Error %d: %s\n", retCode , errstring ); \
00078             if ( errstring != NULL ) SM_free ( errstring ); \
00079             lprintf ( "Function %s:  Line %d in %s\n ", #x, __LINE__, __FILE__); \
00080         } \
00081     } \
00082 }
00083 
00084 #endif