]> err.no Git - sope/blob - sope-xml/SaxObjC/SaxMethodCallHandler.h
fixed init
[sope] / sope-xml / SaxObjC / SaxMethodCallHandler.h
1 /*
2   Copyright (C) 2000-2005 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 __SaxMethodCallHandler_H__
23 #define __SaxMethodCallHandler_H__
24
25 #include <SaxObjC/SaxDefaultHandler.h>
26 #import <Foundation/NSMapTable.h>
27
28 @class NSString, NSMutableArray, NSMutableDictionary;
29
30 /*
31   [also take a look at SaxObjectDecoder]
32   
33   This handler calls a method on a delegate for each tag. The selector is
34   constructed this way:
35   
36     [start|end] + nskey + tagname + ':'
37
38   If no method could be found for the tag, it is first checked whether the
39   delegate responds to
40
41     [start|end] + nskey + 'unknownTag:attributes:'
42
43   and it this couldn't be found, it is checked for
44
45     [start|end] + 'tag:_tagName namespace:_ns attributes:'
46
47   If no key could be found for a namespace, it is first checked whether the
48   delegate responds to
49
50     [start|end] + 'any_' + tagname + ':'
51
52   if this fails it is checked for this selector
53
54     [start|end] + 'tag:_tagName namespace:_ns attributes:'
55
56   if neither exists, the tag is ignored.
57   
58   Eg:
59
60     nskey='xhtml' startKey='start_' endKey='end_'
61     - (void)start_xhtml_br:(id<SaxAttributes>)_attrs;
62     - (void)end_xhtml_br;
63 */
64
65 @interface SaxMethodCallHandler : SaxDefaultHandler
66 {
67   id                  delegate; // non-retained: default=self (for subclasses)
68   NSMutableDictionary *namespaceToKey;
69   NSMutableArray      *tagStack;
70   NSString            *startKey;            // default: 'start_'
71   NSString            *endKey;              // default: 'end_'
72   NSString            *unknownNamespaceKey; // default: 'any_'
73   int                 ignoreLevel;
74   
75   /* processing */
76   NSMapTable      *fqNameToStartSel;
77   NSMutableString *selName; /* reused for each construction */
78 }
79
80 /* namespaces */
81
82 - (void)registerNamespace:(NSString *)_namespace withKey:(NSString *)_key;
83
84 /* keys */
85
86 - (void)setStartKey:(NSString *)_s;
87 - (NSString *)startKey;
88 - (void)setEndKey:(NSString *)_s;
89 - (NSString *)endKey;
90 - (void)setUnknownNamespaceKey:(NSString *)_s;
91 - (NSString *)unknownNamespaceKey;
92
93 /* tag stack */
94
95 - (NSArray *)tagStack;
96 - (unsigned)depth;
97
98 - (void)ignoreChildren;
99 - (BOOL)doesIgnoreChildren;
100
101 /* delegate */
102
103 - (void)setDelegate:(id)_delegate;
104 - (id)delegate;
105
106 @end
107
108 #endif /* __SaxMethodCallHandler_H__ */