]> err.no Git - sope/blob - sope-xml/DOM/DOMCharacterData.m
fixed an uninit var on Cocoa
[sope] / sope-xml / DOM / DOMCharacterData.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 "DOMCharacterData.h"
23 #include "common.h"
24
25 @implementation NGDOMCharacterData
26
27 - (id)initWithString:(NSString *)_s {
28   if ((self = [super init])) {
29     self->data = [_s copy];
30   }
31   return self;
32 }
33 - (void)dealloc {
34   [self->data release];
35   [super dealloc];
36 }
37
38 /* attributes */
39
40 - (void)setData:(NSString *)_data {
41   id old = self->data;
42   self->data = [_data copy];
43   [old release];
44 }
45 - (NSString *)data {
46   return self->data;
47 }
48
49 - (unsigned)length {
50   return [self->data length];
51 }
52
53 /* operations */
54
55 - (NSString *)substringData:(unsigned)_offset count:(unsigned)_count {
56   NSRange r;
57
58   r.location = _offset;
59   r.length   = _count;
60   
61   return [[self data] substringWithRange:r];
62 }
63
64 - (void)appendData:(NSString *)_data {
65   id old;
66   old = self->data;
67   self->data = old ? [old stringByAppendingString:_data] : _data;
68   [old release];
69 }
70
71 - (void)insertData:(NSString *)_data offset:(unsigned)_offset {
72   [self doesNotRecognizeSelector:_cmd];
73 }
74
75 - (void)deleteData:(unsigned)_offset count:(unsigned)_count {
76   NSRange r;
77   id new, old;
78   
79   r.location = _offset;
80   r.length   = _count;
81
82   new = [self->data substringWithRange:r];
83   old = self->data;
84   self->data = [new copy];
85   [old release];
86 }
87
88 - (void)replaceData:(unsigned)_offset count:(unsigned)_c with:(NSString *)_s {
89   [self doesNotRecognizeSelector:_cmd];
90 }
91
92 /* parent node */
93
94 - (void)_domNodeRegisterParentNode:(id)_parent {
95   self->parent = _parent;
96 }
97 - (void)_domNodeForgetParentNode:(id)_parent {
98   if (_parent == self->parent)
99     /* the node's parent was deallocated */
100     self->parent = nil;
101 }
102 - (id<NSObject,DOMNode>)parentNode {
103   return self->parent;
104 }
105
106 /* QPValues */
107
108 - (NSException *)setQueryPathValue:(id)_value {
109   [self setData:[_value stringValue]];
110   return nil;
111 }
112 - (id)queryPathValue {
113   return [self data];
114 }
115
116 @end /* NGDOMCharacterData(QPValues) */