utility.h

00001 /***************************************************************************
00002  *   clipsmm C++ wrapper for the CLIPS c library                           *
00003  *   Copyright (C) 2006 by Rick L. Vinyard, Jr.                            *
00004  *   rvinyard@cs.nmsu.edu                                                  *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of version 2 of the GNU General Public License as  *
00008  *   published by the Free Software Foundation.                            *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Lesser General Public      *
00016  *   License along with this library; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00019  ***************************************************************************/
00020 #ifndef CLIPSUTILITY_H
00021 #define CLIPSUTILITY_H
00022 
00023 #include <vector>
00024 #include <string>
00025 #include <stdexcept>
00026 
00027 extern "C" {
00028   struct dataObject;
00029 }
00030 
00031 namespace CLIPS {
00032 
00034   void init( );
00035 
00036   std::vector<std::string> data_object_to_strings(dataObject* clipsdo);
00037   std::vector<std::string> data_object_to_strings(dataObject& clipsdo);
00038 
00039   void get_argument(void* env, int argposition, double& value);
00040   void get_argument(void* env, int argposition, float& value);
00041   void get_argument(void* env, int argposition, short& value);
00042   void get_argument(void* env, int argposition, short unsigned& value);
00043   void get_argument(void* env, int argposition, int& value);
00044   void get_argument(void* env, int argposition, unsigned& value);
00045   void get_argument(void* env, int argposition, long& value);
00046   void get_argument(void* env, int argposition, std::string& value);
00047 
00048   template <typename T_return> inline char get_return_code() {
00049     throw std::logic_error("clipsmm: Adding function with invalid return type");
00050   }
00051   template <> inline char get_return_code<bool>()        { return 'b'; }
00052   template <> inline char get_return_code<char>()        { return 'c'; }
00053   template <> inline char get_return_code<double>()      { return 'd'; }
00054   template <> inline char get_return_code<float>()       { return 'f'; }
00055   template <> inline char get_return_code<int>()         { return 'i'; }
00056   template <> inline char get_return_code<long>()        { return 'l'; }
00057   template <> inline char get_return_code<std::string>() { return 's'; }
00058   template <> inline char get_return_code<void>()        { return 'v'; }
00059 
00060   template <typename T_return> inline char get_argument_code() {
00061     throw std::logic_error("clipsmm: Adding function with invalid argument type");
00062   }
00063   template <> inline char get_argument_code<double>()      { return 'd'; }
00064   template <> inline char get_argument_code<float>()       { return 'f'; }
00065   template <> inline char get_argument_code<int>()         { return 'i'; }
00066   template <> inline char get_argument_code<long>()        { return 'l'; }
00067   template <> inline char get_argument_code<std::string>() { return 's'; }
00068 
00069 
00070 }
00071 
00072 #endif

Generated on Sun Nov 12 11:55:35 2006 by  doxygen 1.5.1