add mp3 and ogg torrent url info to JamendoAlbum
[amarok.git] / src / expression.h
blobdb81940b90387bc8f7e6d062c6cef8f6e77286e5
1 /*
2 Copyright (c) 2006 Gábor Lehel <illissius@gmail.com>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef AMAROK_EXPRESSION_H
21 #define AMAROK_EXPRESSION_H
23 #include <QList>
24 #include <QString>
26 struct expression_element
28 QString field;
29 QString text;
30 bool negate: 1;
31 enum { Contains, Less, More } match: 2;
32 expression_element(): negate( false ), match( Contains ) { }
34 typedef QList<expression_element> or_list;
36 typedef QList<or_list> ParsedExpression;
38 class ExpressionParser
40 public:
41 ExpressionParser( const QString &expression );
42 ParsedExpression parse();
43 static ParsedExpression parse( const QString &expression );
45 static bool isAdvancedExpression( const QString &expression );
47 private:
48 void parseChar( const QChar &c );
49 void handleSpace( const QChar &c );
50 void handleMinus( const QChar &c );
51 void handleColon( const QChar &c );
52 void handleMod( const QChar &c );
53 void handleQuote( const QChar &c );
54 void handleChar( const QChar &c );
55 void finishedToken();
56 void finishedElement();
57 void finishedOrGroup();
59 const QString &m_expression;
60 enum State { ExpectMinus, ExpectField, ExpectMod, ExpectText };
61 int m_state;
62 bool m_haveGroup;
63 bool m_inQuote;
64 bool m_inOrGroup;
65 QString m_string;
66 expression_element m_element;
67 or_list m_or;
68 ParsedExpression m_parsed;
72 #endif