ionflux.org | Impressum

TreeEval.hpp

Go to the documentation of this file.
00001 #ifndef IONFLUX_TOOLS_TREEEVAL
00002 #define IONFLUX_TOOLS_TREEEVAL
00003 /* ==========================================================================
00004  * Ionflux Tools
00005  * Copyright (c) 2004 Joern P. Meier
00006  * mail@ionflux.org
00007  * --------------------------------------------------------------------------
00008  * TreeEval.hpp                        Tree expression evaluator.
00009  * ==========================================================================
00010  * 
00011  * This file is part of Ionflux Tools.
00012  * 
00013  * Ionflux Tools is free software; you can redistribute it and/or modify it 
00014  * under the terms of the GNU General Public License as published by the Free
00015  * Software Foundation; either version 2 of the License, or (at  your option)
00016  * any later version.
00017  * 
00018  * Ionflux Tools is distributed in the hope that it will be useful, but 
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00020  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00021  * for more details.
00022  * 
00023  * You should have received a copy of the GNU General Public License
00024  * along with Ionflux Tools; if not, write to the Free Software Foundation, 
00025  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00026  * 
00027  * ========================================================================== */
00028 
00029 #include <string>
00030 #include <iostream>
00031 #include <sstream>
00032 #include <vector>
00033 #include <stack>
00034 #include <ionflux/tools.hpp>
00035 #include <ionflux/Tokenizer.hpp>
00036 #include <ionflux/Tree.hpp>
00037 #include <ionflux/TreeResolver.hpp>
00038 
00039 namespace Ionflux
00040 {
00041 
00042 namespace Tools
00043 {
00044 
00045 class Tree;
00046 struct DataEntry;
00047 struct TreeExprElement;
00048 
00054 class TreeEval
00055 {
00056     protected:
00067         static bool calculate(DataEntry &op1, DataEntry &result, 
00068             const std::string &op);
00069         
00081         static bool calculate(DataEntry &op1, DataEntry &op2, 
00082             DataEntry &result, const std::string &op);
00083         
00099         static bool unwindOpStack(std::stack<TreeExprElement> &ops, 
00100             std::stack<TreeExprElement> &values, Tree &temps, 
00101             bool unwindPar = false);
00102         
00103     public:
00105         static const TokenType TT_OPERATOR;
00107         static const TokenType TT_TREEPATH_NP;
00109         static const TokenType TT_PAR_LEFT;
00111         static const TokenType TT_PAR_RIGHT;
00112         
00117         TreeEval();
00118         
00123         virtual ~TreeEval();
00124         
00134         static bool parseTreeExpr(const std::string &treeExpr, 
00135             std::vector<TreeExprElement> &elements);
00136         
00151         static bool eval(Tree *tree, std::vector<TreeExprElement> &elements, 
00152             Node &result, bool createPath);
00153 };
00154 
00155 }
00156 
00157 }
00158 
00162 #endif

Generated on Tue Mar 14 20:58:30 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6