]> err.no Git - sope/blob - sope-xml/DOM/DOMNode+Enum.m
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / sope-xml / DOM / DOMNode+Enum.m
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 #include "DOMNode+Enum.h"
23 #include "common.h"
24
25 @interface _DOMNodeParentNodeEnumerator : NSEnumerator
26 {
27   id currentNode;
28 }
29 + (id)enumeratorWithDOMNode:(id)_node;
30 @end
31
32 @implementation NSObject(DOMNodeEnum)
33
34 - (NSEnumerator *)domParentNodeEnumerator {
35   return [_DOMNodeParentNodeEnumerator enumeratorWithDOMNode:
36                                          [(NGDOMNode *)self parentNode]];
37 }
38
39 @end /* NSObject(DOMNodeEnum) */
40
41 @implementation NGDOMNode(Enum)
42
43 - (NSEnumerator *)parentNodeEnumerator {
44   return [self domParentNodeEnumerator];
45 }
46
47 @end /* NGDOMNode(Enum) */
48
49 @implementation _DOMNodeParentNodeEnumerator
50
51 + (id)enumeratorWithDOMNode:(id)_node {
52   _DOMNodeParentNodeEnumerator *e;
53   e = [self alloc];
54   e->currentNode = [_node retain];
55   return [e autorelease];
56 }
57
58 - (void)dealloc {
59   [self->currentNode release];
60   [super dealloc];
61 }
62
63 - (id)nextObject {
64   id old;
65
66   old = self->currentNode;
67   self->currentNode = [[old parentNode] retain];
68   return [old autorelease];
69 }
70
71 @end /* _DOMNodeParentNodeEnumerator */