Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXExpression.h
1 /********************************************************************************
2 * *
3 * E x p r e s s i o n E v a l u a t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXEXPRESSION_H
22 #define FXEXPRESSION_H
23 
24 namespace FX {
25 
26 
81 class FXAPI FXExpression {
82 private:
83  FXuchar *code;
84 private:
85  static const FXuchar initial[];
86  static const FXchar *const errors[];
87 public:
88 
90  enum Error {
91  ErrOK,
98  ErrColon
99  };
100 
101 public:
102 
104  FXExpression();
105 
107  FXExpression(const FXExpression& orig);
108 
110  FXExpression(const FXchar* expression,const FXchar* variables=NULL,Error* error=NULL);
111 
113  FXExpression(const FXString& expression,const FXString& variables=FXString::null,Error* error=NULL);
114 
116  FXExpression& operator=(const FXExpression& orig);
117 
119  FXbool empty() const { return (code==initial); }
120 
126  FXdouble evaluate(const FXdouble *args=NULL) const;
127 
135  Error parse(const FXchar* expression,const FXchar* variables=NULL);
136  Error parse(const FXString& expression,const FXString& variables=FXString::null);
137 
139  static const FXchar* getError(Error err){ return errors[err]; }
140 
142  friend FXAPI FXStream& operator<<(FXStream& store,const FXExpression& s);
143  friend FXAPI FXStream& operator>>(FXStream& store,FXExpression& s);
144 
146  void clear();
147 
149  ~FXExpression();
150  };
151 
152 
153 // Serialization
154 extern FXAPI FXStream& operator<<(FXStream& store,const FXExpression& s);
155 extern FXAPI FXStream& operator>>(FXStream& store,FXExpression& s);
156 
157 }
158 
159 #endif

Copyright © 1997-2016 Jeroen van der Zijp