clipsmm - C++ CLIPS Interface Library

clipsmm logo

utility.h

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

Generated on Wed Jul 29 12:04:08 2009 for clipsmm by doxygen 1.5.8