/* etree.* - handles expression trees.. Copyright (C) 1999,2001-2004 Matthew Mueller This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "etree.h" #include "cache.h" #include "grouplist.h" #include "myregex.h" #include "misc.h" #include "nget.h" #include "strreps.h" #include "getter.h" #include #define MAKE_BINARY_OP(name,op) template \ struct Op_ ## name { \ bool operator()(const T v1,const T2 v2) const {return v1 op v2;} \ }; MAKE_BINARY_OP(gt,>); MAKE_BINARY_OP(ge,>=); MAKE_BINARY_OP(lt,<); MAKE_BINARY_OP(le,<=); MAKE_BINARY_OP(eq,==); MAKE_BINARY_OP(ne,!=); //use real operators here (rather than a predComparison with Op template) to take advantage of short-circuit evaluation. template class predAnd : public pred { private: pred *p1, *p2; public: predAnd(pred *n1, pred *n2):p1(n1), p2(n2) { } virtual ~predAnd() {delete p1; delete p2;} virtual bool operator()(ClassType* f) const { return (*p1)(f) && (*p2)(f); } }; template class predOr : public pred { private: pred *p1, *p2; public: predOr(pred *n1, pred *n2):p1(n1), p2(n2) { } virtual ~predOr() {delete p1; delete p2;} virtual bool operator()(ClassType* f) const { return (*p1)(f) || (*p2)(f); } }; template