MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
evaluator_impl.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbutil/evaluator_impl.cc,v 1.3 2017/01/12 14:44:04 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 /*
33  * With the contribution of Ankit Aggarwal <ankit.ankit.aggarwal@gmail.com>
34  * during Google Summer of Code 2015
35  */
36 
37 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
38 
39 #include <cerrno>
40 #include <cfloat>
41 #include <cstdlib>
42 #include <climits>
43 #include <limits>
44 #include <sstream>
45 
46 #include "mathp.h"
47 #include "parser.h"
48 
49 #ifdef USE_EE
50 
51 #include "evaluator_impl.h"
52 
54 
55 std::string
57 {
58  std::ostringstream out;
59  e->Output(out);
60  return out.str();
61 }
62 
63 bool
64 EE_Eval(TypedValue& dst, const ExpressionElement *ee)
65 {
66  if (ee == 0) {
67  return false;
68  }
69 
70  dst = ee->Eval();
71 
72  return true;
73 }
74 
75 bool
76 EE_Eval(bool& dst, const ExpressionElement *ee)
77 {
78  if (ee == 0) {
79  return false;
80  }
81 
82  dst = ee->Eval().GetBool();
83 
84  return true;
85 }
86 
87 bool
88 EE_Eval(Int& dst, const ExpressionElement *ee)
89 {
90  if (ee == 0) {
91  return false;
92  }
93 
94  dst = ee->Eval().GetInt();
95 
96  return true;
97 }
98 
99 bool
100 EE_Eval(Real& dst, const ExpressionElement *ee)
101 {
102  if (ee == 0) {
103  return false;
104  }
105 
106  dst = ee->Eval().GetReal();
107 
108  return true;
109 }
110 
111 bool
112 EE_Eval(std::string& dst, const ExpressionElement *ee)
113 {
114  if (ee == 0) {
115  return false;
116  }
117 
118  dst = ee->Eval().GetString();
119 
120  return true;
121 }
122 
123 #endif // USE_EE
Real GetReal(void) const
Definition: mathp.cc:1228
bool EE_Eval(TypedValue &dst, const ExpressionElement *ee)
virtual TypedValue Eval(void) const =0
int Int
Definition: mathtyp.h:40
static unsigned m_uEEFlags
Definition: evaluator.h:53
virtual std::ostream & Output(std::ostream &out) const =0
std::string EEStrOut(const ExpressionElement *e)
const std::string & GetString(void) const
Definition: mathp.cc:1247
Int GetInt(void) const
Definition: mathp.cc:1209
bool GetBool(void) const
Definition: mathp.cc:1188
double Real
Definition: mathtyp.h:39