00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00033
00034 #ifndef GROOVX_TCL_CONVERSIONS_H_UTC20050628162420_DEFINED
00035 #define GROOVX_TCL_CONVERSIONS_H_UTC20050628162420_DEFINED
00036
00037 #include "rutz/traits.h"
00038 #include "tcl/obj.h"
00039
00040 typedef struct Tcl_Obj Tcl_Obj;
00041
00042 namespace rutz
00043 {
00044 class fstring;
00045 class value;
00046 template <class T> class fwd_iter;
00047 }
00048
00049 namespace nub
00050 {
00051 template <class T> class ref;
00052 template <class T> class soft_ref;
00053 }
00054
00055 namespace tcl
00056 {
00057 class obj;
00058
00060 template <class T>
00061 struct returnable
00062 {
00063
00064
00065
00066 typedef typename rutz::select_if<
00067 rutz::is_sub_super<T, rutz::value>::result,
00068 rutz::fstring, T>::result_t
00069 type;
00070 };
00071
00073 template <class T>
00074 struct returnable<const T>
00075 {
00076 typedef typename rutz::select_if<
00077 rutz::is_sub_super<T, rutz::value>::result,
00078 rutz::fstring, T>::result_t
00079 type;
00080 };
00081
00083 template <class T>
00084 struct returnable<const T&>
00085 {
00086 typedef typename rutz::select_if<
00087 rutz::is_sub_super<T, rutz::value>::result,
00088 rutz::fstring, T>::result_t
00089 type;
00090 };
00091
00092
00093
00094
00095
00097
00100 template <class T>
00101 inline typename returnable<T>::type convert_to( const tcl::obj& obj )
00102 {
00103 return aux_convert_to(obj.get(), static_cast<typename returnable<T>::type*>(0));
00104 }
00105
00107
00110 template <class T>
00111 inline typename returnable<T>::type convert_to( Tcl_Obj* obj )
00112 {
00113 return aux_convert_to(obj, static_cast<typename returnable<T>::type*>(0));
00114 }
00115
00116
00117
00118
00119
00120
00121 int aux_convert_to(Tcl_Obj* obj, int*);
00122 unsigned int aux_convert_to(Tcl_Obj* obj, unsigned int*);
00123 long aux_convert_to(Tcl_Obj* obj, long*);
00124 unsigned long aux_convert_to(Tcl_Obj* obj, unsigned long*);
00125 long long aux_convert_to(Tcl_Obj* obj, long long*);
00126 bool aux_convert_to(Tcl_Obj* obj, bool*);
00127 double aux_convert_to(Tcl_Obj* obj, double*);
00128 float aux_convert_to(Tcl_Obj* obj, float*);
00129 const char* aux_convert_to(Tcl_Obj* obj, const char**);
00130 rutz::fstring aux_convert_to(Tcl_Obj* obj, rutz::fstring*);
00131
00132 inline
00133 Tcl_Obj* aux_convert_to(Tcl_Obj* obj, Tcl_Obj**)
00134 { return obj; }
00135
00136 inline
00137 tcl::obj aux_convert_to(Tcl_Obj* obj, tcl::obj*)
00138 { return tcl::obj(obj); }
00139
00140
00141
00142
00143
00145
00148 template <class T>
00149 inline tcl::obj convert_from(const T& val)
00150 {
00151 return aux_convert_from(val);
00152 }
00153
00154 tcl::obj aux_convert_from(long long val);
00155 tcl::obj aux_convert_from(long val);
00156 tcl::obj aux_convert_from(unsigned long val);
00157 tcl::obj aux_convert_from(int val);
00158 tcl::obj aux_convert_from(unsigned int val);
00159 tcl::obj aux_convert_from(unsigned char val);
00160 tcl::obj aux_convert_from(bool val);
00161 tcl::obj aux_convert_from(double val);
00162 tcl::obj aux_convert_from(float val);
00163 tcl::obj aux_convert_from(const char* val);
00164 tcl::obj aux_convert_from(const rutz::fstring& val);
00165 tcl::obj aux_convert_from(const rutz::value& v);
00166
00167 inline
00168 tcl::obj aux_convert_from(Tcl_Obj* val)
00169 { return tcl::obj(val); }
00170
00171 inline
00172 tcl::obj aux_convert_from(tcl::obj val)
00173 { return val; }
00174 }
00175
00176 static const char __attribute__((used)) vcid_groovx_tcl_conversions_h_utc20050628162420[] = "$Id: conversions.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00177 #endif // !GROOVX_TCL_CONVERSIONS_H_UTC20050628162420_DEFINED