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 #include <clipsmm/value.h>
00027 
00028 extern "C" {
00029   struct dataObject;
00030 }
00031 
00032 namespace CLIPS {
00033 
00035   void init( );
00036 
00037   std::vector<std::string> data_object_to_strings(dataObject* clipsdo);
00038   std::vector<std::string> data_object_to_strings(dataObject& clipsdo);
00039 
00040   void get_argument(void* env, int argposition, double& value);
00041   void get_argument(void* env, int argposition, float& value);
00042   void get_argument(void* env, int argposition, short& value);
00043   void get_argument(void* env, int argposition, short unsigned& value);
00044   void get_argument(void* env, int argposition, int& value);
00045   void get_argument(void* env, int argposition, unsigned& value);
00046   void get_argument(void* env, int argposition, long& value);
00047   void get_argument(void* env, int argposition, std::string& value);
00048   void get_argument(void* env, int argposition, Values& values);
00049 
00050   template <typename T_return> inline char get_return_code() {
00051     throw std::logic_error("clipsmm: Adding function with invalid return type");
00052   }
00053   template <> inline char get_return_code<bool>()        { return 'b'; }
00054   template <> inline char get_return_code<char>()        { return 'c'; }
00055   template <> inline char get_return_code<double>()      { return 'd'; }
00056   template <> inline char get_return_code<float>()       { return 'f'; }
00057   template <> inline char get_return_code<int>()         { return 'i'; }
00058   template <> inline char get_return_code<long>()        { return 'l'; }
00059   template <> inline char get_return_code<std::string>() { return 's'; }
00060   template <> inline char get_return_code<void>()        { return 'v'; }
00061   template <> inline char get_return_code<Values>()      { return 'm'; }
00062 
00063   template <typename T_return> inline char get_argument_code() {
00064     throw std::logic_error("clipsmm: Adding function with invalid argument type");
00065   }
00066   template <> inline char get_argument_code<double>()      { return 'd'; }
00067   template <> inline char get_argument_code<float>()       { return 'f'; }
00068   template <> inline char get_argument_code<int>()         { return 'i'; }
00069   template <> inline char get_argument_code<long>()        { return 'l'; }
00070   template <> inline char get_argument_code<std::string>() { return 's'; }
00071   template <> inline char get_argument_code<Values>()      { return 'm'; }
00072 
00073 }
00074 
00075 #endif

Generated on Sun Feb 12 2012 17:07:50 for clipsmm by doxygen 1.7.4