Source: dom/dom_text.h

# Source: dom/dom_text.h |
Annotated List
Files
Globals
Hierarchy
Index

    /*
     * This file is part of the DOM implementation for KDE.
     *
     * (C) 1999 Lars Knoll (knoll@kde.org)
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Library General Public
     * License as published by the Free Software Foundation; either
     * version 2 of the License, or (at your option) any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * Library General Public License for more details.
     *
     * You should have received a copy of the GNU Library General Public License
     * along with this library; see the file COPYING.LIB.  If not, write to
     * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     * Boston, MA 02111-1307, USA.
     *
     * This file includes excerpts from the Document Object Model (DOM)
     * Level 1 Specification (Recommendation)
     * http://www.w3.org/TR/REC-DOM-Level-1/
     * Copyright © World Wide Web Consortium , (Massachusetts Institute of
     * Technology , Institut National de Recherche en Informatique et en
     * Automatique , Keio University ). All Rights Reserved.
     *
     * $Id: dom_text.h,v 1.9.12.1 2003/05/18 12:34:37 mueller Exp $
     */
    #ifndef _DOM_CharacterData_h_
    #define _DOM_CharacterData_h_

    #include

    namespace DOM {

    class DOMString;
    class CharacterDataImpl;

    /**
     * The  CharacterData  interface extends Node with a set
     * of attributes and methods for accessing character data in the DOM.
     * For clarity this set is defined here rather than on each object
     * that uses these attributes and methods. No DOM objects correspond
     * directly to  CharacterData  , though  Text
     *  and others do inherit the interface from it. All
     * offsets in this interface start from 0.
     *
     */
    class CharacterData : public Node
    {
    public:
        CharacterData();
        CharacterData(const CharacterData &other);
        CharacterData(const Node &other) : Node()
             {(*this)=other;}

        CharacterData & operator = (const Node &other);
        CharacterData & operator = (const CharacterData &other);

        ~CharacterData();

        /**
         * The character data of the node that implements this interface.
         * The DOM implementation may not put arbitrary limits on the
         * amount of data that may be stored in a  CharacterData
         *  node. However, implementation limits may mean that the
         * entirety of a node's data may not fit into a single
         * DOMString  . In such cases, the user may call
         * substringData  to retrieve the data in appropriately
         * sized pieces.
         *
         * @exception DOMException
         * DOMSTRING_SIZE_ERR: Raised when it would return more characters
         * than fit in a  DOMString  variable on the
         * implementation platform.
         *
         */
        DOMString data() const;

        /**
         * see @ref data
         * @exception DOMException
         * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
         *
         */
        void setData( const DOMString & );

        /**
         * The number of characters that are available through  data
         *  and the  substringData  method below. This
         * may have the value zero, i.e.,  CharacterData
         * nodes may be empty.
         *
         */
        unsigned long length() const;

        /**
         * Extracts a range of data from the node.
         *
         * @param offset Start offset of substring to extract.
         *
         * @param count The number of characters to extract.
         *
         * @return The specified substring. If the sum of  offset
         *  and  count  exceeds the  length
         *  , then all characters to the end of the data are
         * returned.
         *
         * @exception DOMException
         * INDEX_SIZE_ERR: Raised if the specified offset is negative or
         * greater than the number of characters in  data  ,
         * or if the specified  count  is negative.
         *
         *  DOMSTRING_SIZE_ERR: Raised if the specified range of text does
         * not fit into a  DOMString  .
         *
         */
        DOMString substringData ( const unsigned long offset, const unsigned long count );

        /**
         * Append the string to the end of the character data of the node.
         * Upon success,  data  provides access to the
         * concatenation of  data  and the  DOMString
         *  specified.
         *
         * @param arg The  DOMString  to append.
         *
         * @return
         *
         * @exception DOMException
         * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
         *
         */
        void appendData ( const DOMString &arg );

        /**
         * Insert a string at the specified character offset.
         *
         * @param offset The character offset at which to insert.
         *
         * @param arg The  DOMString  to insert.
         *
         * @return
         *
         * @exception DOMException
         * INDEX_SIZE_ERR: Raised if the specified offset is negative or
         * greater than the number of characters in  data  .
         *
         *  NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
         *
         */
        void insertData ( const unsigned long offset, const DOMString &arg );

        /**
         * Remove a range of characters from the node. Upon success,
         *  data  and  length  reflect the
         * change.
         *
         * @param offset The offset from which to remove characters.
         *
         * @param count The number of characters to delete. If the sum of
         *  offset  and  count  exceeds
         * length  then all characters from  offset
         * to the end of the data are deleted.
         *
         * @return
         *
         * @exception DOMException
         * INDEX_SIZE_ERR: Raised if the specified offset is negative or
         * greater than the number of characters in  data  ,
         * or if the specified  count  is negative.
         *
         *  NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
         *
         */
        void deleteData ( const unsigned long offset, const unsigned long count );

        /**
         * Replace the characters starting at the specified character
         * offset with the specified string.
         *
         * @param offset The offset from which to start replacing.
         *
         * @param count The number of characters to replace. If the sum of
         *  offset  and  count  exceeds
         * length  , then all characters to the end of the data are
         * replaced (i.e., the effect is the same as a  remove
         *  method call with the same range, followed by an
         * append  method invocation).
         *
         * @param arg The  DOMString  with which the range
         * must be replaced.
         *
         * @return
         *
         * @exception DOMException
         * INDEX_SIZE_ERR: Raised if the specified offset is negative or
         * greater than the number of characters in  data  ,
         * or if the specified  count  is negative.
         *
         *  NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
         *
         */
        void replaceData ( const unsigned long offset, const unsigned long count, const DOMString &arg );

    protected:
        CharacterData(CharacterDataImpl *i);
    };

    class CommentImpl;

    /**
     * This represents the content of a comment, i.e., all the characters
     * between the starting '  <!--  ' and ending '
     * -->  '. Note that this is the definition of a comment in
     * XML, and, in practice, HTML, although some HTML tools may implement
     * the full SGML comment structure.
     *
     */
    class Comment : public CharacterData
    {
        friend class Document;

    public:
        Comment();
        Comment(const Comment &other);
        Comment(const Node &other) : CharacterData()
             {(*this)=other;}

        Comment & operator = (const Node &other);
        Comment & operator = (const Comment &other);

        ~Comment();

    protected:
        Comment(CommentImpl *i);
    };

    class TextImpl;

    /**
     * The  Text  interface represents the textual content
     * (termed  character data  in XML) of
     * an  Element  or  Attr  . If there is no
     * markup inside an element's content, the text is contained in a
     * single object implementing the  Text  interface that
     * is the only child of the element. If there is markup, it is parsed
     * into a list of elements and  Text  nodes that form the
     * list of children of the element.
     *
     *  When a document is first made available via the DOM, there is only
     * one  Text  node for each block of text. Users may
     * create adjacent  Text  nodes that represent the
     * contents of a given element without any intervening markup, but
     * should be aware that there is no way to represent the separations
     * between these nodes in XML or HTML, so they will not (in general)
     * persist between DOM editing sessions. The  normalize()
     *  method on  Element  merges any such adjacent
     *  Text  objects into a single node for each block of
     * text; this is recommended before employing operations that depend
     * on a particular document structure, such as navigation with
     * XPointers.
     *
     */
    class Text : public CharacterData
    {
        friend class Document;

    public:
        Text();
        Text(const Text &other);
        Text(const Node &other) : CharacterData()
             {(*this)=other;}

        Text & operator = (const Node &other);
        Text & operator = (const Text &other);

        ~Text();

        /**
         * Breaks this  Text  node into two Text nodes at the
         * specified offset, keeping both in the tree as siblings. This
         * node then only contains all the content up to the  offset
         *  point. And a new  Text  node, which is
         * inserted as the next sibling of this node, contains all the
         * content at and after the  offset  point.
         *
         * @param offset The offset at which to split, starting from 0.
         *
         * @return The new  Text  node.
         *
         * @exception DOMException
         * INDEX_SIZE_ERR: Raised if the specified offset is negative or
         * greater than the number of characters in  data  .
         *
         *  NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
         *
         */
        Text splitText ( const unsigned long offset );

    protected:
        Text(TextImpl *i);

    };

    } //namespace
    #endif

Generated by: root on macppc.ports.openbsd.org on Sat Sep 6 10:37:43 2003, using kdoc 2.0a54.