Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

ZincInternal.hpp

Go to the documentation of this file.
00001 
00017 #include <string>
00018 
00019 #include "ZincObjects.hpp"
00020 #ifndef BAZAR
00021 #define BAZAR
00022 
00023 #define MAX_NUM_LENGTH 32
00024 
00025 // The base name of the TCL function that serve for callbacks
00026 #define Z_TCLCB "zincTclCb"
00027 
00038 // make a boolean object
00039 #define Z_BOO_POOL(no, value) ( Tcl_SetBooleanObj (pool[no], value), pool[no] )
00040 // make an integer object
00041 #define Z_INT_POOL(no, value) ( Tcl_SetIntObj (pool[no], value), pool[no] )
00042 // make a double object
00043 #define Z_DBL_POOL(no, value) ( Tcl_SetDoubleObj (pool[no], value), pool[no] )
00044 // make a string object
00045 #define Z_STR_POOL(no, value, length) ( Tcl_SetStringObj (pool[no],       \
00046                                                           value, length), \
00047                                         pool[no] )
00048 
00057 #define Z_LST_POOL(no, value, size) ( Tcl_SetListObj (pool[no], size, value),\
00058                                       pool[no] )
00059 
00068 #define Z_CLEANLIST(no) Tcl_SetIntObj (pool[no], 0)
00069 
00070 
00076 //create an option object (value prefixed by '-')
00077 #define Z_DEFINE_ZOPT(string) Tcl_Obj* ZOPT_##string = Tcl_NewStringObj ("-" #string, -1);
00078 //create a function object
00079 #define Z_DEFINE_ZFCT(string) Tcl_Obj* ZFCT_##string = Tcl_NewStringObj (#string, -1);
00080 //create an item object
00081 #define Z_DEFINE_ZITM(string) Tcl_Obj* ZITM_##string = Tcl_NewStringObj (#string, -1);
00082 
00089 #define Z_PARENTGROUP(parentGroup)  \
00090   ( (parentGroup != NULL) ? parentGroup->object : DEFAULT_GROUP_OBJ );
00091 
00097 inline std::string itos (int integer)
00098 {
00099   char tmp[MAX_NUM_LENGTH];
00100   // use standard function to convert
00101   if (snprintf (tmp, MAX_NUM_LENGTH, "%d", integer) < 0)
00102   {
00103     throw ZincException ("Error converting integer", __FILE__, __LINE__ );
00104   }
00105   return std::string (tmp);
00106 }
00107 
00113 inline std::string ltos (long l)
00114 {
00115   char tmp[MAX_NUM_LENGTH];
00116   // use standard function to convert
00117   if (snprintf (tmp, MAX_NUM_LENGTH, "%ld", l) < 0)
00118   {
00119     throw ZincException ("Error converting long", __FILE__, __LINE__ );
00120   }
00121   return std::string (tmp);
00122 }
00123 
00129 inline std::string dtos (double d)
00130 {
00131   char tmp[MAX_NUM_LENGTH];
00132   // use standard function to convert
00133   if (snprintf (tmp, MAX_NUM_LENGTH, "%f", d) < 0)
00134   {
00135     throw ZincException ("Error converting double", __FILE__, __LINE__ );
00136   }
00137   return std::string (tmp);
00138 }
00139 
00156 #endif

Generated on Mon Apr 18 17:40:44 2005 for IntuiKit by doxygen 1.3.3