File indexing completed on 2024-03-24 16:22:02
0001 /** 0002 This file belong to the KMPlayer project, a movie player plugin for Konqueror 0003 Copyright (C) 2009 Koos Vriezen <koos.vriezen@gmail.com> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Lesser General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Lesser General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public 0016 License along with this library; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 **/ 0019 0020 #ifndef _KMPLAYER_EXPRESSION_H_ 0021 #define _KMPLAYER_EXPRESSION_H_ 0022 0023 #include "kmplayerplaylist.h" 0024 0025 namespace KMPlayer { 0026 0027 class NodeValue { 0028 public: 0029 NodeValue (Node *n, Attribute *a=NULL) : node (n), attr (a) {} 0030 NodeValue (const QString &s) : node (NULL), attr (NULL), string (s) {} 0031 0032 QString value () const; 0033 bool operator ==(const NodeValue& v) const { 0034 return (node && node == v.node && attr == v.attr) 0035 || (!node && string == v.string); 0036 } 0037 0038 Node *node; 0039 Attribute *attr; 0040 QString string; 0041 }; 0042 0043 class ExprIterator; 0044 0045 class Expression : public VirtualVoid { 0046 public: 0047 class iterator { 0048 mutable ExprIterator* iter; 0049 public: 0050 iterator(ExprIterator* it=NULL) : iter(it) {} 0051 iterator(const iterator& it) : iter(it.iter) { it.iter = NULL; } 0052 ~iterator(); 0053 iterator& operator =(const iterator& it); 0054 bool operator ==(const iterator& it) const; 0055 bool operator !=(const iterator& it) const { return !(*this == it); } 0056 iterator& operator ++(); 0057 NodeValue& operator*(); 0058 NodeValue* operator->(); 0059 }; 0060 virtual bool toBool () const = 0; 0061 virtual int toInt () const = 0; 0062 virtual float toFloat () const = 0; 0063 virtual QString toString () const = 0; 0064 virtual iterator begin() const = 0; 0065 virtual iterator end() const = 0; 0066 virtual void setRoot (Node *root) = 0; 0067 }; 0068 0069 Expression* evaluateExpr(const QByteArray& expr, const QString& root = QString()); 0070 0071 } 0072 0073 #endif