00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <clipsmm/utility.h>
00020
00021 #include <glibmm/thread.h>
00022
00023 extern "C" {
00024 #include <clips/clips.h>
00025 };
00026
00027 namespace DACLIPS {
00028
00029 void init() {
00030 if(!Glib::thread_supported()) Glib::thread_init();
00031 }
00032
00033 std::vector<std::string> data_object_to_strings( dataObject* clipsdo ) {
00034 return data_object_to_strings( *clipsdo );
00035 }
00036
00037 std::vector<std::string> data_object_to_strings( dataObject& clipsdo ) {
00038 void* mfptr;
00039 long int end, i;
00040 std::string s;
00041 std::vector<std::string> strings;
00042
00043 switch ( GetType(clipsdo) ) {
00044 case SYMBOL:
00045 case INSTANCE_NAME:
00046 case STRING:
00047 strings.push_back( DOToString( clipsdo ) );
00048 break;
00049 case MULTIFIELD:
00050 end = GetDOEnd( clipsdo );
00051 mfptr = GetValue( clipsdo );
00052 for ( i = GetDOBegin( clipsdo ); i <= end; i++ ) {
00053 switch ( GetMFType( mfptr, i ) ) {
00054 case SYMBOL:
00055 case STRING:
00056 case INSTANCE_NAME:
00057 strings.push_back( ValueToString( GetMFValue( mfptr, i ) ) );
00058 break;
00059 default:
00060 break;
00061 }
00062 }
00063 default:
00064 break;
00065 }
00066
00067 return strings;
00068 }
00069
00070 void get_argument(void* env, int argposition, double& value) {
00071 value = EnvRtnDouble(env, argposition);
00072 }
00073
00074 void get_argument(void* env, int argposition, float& value) {
00075 value = static_cast<float>( EnvRtnDouble(env, argposition) );
00076 }
00077
00078 void get_argument(void* env, int argposition, short& value) {
00079 value = static_cast<short>( EnvRtnLong(env, argposition) );
00080 }
00081
00082 void get_argument(void* env, int argposition, short unsigned& value) {
00083 value = static_cast<short unsigned>( EnvRtnLong(env, argposition) );
00084 }
00085
00086 void get_argument(void* env, int argposition, int& value) {
00087 value = static_cast<int>( EnvRtnLong(env, argposition) );
00088 }
00089
00090 void get_argument(void* env, int argposition, unsigned& value) {
00091 value = static_cast<unsigned>( EnvRtnLong(env, argposition) );
00092 }
00093
00094 void get_argument(void* env, int argposition, long& value) {
00095 value = EnvRtnLong(env, argposition);
00096 }
00097
00098 void get_argument(void* env, int argposition, std::string& value) {
00099 value = EnvRtnLexeme(env, argposition);
00100 }
00101
00102 }