FXExpression.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                      E x p r e s s i o n   E v a l u a t o r                  *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXExpression.h,v 1.13 2006/03/21 01:41:43 fox Exp $                      *
00023 ********************************************************************************/
00024 #ifndef FXEXPRESSION_H
00025 #define FXEXPRESSION_H
00026 
00027 
00028 namespace FX {
00029 
00030 
00032 enum FXExpressionError {
00033   EXPRERR_OK,
00034   EXPRERR_EMPTY,             
00035   EXPRERR_MEMORY,            
00036   EXPRERR_PAREN,             
00037   EXPRERR_TOKEN,             
00038   EXPRERR_COMMA,             
00039   EXPRERR_IDENT              
00040   };
00041 
00042 
00044 class FXAPI FXExpression {
00045 private:
00046   FXuchar *code;
00047 private:
00048   static const FXuchar initial[];
00049   static const FXchar *const errors[];
00050 public:
00051 
00053   FXExpression();
00054 
00056   FXExpression(const FXExpression& orig);
00057 
00059   FXExpression(const FXchar* expression,const FXchar* variables=NULL,FXExpressionError* error=NULL);
00060 
00062   FXExpression(const FXString& expression,const FXString& variables=FXString::null,FXExpressionError* error=NULL);
00063 
00065   FXExpression& operator=(const FXExpression& orig);
00066 
00068   bool empty() const { return (code==initial); }
00069 
00071   FXdouble evaluate(const FXdouble *args=NULL);
00072 
00074   FXExpressionError parse(const FXchar* expression,const FXchar* variables=NULL);
00075 
00077   FXExpressionError parse(const FXString& expression,const FXString& variables=FXString::null);
00078 
00080   static const FXchar* getError(FXExpressionError err){ return errors[err]; }
00081 
00083  ~FXExpression();
00084   };
00085 
00086 }
00087 
00088 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:20 2009 for TnFOX by doxygen v1.4.7