00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXEXPRESSION_H
00022 #define FXEXPRESSION_H
00023
00024
00025 namespace FX {
00026
00027
00029 enum FXExpressionError {
00030 EXPRERR_OK,
00031 EXPRERR_EMPTY,
00032 EXPRERR_MEMORY,
00033 EXPRERR_PAREN,
00034 EXPRERR_TOKEN,
00035 EXPRERR_COMMA,
00036 EXPRERR_IDENT
00037 };
00038
00039
00041 class FXAPI FXExpression {
00042 private:
00043 FXuchar *code;
00044 private:
00045 static const FXuchar initial[];
00046 static const FXchar *const errors[];
00047 public:
00048
00050 FXExpression();
00051
00053 FXExpression(const FXExpression& orig);
00054
00056 FXExpression(const FXchar* expression,const FXchar* variables=NULL,FXExpressionError* error=NULL);
00057
00059 FXExpression(const FXString& expression,const FXString& variables=FXString::null,FXExpressionError* error=NULL);
00060
00062 FXExpression& operator=(const FXExpression& orig);
00063
00065 FXbool empty() const { return (code==initial); }
00066
00068 FXdouble evaluate(const FXdouble *args=NULL) const;
00069
00071 FXExpressionError parse(const FXchar* expression,const FXchar* variables=NULL);
00072
00074 FXExpressionError parse(const FXString& expression,const FXString& variables=FXString::null);
00075
00077 static const FXchar* getError(FXExpressionError err){ return errors[err]; }
00078
00080 friend FXAPI FXStream& operator<<(FXStream& store,const FXExpression& s);
00081 friend FXAPI FXStream& operator>>(FXStream& store,FXExpression& s);
00082
00084 ~FXExpression();
00085 };
00086
00087
00088
00089 extern FXAPI FXStream& operator<<(FXStream& store,const FXExpression& s);
00090 extern FXAPI FXStream& operator>>(FXStream& store,FXExpression& s);
00091
00092 }
00093
00094 #endif