[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: DOM_CharacterData.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef DOM_CharacterData_HEADER_GUARD_ |
---|
| 23 | #define DOM_CharacterData_HEADER_GUARD_ |
---|
| 24 | |
---|
| 25 | #include <xercesc/util/XercesDefs.hpp> |
---|
| 26 | #include "DOM_Node.hpp" |
---|
| 27 | |
---|
| 28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | class CharacterDataImpl; |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * The <code>DOM_CharacterData</code> interface extends Node with a set of |
---|
| 35 | * methods for accessing character data in the DOM. |
---|
| 36 | * |
---|
| 37 | * For clarity this set is defined here rather than on each class that uses |
---|
| 38 | * these methods. No DOM objects correspond directly to |
---|
| 39 | * <code>CharacterData</code>, though <code>Text</code> and others do inherit |
---|
| 40 | * the interface from it. All <code>offset</code>s in this interface start |
---|
| 41 | * from 0, and index in terms of Unicode 16 bit storage units. |
---|
| 42 | */ |
---|
| 43 | class DEPRECATED_DOM_EXPORT DOM_CharacterData: public DOM_Node { |
---|
| 44 | |
---|
| 45 | private: |
---|
| 46 | |
---|
| 47 | public: |
---|
| 48 | /** @name Constructors and assignment operator */ |
---|
| 49 | //@{ |
---|
| 50 | /** |
---|
| 51 | * Default constructor for DOM_CharacterData. While there can be |
---|
| 52 | * no actual DOM nodes of type CharacterData, the C++ objects |
---|
| 53 | * function more like reference variables, and instances of |
---|
| 54 | * <code>DOM_CharacterData</code> can exist. They will be null when created |
---|
| 55 | * by this constructor, and can then be assigned to refer to Text |
---|
| 56 | * or CDATASection nodes. |
---|
| 57 | */ |
---|
| 58 | DOM_CharacterData(); |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * Copy constructor |
---|
| 62 | * |
---|
| 63 | * @param other The object to be copied |
---|
| 64 | */ |
---|
| 65 | DOM_CharacterData(const DOM_CharacterData &other); |
---|
| 66 | /** |
---|
| 67 | * Assignment operator |
---|
| 68 | * |
---|
| 69 | * @param other The object to be copied |
---|
| 70 | */ |
---|
| 71 | DOM_CharacterData & operator = (const DOM_CharacterData &other); |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * Assignment operator. This overloaded variant is provided for |
---|
| 75 | * the sole purpose of setting a DOM_Node reference variable to |
---|
| 76 | * zero. Nulling out a reference variable in this way will decrement |
---|
| 77 | * the reference count on the underlying Node object that the variable |
---|
| 78 | * formerly referenced. This effect is normally obtained when reference |
---|
| 79 | * variable goes out of scope, but zeroing them can be useful for |
---|
| 80 | * global instances, or for local instances that will remain in scope |
---|
| 81 | * for an extended time, when the storage belonging to the underlying |
---|
| 82 | * node needs to be reclaimed. |
---|
| 83 | * |
---|
| 84 | * @param val Only a value of 0, or null, is allowed. |
---|
| 85 | */ |
---|
| 86 | DOM_CharacterData & operator = (const DOM_NullPtr *val); |
---|
| 87 | |
---|
| 88 | //@} |
---|
| 89 | /** @name Destructor. */ |
---|
| 90 | //@{ |
---|
| 91 | /** |
---|
| 92 | * Destructor for DOM_CharacterData. The object being destroyed |
---|
| 93 | * is the reference to the Character Data node, not the character |
---|
| 94 | * data itself. |
---|
| 95 | */ |
---|
| 96 | ~DOM_CharacterData(); |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | //@} |
---|
| 100 | |
---|
| 101 | /** @name Getter functions. */ |
---|
| 102 | //@{ |
---|
| 103 | /** |
---|
| 104 | * Returns the character data of the node that implements this interface. |
---|
| 105 | * |
---|
| 106 | * The DOM implementation may not put arbitrary limits on the amount of data that |
---|
| 107 | * may be stored in a <code>CharacterData</code> node. However, |
---|
| 108 | * implementation limits may mean that the entirety of a node's data may |
---|
| 109 | * not fit into a single <code>DOMString</code>. In such cases, the user |
---|
| 110 | * may call <code>substringData</code> to retrieve the data in |
---|
| 111 | * appropriately sized pieces. |
---|
| 112 | * @exception DOMException |
---|
| 113 | * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
---|
| 114 | * @exception DOMException |
---|
| 115 | * DOMSTRING_SIZE_ERR: Raised when it would return more characters than |
---|
| 116 | * fit in a <code>DOMString</code> variable on the implementation |
---|
| 117 | * platform. |
---|
| 118 | */ |
---|
| 119 | DOMString getData() const; |
---|
| 120 | /** |
---|
| 121 | * Returns the number of characters that are available through <code>data</code> and |
---|
| 122 | * the <code>substringData</code> method below. |
---|
| 123 | * |
---|
| 124 | * This may have the value |
---|
| 125 | * zero, i.e., <code>CharacterData</code> nodes may be empty. |
---|
| 126 | */ |
---|
| 127 | unsigned int getLength() const; |
---|
| 128 | /** |
---|
| 129 | * Extracts a range of data from the node. |
---|
| 130 | * |
---|
| 131 | * @param offset Start offset of substring to extract. |
---|
| 132 | * @param count The number of characters to extract. |
---|
| 133 | * @return The specified substring. If the sum of <code>offset</code> and |
---|
| 134 | * <code>count</code> exceeds the <code>length</code>, then all |
---|
| 135 | * characters to the end of the data are returned. |
---|
| 136 | * @exception DOMException |
---|
| 137 | * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
---|
| 138 | * than the number of characters in <code>data</code>, or if the |
---|
| 139 | * specified <code>count</code> is negative. |
---|
| 140 | * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not |
---|
| 141 | * fit into a <code>DOMString</code>. |
---|
| 142 | */ |
---|
| 143 | DOMString substringData(unsigned int offset, |
---|
| 144 | unsigned int count) const; |
---|
| 145 | //@} |
---|
| 146 | /** @name Functions that set or change data. */ |
---|
| 147 | //@{ |
---|
| 148 | /** |
---|
| 149 | * Append the string to the end of the character data of the node. |
---|
| 150 | * |
---|
| 151 | * Upon success, <code>data</code> provides access to the concatenation of |
---|
| 152 | * <code>data</code> and the <code>DOMString</code> specified. |
---|
| 153 | * @param arg The <code>DOMString</code> to append. |
---|
| 154 | * @exception DOMException |
---|
| 155 | * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
---|
| 156 | */ |
---|
| 157 | void appendData(const DOMString &arg); |
---|
| 158 | /** |
---|
| 159 | * Insert a string at the specified character offset. |
---|
| 160 | * |
---|
| 161 | * @param offset The character offset at which to insert. |
---|
| 162 | * @param arg The <code>DOMString</code> to insert. |
---|
| 163 | * @exception DOMException |
---|
| 164 | * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
---|
| 165 | * than the number of characters in <code>data</code>. |
---|
| 166 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
---|
| 167 | */ |
---|
| 168 | void insertData(unsigned int offset, const DOMString &arg); |
---|
| 169 | /** |
---|
| 170 | * Remove a range of characters from the node. |
---|
| 171 | * |
---|
| 172 | * Upon success, |
---|
| 173 | * <code>data</code> and <code>length</code> reflect the change. |
---|
| 174 | * @param offset The offset from which to remove characters. |
---|
| 175 | * @param count The number of characters to delete. If the sum of |
---|
| 176 | * <code>offset</code> and <code>count</code> exceeds <code>length</code> |
---|
| 177 | * then all characters from <code>offset</code> to the end of the data |
---|
| 178 | * are deleted. |
---|
| 179 | * @exception DOMException |
---|
| 180 | * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
---|
| 181 | * than the number of characters in <code>data</code>, or if the |
---|
| 182 | * specified <code>count</code> is negative. |
---|
| 183 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
---|
| 184 | */ |
---|
| 185 | void deleteData(unsigned int offset, |
---|
| 186 | unsigned int count); |
---|
| 187 | /** |
---|
| 188 | * Replace the characters starting at the specified character offset with |
---|
| 189 | * the specified string. |
---|
| 190 | * |
---|
| 191 | * @param offset The offset from which to start replacing. |
---|
| 192 | * @param count The number of characters to replace. If the sum of |
---|
| 193 | * <code>offset</code> and <code>count</code> exceeds <code>length</code> |
---|
| 194 | * , then all characters to the end of the data are replaced (i.e., the |
---|
| 195 | * effect is the same as a <code>remove</code> method call with the same |
---|
| 196 | * range, followed by an <code>append</code> method invocation). |
---|
| 197 | * @param arg The <code>DOMString</code> with which the range must be |
---|
| 198 | * replaced. |
---|
| 199 | * @exception DOMException |
---|
| 200 | * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
---|
| 201 | * than the number of characters in <code>data</code>, or if the |
---|
| 202 | * specified <code>count</code> is negative. |
---|
| 203 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
---|
| 204 | */ |
---|
| 205 | void replaceData(unsigned int offset, |
---|
| 206 | unsigned int count, |
---|
| 207 | const DOMString &arg); |
---|
| 208 | |
---|
| 209 | /** |
---|
| 210 | * Sets the character data of the node that implements this interface. |
---|
| 211 | * |
---|
| 212 | * @param data The <code>DOMString</code> to set. |
---|
| 213 | */ |
---|
| 214 | void setData(const DOMString &data); |
---|
| 215 | //@} |
---|
| 216 | |
---|
| 217 | protected: |
---|
| 218 | DOM_CharacterData(CharacterDataImpl *impl); |
---|
| 219 | |
---|
| 220 | }; |
---|
| 221 | |
---|
| 222 | XERCES_CPP_NAMESPACE_END |
---|
| 223 | |
---|
| 224 | #endif |
---|
| 225 | |
---|
| 226 | |
---|