File indexing completed on 2024-04-28 15:24:56
0001 /* 0002 * path.h - Copyright 2005 Frerich Raabe <raabe@kde.org> 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 0008 * 1. Redistributions of source code must retain the above copyright 0009 * notice, this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright 0011 * notice, this list of conditions and the following disclaimer in the 0012 * documentation and/or other materials provided with the distribution. 0013 * 0014 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0017 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 */ 0025 #ifndef PATH_H 0026 #define PATH_H 0027 0028 #include "expression.h" 0029 #include "step.h" 0030 0031 #include <QList> 0032 0033 int khtmlxpathyyparse(); 0034 0035 namespace khtml 0036 { 0037 namespace XPath 0038 { 0039 0040 class Filter : public Expression 0041 { 0042 public: 0043 Filter(Expression *expr, 0044 const QList<Predicate *> &predicates = QList<Predicate *>()); 0045 virtual ~Filter(); 0046 0047 QString dump() const override; 0048 0049 private: 0050 Value doEvaluate() const override; 0051 0052 Expression *m_expr; 0053 QList<Predicate *> m_predicates; 0054 }; 0055 0056 class LocationPath : public Expression 0057 { 0058 friend int ::khtmlxpathyyparse(); 0059 public: 0060 LocationPath(); 0061 virtual ~LocationPath(); 0062 0063 void optimize(); 0064 QString dump() const override; 0065 0066 private: 0067 Value doEvaluate() const override; 0068 0069 QList<Step *> m_steps; 0070 bool m_absolute; 0071 }; 0072 0073 class Path : public Expression 0074 { 0075 public: 0076 Path(Filter *filter, LocationPath *path); 0077 virtual ~Path(); 0078 0079 QString dump() const override; 0080 0081 private: 0082 Value doEvaluate() const override; 0083 0084 Filter *m_filter; 0085 LocationPath *m_path; 0086 }; 0087 0088 } // namespace XPath 0089 0090 } // namespace khtml 0091 0092 #endif // PATH_H 0093