]> err.no Git - sope/blob - sope-core/NGExtensions/NGRuleEngine.subproj/NGRuleParser.h
fixed copyrights for 2005
[sope] / sope-core / NGExtensions / NGRuleEngine.subproj / NGRuleParser.h
1 /*
2   Copyright (C) 2003-2004 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGRuleEngine_NGRuleParser_H__
23 #define __NGRuleEngine_NGRuleParser_H__
24
25 #import <Foundation/NSObject.h>
26 #import <Foundation/NSString.h>
27
28 /*
29   NGRuleParser
30   
31   This class parses NGRule objects. The serialization format is:
32   
33      qualifier => assignment [; priority]
34      
35   The qualifier is either the special '*true*' or a serialized EOQualifier
36   and the assignment is a key/value statement, eg "value=blue".
37
38   We map some special priority "keys":
39     "important" => 1000
40     "very high" => 200
41     "high"      => 150
42     "default"   => 100
43     "normal"    => 100
44     "low"       => 50
45     "very low"  => 5
46     "fallback"  => 0
47 */
48
49 @class NSException, NSString, NSDictionary;
50 @class EOQualifier;
51 @class NGRule, NGRuleModel;
52
53 @interface NGRuleParser : NSObject
54 {
55   NSString     *ruleQuotes;
56   unichar      ruleEscape;
57   NSException  *lastException;
58   NSDictionary *priorityMapping; /* maps strings to ints (eg high => 10)  */
59   NSDictionary *boolMapping;     /* maps strings to bool (eg false => NO) */
60 }
61
62 + (id)sharedRuleParser;
63
64 /* accessors */
65
66 - (NSException *)lastException;
67
68 /* parsing */
69
70 - (NGRule *)parseRuleFromPropertyList:(id)_plist;
71 - (NGRule *)parseRuleFromString:(NSString *)_plist;
72 - (NGRuleModel *)parseRuleModelFromPropertyList:(id)_plist;
73
74 /* parsing of the individual parts */
75
76 - (EOQualifier *)parseQualifierFromString:(NSString *)_s;
77 - (id)parseActionFromString:(NSString *)_s;
78 - (int)parsePriorityFromString:(NSString *)_s;
79
80 - (BOOL)splitString:(NSString *)_s 
81   intoQualifierString:(NSString **)_qs
82   actionString:(NSString **)_as
83   andPriorityString:(NSString **)_ps;
84
85 @end
86
87 #endif /* __NGRuleEngine_NGRuleParser_H__ */