DOM_CharacterData.hpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:11k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  * 
  4.  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  * 
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer. 
  13.  * 
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  * 
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:  
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  * 
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written 
  29.  *    permission, please contact apache@apache.org.
  30.  * 
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  * 
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  * 
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 1999, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Log: DOM_CharacterData.hpp,v $
  58.  * Revision 1.6  2000/03/02 19:53:53  roddey
  59.  * This checkin includes many changes done while waiting for the
  60.  * 1.1.0 code to be finished. I can't list them all here, but a list is
  61.  * available elsewhere.
  62.  *
  63.  * Revision 1.5  2000/02/24 20:11:27  abagchi
  64.  * Swat for removing Log from API docs
  65.  *
  66.  * Revision 1.4  2000/02/15 23:17:36  andyh
  67.  * Update Doc++ API comments
  68.  * NameSpace bugfix and update to track W3C
  69.  * Chih Hsiang Chou
  70.  *
  71.  * Revision 1.3  2000/02/06 07:47:28  rahulj
  72.  * Year 2K copyright swat.
  73.  *
  74.  * Revision 1.2  2000/02/04 01:49:29  aruna1
  75.  * TreeWalker and NodeIterator changes
  76.  *
  77.  * Revision 1.1.1.1  1999/11/09 01:08:49  twl
  78.  * Initial checkin
  79.  *
  80.  * Revision 1.2  1999/11/08 20:44:13  rahul
  81.  * Swat for adding in Product name and CVS comment log variable.
  82.  *
  83.  */
  84. #ifndef DOM_CharacterData_HEADER_GUARD_
  85. #define DOM_CharacterData_HEADER_GUARD_
  86. #include <util/XercesDefs.hpp>
  87. #include <dom/DOM_Node.hpp>
  88. class CharacterDataImpl;
  89. /**
  90.  * The <code>DOM_CharacterData</code> interface extends Node with a set  of 
  91.  * methods for accessing character data in the DOM.
  92.  *
  93.  * For clarity this set is defined here rather than on each class that uses 
  94.  * these methods. No DOM objects correspond directly to 
  95.  * <code>CharacterData</code>, though <code>Text</code> and others do inherit 
  96.  * the interface from it. All <code>offset</code>s in this interface start 
  97.  * from 0, and index in terms of Unicode 16 bit storage units.
  98.  */
  99. class CDOM_EXPORT DOM_CharacterData: public DOM_Node {
  100. private:
  101. public:
  102.   /** @name Constructors and assignment operator */
  103.   //@{
  104.   /**
  105.     * Default constructor for DOM_CharacterData.  While there can be
  106.     * no actual DOM nodes of type CharacterData, the C++ objects
  107.     * function more like reference variables, and instances of
  108.     * <code>DOM_CharacterData</code> can exist.  They will be null when created
  109.     * by this constructor, and can then be assigned to refer to Text
  110.     * or CDATASection nodes.
  111.     */
  112.     DOM_CharacterData();
  113.   /**
  114.     * Copy constructor
  115.     *
  116.     * @param other The object to be copied
  117.     */
  118.     DOM_CharacterData(const DOM_CharacterData &other);
  119.   /**
  120.     * Assignment operator
  121.     *
  122.     * @param other The object to be copied
  123.     */
  124.     DOM_CharacterData & operator = (const DOM_CharacterData &other);
  125.     /**
  126.       * Assignment operator.  This overloaded variant is provided for
  127.       *   the sole purpose of setting a DOM_Node reference variable to
  128.       *   zero.  Nulling out a reference variable in this way will decrement
  129.       *   the reference count on the underlying Node object that the variable
  130.       *   formerly referenced.  This effect is normally obtained when reference
  131.       *   variable goes out of scope, but zeroing them can be useful for
  132.       *   global instances, or for local instances that will remain in scope
  133.       *   for an extended time,  when the storage belonging to the underlying
  134.       *   node needs to be reclaimed.
  135.       *
  136.       * @param val.  Only a value of 0, or null, is allowed.
  137.       */
  138.     DOM_CharacterData & operator = (const DOM_NullPtr *val);
  139.     //@}
  140.     /** @name Destructor. */
  141.     //@{
  142.  /**
  143.   * Destructor for DOM_CharacterData.  The object being destroyed
  144.       * is the reference to the Character Data node, not the character
  145.       * data itself.
  146.   */
  147.     ~DOM_CharacterData();
  148.     //@}
  149.     /** @name Getter functions. */
  150.     //@{
  151.   /**
  152.    * Returns the character data of the node that implements this interface. 
  153.    *
  154.    * The DOM implementation may not put arbitrary limits on the amount of data that 
  155.    * may be stored in a  <code>CharacterData</code> node. However, 
  156.    * implementation limits may  mean that the entirety of a node's data may 
  157.    * not fit into a single <code>DOMString</code>. In such cases, the user 
  158.    * may call <code>substringData</code> to retrieve the data in 
  159.    * appropriately sized pieces.
  160.    * @exception DOMException
  161.    *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  162.    * @exception DOMException
  163.    *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than 
  164.    *   fit in a <code>DOMString</code> variable on the implementation 
  165.    *   platform.
  166.    */
  167.   DOMString          getData() const;
  168.   /**
  169.    * Returns the number of characters that are available through <code>data</code> and 
  170.    * the <code>substringData</code> method below. 
  171.    *
  172.    * This may have the value 
  173.    * zero, i.e., <code>CharacterData</code> nodes may be empty.
  174.    */
  175.   unsigned int       getLength() const;
  176.   /**
  177.    * Extracts a range of data from the node.
  178.    *
  179.    * @param offset Start offset of substring to extract.
  180.    * @param count The number of characters to extract.
  181.    * @return The specified substring. If the sum of <code>offset</code> and 
  182.    *   <code>count</code> exceeds the <code>length</code>, then all 
  183.    *   characters to the end of the data are returned.
  184.    * @exception DOMException
  185.    *   INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 
  186.    *   than the number of characters in <code>data</code>, or if the 
  187.    *   specified <code>count</code> is negative.
  188.    *   <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not 
  189.    *   fit into a <code>DOMString</code>.
  190.    */
  191.   DOMString          substringData(unsigned int offset, 
  192.                                    unsigned int count) const;
  193.     //@}
  194.     /** @name Functions that set or change data. */
  195.     //@{
  196.   /**
  197.    * Append the string to the end of the character data of the node.
  198.    *
  199.    * Upon success, <code>data</code> provides access to the concatenation of 
  200.    * <code>data</code> and the <code>DOMString</code> specified.
  201.    * @param arg The <code>DOMString</code> to append.
  202.    * @exception DOMException
  203.    *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  204.    */
  205.   void               appendData(const DOMString &arg);
  206.   /**
  207.    * Insert a string at the specified character offset.
  208.    *
  209.    * @param offset The character offset at which to insert.
  210.    * @param arg The <code>DOMString</code> to insert.
  211.    * @exception DOMException
  212.    *   INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 
  213.    *   than the number of characters in <code>data</code>.
  214.    *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  215.    */
  216.   void               insertData(unsigned int offset, const  DOMString &arg);
  217.   /**
  218.    * Remove a range of characters from the node. 
  219.    *
  220.    * Upon success, 
  221.    * <code>data</code> and <code>length</code> reflect the change.
  222.    * @param offset The offset from which to remove characters.
  223.    * @param count The number of characters to delete. If the sum of 
  224.    *   <code>offset</code> and <code>count</code> exceeds <code>length</code> 
  225.    *   then all characters from <code>offset</code> to the end of the data 
  226.    *   are deleted.
  227.    * @exception DOMException
  228.    *   INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 
  229.    *   than the number of characters in <code>data</code>, or if the 
  230.    *   specified <code>count</code> is negative.
  231.    *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  232.    */
  233.   void               deleteData(unsigned int offset, 
  234.                                 unsigned int count);
  235.   /**
  236.    * Replace the characters starting at the specified character offset with 
  237.    * the specified string.
  238.    *
  239.    * @param offset The offset from which to start replacing.
  240.    * @param count The number of characters to replace. If the sum of 
  241.    *   <code>offset</code> and <code>count</code> exceeds <code>length</code>
  242.    *   , then all characters to the end of the data are replaced (i.e., the 
  243.    *   effect is the same as a <code>remove</code> method call with the same 
  244.    *   range, followed by an <code>append</code> method invocation).
  245.    * @param arg The <code>DOMString</code> with which the range must be 
  246.    *   replaced.
  247.    * @exception DOMException
  248.    *   INDEX_SIZE_ERR: Raised if the specified offset is negative or greater 
  249.    *   than the number of characters in <code>data</code>, or if the 
  250.    *   specified <code>count</code> is negative.
  251.    *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  252.    */
  253.   void               replaceData(unsigned int offset, 
  254.                                  unsigned int count, 
  255.                                  const DOMString &arg);
  256.   /**
  257.    * Sets the character data of the node that implements this interface. 
  258.    *
  259.    * @param data The <code>DOMString</code> to set.
  260.    */
  261.   void               setData(const DOMString &data);
  262.   //@}
  263. protected:
  264.     DOM_CharacterData(CharacterDataImpl *impl);
  265. };
  266. #endif