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
26 struct expression_element
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
41 ExpressionParser( const QString
&expression
);
42 ParsedExpression
parse();
43 static ParsedExpression
parse( const QString
&expression
);
45 static bool isAdvancedExpression( const QString
&expression
);
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
);
56 void finishedElement();
57 void finishedOrGroup();
59 const QString
&m_expression
;
60 enum State
{ ExpectMinus
, ExpectField
, ExpectMod
, ExpectText
};
66 expression_element m_element
;
68 ParsedExpression m_parsed
;