File indexing completed on 2024-05-19 04:49:18
0001 /**************************************************************************************** 0002 * Copyright (c) 2007-2008 Maximilian Kossick <maximilian.kossick@googlemail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef AMAROK_XMLQUERYREADER_H 0018 #define AMAROK_XMLQUERYREADER_H 0019 0020 #include "core/collections/QueryMaker.h" 0021 0022 #include <QList> 0023 #include <QXmlStreamReader> 0024 0025 namespace Collections { 0026 class QueryMaker; 0027 } 0028 0029 class XmlQueryReader : public QXmlStreamReader 0030 { 0031 public: 0032 0033 enum ReturnValueEnum { IgnoreReturnValues = 0 0034 , ParseReturnValues 0035 }; 0036 0037 static Collections::QueryMaker* getQueryMaker( const QString &xmlData, ReturnValueEnum flag ); 0038 0039 XmlQueryReader( Collections::QueryMaker *qm, ReturnValueEnum flag ); 0040 virtual ~XmlQueryReader(); 0041 0042 bool read( const QString &xmlData ); 0043 0044 struct Filter 0045 { 0046 Filter() : exclude(false), field(0), compare(-1) {} 0047 0048 bool exclude; 0049 qint64 field; 0050 QString value; 0051 int compare; /* -1 => not a numerical comparison */ 0052 }; 0053 0054 const QList<Filter>& getFilters() const; 0055 0056 /** 0057 * Reads only one filter element. 0058 */ 0059 static Filter readFilter(QXmlStreamReader *reader); 0060 0061 static int compareVal( QStringRef compare ); 0062 0063 private: 0064 void readQuery(); 0065 void readFilters(); 0066 void readReturnValues(); 0067 void ignoreElements(); 0068 void readAndOr(); 0069 0070 struct Private; 0071 Private * const d; 0072 }; 0073 0074 #endif