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