00001
00017 #include <string>
00018
00019 #include "ZincObjects.hpp"
00020 #ifndef BAZAR
00021 #define BAZAR
00022
00023 #define MAX_NUM_LENGTH 32
00024
00025
00026 #define Z_TCLCB "zincTclCb"
00027
00038
00039 #define Z_BOO_POOL(no, value) ( Tcl_SetBooleanObj (pool[no], value), pool[no] )
00040
00041 #define Z_INT_POOL(no, value) ( Tcl_SetIntObj (pool[no], value), pool[no] )
00042
00043 #define Z_DBL_POOL(no, value) ( Tcl_SetDoubleObj (pool[no], value), pool[no] )
00044
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
00077 #define Z_DEFINE_ZOPT(string) Tcl_Obj* ZOPT_##string = Tcl_NewStringObj ("-" #string, -1);
00078
00079 #define Z_DEFINE_ZFCT(string) Tcl_Obj* ZFCT_##string = Tcl_NewStringObj (#string, -1);
00080
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
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
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
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