|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: DOM_Text.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 #ifndef DOM_Text_HEADER_GUARD_ |
|
39 #define DOM_Text_HEADER_GUARD_ |
|
40 |
|
41 #include <xercesc/util/XercesDefs.hpp> |
|
42 #include "DOM_CharacterData.hpp" |
|
43 |
|
44 XERCES_CPP_NAMESPACE_BEGIN |
|
45 |
|
46 |
|
47 class TextImpl; |
|
48 |
|
49 |
|
50 /** |
|
51 * The <code>Text</code> interface represents the textual content (termed |
|
52 * character data in XML) of an <code>Element</code> or <code>Attr</code>. |
|
53 * If there is no markup inside an element's content, the text is contained |
|
54 * in a single object implementing the <code>Text</code> interface that is |
|
55 * the only child of the element. If there is markup, it is parsed into a |
|
56 * list of elements and <code>Text</code> nodes that form the list of |
|
57 * children of the element. |
|
58 * <p>When a document is first made available via the DOM, there is only one |
|
59 * <code>Text</code> node for each block of text. Users may create adjacent |
|
60 * <code>Text</code> nodes that represent the contents of a given element |
|
61 * without any intervening markup, but should be aware that there is no way |
|
62 * to represent the separations between these nodes in XML, so they |
|
63 * will not (in general) persist between DOM editing sessions. The |
|
64 * <code>normalize()</code> method on <code>Element</code> merges any such |
|
65 * adjacent <code>Text</code> objects into a single node for each block of |
|
66 * text; this is recommended before employing operations that depend on a |
|
67 * particular document structure, such as navigation with |
|
68 * <code>XPointers.</code> |
|
69 */ |
|
70 class DEPRECATED_DOM_EXPORT DOM_Text: public DOM_CharacterData { |
|
71 |
|
72 public: |
|
73 /** @name Constructors and assignment operator */ |
|
74 //@{ |
|
75 /** |
|
76 * Default constructor for DOM_Text. The resulting object does not |
|
77 * refer to an actual Text node; it will compare == to 0, and is similar |
|
78 * to a null object reference variable in Java. It may subsequently be |
|
79 * assigned to refer to an actual comment node. |
|
80 * |
|
81 */ |
|
82 DOM_Text(); |
|
83 |
|
84 /** |
|
85 * Copy constructor. Creates a new <code>DOM_Text</code> that refers to the |
|
86 * same underlying node as the original. See also DOM_Node::clone(), |
|
87 * which will copy the actual Text node, rather than just creating a new |
|
88 * reference to the original node. |
|
89 * |
|
90 * @param other The object to be copied. |
|
91 */ |
|
92 DOM_Text(const DOM_Text &other); |
|
93 |
|
94 /** |
|
95 * Assignment operator. |
|
96 * |
|
97 * @param other The object to be copied. |
|
98 */ |
|
99 DOM_Text & operator = (const DOM_Text &other); |
|
100 |
|
101 /** |
|
102 * Assignment operator. This overloaded variant is provided for |
|
103 * the sole purpose of setting a DOM_Node reference variable to |
|
104 * zero. Nulling out a reference variable in this way will decrement |
|
105 * the reference count on the underlying Node object that the variable |
|
106 * formerly referenced. This effect is normally obtained when reference |
|
107 * variable goes out of scope, but zeroing them can be useful for |
|
108 * global instances, or for local instances that will remain in scope |
|
109 * for an extended time, when the storage belonging to the underlying |
|
110 * node needs to be reclaimed. |
|
111 * |
|
112 * @param val Only a value of 0, or null, is allowed. |
|
113 */ |
|
114 DOM_Text & operator = (const DOM_NullPtr *val); |
|
115 |
|
116 //@} |
|
117 /** @name Destructor. */ |
|
118 //@{ |
|
119 /** |
|
120 * Destructor for DOM_Text. The object being destroyed is the reference |
|
121 * object, not the underlying Comment node itself. |
|
122 * |
|
123 */ |
|
124 ~DOM_Text(); |
|
125 |
|
126 //@} |
|
127 /** @name Functions to modify the Text node. */ |
|
128 //@{ |
|
129 |
|
130 /** |
|
131 * Breaks this node into two nodes at the specified |
|
132 * offset, keeping both in the tree as siblings. |
|
133 * |
|
134 * This node then only |
|
135 * contains all the content up to the <code>offset</code> point. And a new |
|
136 * node of the same nodeType, which is inserted as the next sibling of this |
|
137 * node, contains all the content at and after the <code>offset</code> |
|
138 * point. When the <code>offset</code> is equal to the lenght of this node, |
|
139 * the new node has no data. |
|
140 * @param offset The offset at which to split, starting from 0. |
|
141 * @return The new <code>Text</code> node. |
|
142 * @exception DOMException |
|
143 * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
|
144 * than the number of characters in <code>data</code>. |
|
145 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
|
146 */ |
|
147 DOM_Text splitText(unsigned int offset); |
|
148 |
|
149 //@} |
|
150 /** @name Non-standard (not defined by the DOM specification) functions. */ |
|
151 //@{ |
|
152 |
|
153 /** |
|
154 * |
|
155 * Return true if this node contains ignorable whitespaces only. |
|
156 * @return True if this node contains ignorable whitespaces only. |
|
157 */ |
|
158 bool isIgnorableWhitespace(); |
|
159 |
|
160 //@} |
|
161 |
|
162 protected: |
|
163 DOM_Text(TextImpl *); |
|
164 |
|
165 friend class DOM_Document; |
|
166 friend class RangeImpl; |
|
167 |
|
168 |
|
169 |
|
170 }; |
|
171 |
|
172 XERCES_CPP_NAMESPACE_END |
|
173 |
|
174 #endif |
|
175 |
|
176 |