Schnek
types.hpp
1 /*
2  * types.hpp
3  *
4  * Created on: 9 Dec 2011
5  * Author: Holger Schmitz
6  * Email: holger@notjustphysics.com
7  *
8  * Copyright 2012 Holger Schmitz
9  *
10  * This file is part of Schnek.
11  *
12  * Schnek is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * Schnek is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with Schnek. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef SCHNEK_TYPES_HPP_
28 #define SCHNEK_TYPES_HPP_
29 
30 #include "../exception.hpp"
31 
32 #include <boost/variant.hpp>
33 #include <boost/shared_ptr.hpp>
34 
35 namespace schnek {
36 
38 typedef boost::variant<int, double, std::string> ValueVariant;
39 
41 typedef boost::variant<int*, double*, std::string*> ValuePointerVariant;
42 
43 template<typename vtype> class Expression;
44 typedef boost::shared_ptr<Expression<int> > pIntExpression;
45 typedef boost::shared_ptr<Expression<double> > pFloatExpression;
46 typedef boost::shared_ptr<Expression<std::string> > pStringExpression;
47 
49 typedef boost::variant<pIntExpression, pFloatExpression, pStringExpression> ExpressionVariant;
50 
51 
52 
54 {
55  private:
56  std::string message;
57  public:
58  VariableNotFoundException(std::string message_) : SchnekException(), message(message_) {}
59  //VariableNotFoundException() : SchnekException() {}
60  const std::string& getMessage() { return message; }
61 };
62 
64 {
65  private:
66  std::string message;
67  public:
68  EvaluationException(std::string message_) : SchnekException(), message(message_) {}
69  const std::string& getMessage() { return message; }
70 };
71 
73 {
74  std::string varName;
75  public:
76  VariableNotInitialisedException(std::string varName_)
77  : EvaluationException("Variable was not initialised: " + varName_), varName(varName_)
78  {}
79  std::string getVarName() { return varName; }
80 };
81 
82 
84 {
85  public:
87 };
88 
90 {
91  public:
93 };
94 
96 {
97  public:
99 };
100 
102 {
103  public:
105 };
106 
107 
108 } // namespace
109 
110 #endif // SCHNEK_TYPES_HPP_
Definition: types.hpp:101
Definition: types.hpp:83
Definition: types.hpp:89
Definition: algo.hpp:30
Definition: types.hpp:53
Definition: types.hpp:95
Definition: exception.hpp:33
Definition: types.hpp:63