clipsmm - C++ CLIPS Interface Library

clipsmm logo
utility.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Rick L. Vinyard, Jr. *
3  * rvinyard@cs.nmsu.edu *
4  * *
5  * This file is part of the clipsmm library. *
6  * *
7  * The clipsmm library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License *
9  * version 3 as published by the Free Software Foundation. *
10  * *
11  * The clipsmm library is distributed in the hope that it will be *
12  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this software. If not see <http://www.gnu.org/licenses/>. *
18  ***************************************************************************/
19 #ifndef CLIPSUTILITY_H
20 #define CLIPSUTILITY_H
21 
22 #include <vector>
23 #include <string>
24 #include <stdexcept>
25 
26 #include <clipsmm/value.h>
27 
28 extern "C" {
29  struct dataObject;
30 }
31 
32 namespace CLIPS {
33 
35  void init( );
36 
37  std::vector<std::string> data_object_to_strings(dataObject* clipsdo);
38  std::vector<std::string> data_object_to_strings(dataObject& clipsdo);
39 
40  void get_argument(void* env, int argposition, double& value);
41  void get_argument(void* env, int argposition, float& value);
42  void get_argument(void* env, int argposition, short& value);
43  void get_argument(void* env, int argposition, short unsigned& value);
44  void get_argument(void* env, int argposition, int& value);
45  void get_argument(void* env, int argposition, unsigned& value);
46  void get_argument(void* env, int argposition, long& value);
47  void get_argument(void* env, int argposition, std::string& value);
48  void get_argument(void* env, int argposition, Values& values);
49 
50  template <typename T_return> inline char get_return_code() {
51  throw std::logic_error("clipsmm: Adding function with invalid return type");
52  }
53  template <> inline char get_return_code<bool>() { return 'b'; }
54  template <> inline char get_return_code<char>() { return 'c'; }
55  template <> inline char get_return_code<double>() { return 'd'; }
56  template <> inline char get_return_code<float>() { return 'f'; }
57  template <> inline char get_return_code<int>() { return 'i'; }
58  template <> inline char get_return_code<long>() { return 'l'; }
59  template <> inline char get_return_code<std::string>() { return 's'; }
60  template <> inline char get_return_code<void>() { return 'v'; }
61  template <> inline char get_return_code<Values>() { return 'm'; }
62 
63  template <typename T_return> inline char get_argument_code() {
64  throw std::logic_error("clipsmm: Adding function with invalid argument type");
65  }
66  template <> inline char get_argument_code<double>() { return 'd'; }
67  template <> inline char get_argument_code<float>() { return 'f'; }
68  template <> inline char get_argument_code<int>() { return 'i'; }
69  template <> inline char get_argument_code<long>() { return 'l'; }
70  template <> inline char get_argument_code<std::string>() { return 's'; }
71  template <> inline char get_argument_code<Values>() { return 'm'; }
72 
73 }
74 
75 #endif

Generated on Thu Sep 27 2012 17:57:05 for clipsmm by doxygen 1.8.1.2