📄 kissdom.h
字号:
/* Copyright (C) 2000-2004 Code contributed by Greg Collecutt, Joseph Hope and Paul Cochrane This file is part of xmds. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*//* $Id: kissdom.h,v 1.11 2004/07/13 07:24:10 paultcochrane Exp $*//*! @file kissdom.h @brief Greg Collecutt's implementation of DOM3 Greg Collecutt's implementation of the XML Document Object Model level 3*//* This header file provides the definition of my implementation DOM3, called "kiss", which of course is the acronym for "Keep It Simple Stupid". */#ifndef LIST#include<list>#define LIST#endif#ifndef DOM3#include<dom3.h>#endif// *****************************************************************************// *****************************************************************************// KissDOMImplementation// *****************************************************************************// *****************************************************************************//! Implementation of the KISS version of DOMclass KissDOMImplementation : public DOMImplementation {public : //! Constructor of a KissDOMImplementation object KissDOMImplementation(); //! Destructor virtual ~KissDOMImplementation(); //! Determines if feature exists in this version bool hasFeature( DOMString& feature, DOMString& version) const; // Introduced in DOM Level 2: //! Creates a document type DocumentType* createDocumentType( const DOMString& qualifiedName, const DOMString& publicId, const DOMString& systemId); //! Creates a document Document* createDocument( const DOMString& namespaceURI, const DOMString& qualifiedName, DocumentType* doctype); // Introduced in DOM Level 3: //! Makes available DOMImplementation's specialised interface DOMImplementation* getAs( DOMString& feature); //! Prints all nodes void printAll(); //! Prints a node void printNode( const unsigned long& indent, const Node* node2Print);private : list<Node*> myNodeList; //!< The node list};// ******************************************************************************// ******************************************************************************// KissNodeList// ******************************************************************************// ******************************************************************************//! Node list class in KISS DOM implementationclass KissNodeList : public NodeList {public : //! Constructor of KissNodeList object KissNodeList( const list<Node*>* yourPNodeList); //! Destructor virtual ~KissNodeList(); //! Obtains item in node list at index Node* item( unsigned long index) const; //! Returns the length of the node list unsigned long length() const; private : const list<Node*>* myPNodeList; //!< Node list pointer (I think)};// ******************************************************************************// ******************************************************************************// KissNamedNodeMap// ******************************************************************************// ******************************************************************************//! The named node map class in the KISS DOM implementationclass KissNamedNodeMap : public NamedNodeMap {public: //! Constructor for KissNamedNodeMap object KissNamedNodeMap( const unsigned long& yourNodeType); //! Destructor virtual ~KissNamedNodeMap(); //! Gets a named item Node* getNamedItem( const DOMString& name) const ; //! Sets a named item Node* setNamedItem( Node& arg); //! Removes a named item Node* removeNamedItem( const DOMString& name); //! Returns the length (of what?) unsigned long length() const; //! Gets an item as a node object Node* item( const unsigned long index) const; // Introduced in DOM Level 2: //! Gets a named item namespace Node* getNamedItemNS( const DOMString& namespaceURI, const DOMString& localname) const; //! Sets a named item namespace Node* setNamedItemNS( Node& arg); //! Removes a named item namespace Node* removeNamedItemNS( const DOMString& namespaceURI, const DOMString& localname); //! Sets document readonly void setReadOnly( const bool& newReadOnly); //! Gets the owner document as a Document object const Document* ownerDocument() const; //! Sets the owner document void setOwnerDocument( const Document* yourOwnerDocument);private : const Document* myOwnerDocument; //!< The owner document object const unsigned long myNodeType; //!< The node type bool readOnly; //!< Whether or not the document is read only list<Node*> myNodeList; //!< The list of nodes list<const DOMString*> myNameList; //!< The list of names (of what?) list<const DOMString*> myNamespaceURIList; //!< The list of namespace URIs //! Whether or not can add this node (but why doesn't this return anything?) void canAddThisNode(const Node& arg) const;};// ******************************************************************************// ******************************************************************************// KissNode// ******************************************************************************// ******************************************************************************//! Node class in KISS DOM implementationclass KissNode : public virtual Node {public : //! Constructor of KissNode object KissNode( const Document *const yourOwnerDocument, Node *const yourParentNode, const DOMString& yourNodeName); //! Destructor ~KissNode(); //! Returns name of node const DOMString* nodeName() const; //! Returns value of node const DOMString* nodeValue() const; //! Sets value of node virtual void setNodeValue( const DOMString& newNodeValue); //! Returns parent node Node* parentNode() const; //! Sets parent node virtual void setParentNode( Node* newParentNode); //! Returns a list of child nodes const NodeList* childNodes() const; //! Returns the first child node Node* firstChild() const; //! Returns the last child node Node* lastChild() const; //! Returns the previous sibling node Node* previousSibling() const; //! Returns the next sibling node Node* nextSibling() const; //! Returns the attributes as a NamedNodeMap const NamedNodeMap* attributes() const; //! Returns the owner document const Document* ownerDocument() const; //! Sets the owner document virtual void setOwnerDocument( const Document *const newOwnerDocument); //! Inserts a new child node before a reference child node Node* insertBefore( Node* newChild, Node* refChild); //! Replaces a child node Node* replaceChild( Node* newChild, Node* oldChild); //! Removes a child node Node* removeChild( Node* oldChild); //! Appends a child node Node* appendChild( Node* newChild); //! Determines if object has child nodes bool hasChildNodes() const; //! Puts nodes into a normal form void normalize(); // Introduced in DOM Level 2: //! Determines if feature is supported in current version of xml/dom? bool isSupported( DOMString& feature, DOMString& version) const; //! Gets the namespace URI as a DOMString const DOMString* namespaceURI() const; //! Gets some prefix (of what?) const DOMString* prefix() const; //! Sets the prefix (of what?) void setPrefix( const DOMString& newPrefix); //! Gets the local name (of what?) const DOMString* localName() const; // Introduced in DOM Level 3: //! Determines if object/element has attributes bool hasAttributes() const; //! Returns the base URI as a DOMString const DOMString* baseURI() const; //! Compares the document order with another node DocumentOrder compareDocumentOrder( const Node* other) const; //! Compares the tree position with another node TreePosition compareTreePosition( const Node* other) const; //! Returns the text content of this node and its decendants const DOMString* textContent( const bool& deep) const; //! Sets the text content (of what?) virtual void setTextContent( const DOMString& newTextContent); //! Determines if the current node is the same as argument node bool isSameNode( const Node* other) const; //! Looks up namespace prefix and returns as DOMString const DOMString* lookupNamespacePrefix( const DOMString& namespaceURI) const; //! Looks up namespace URI and returns as DOMString const DOMString* lookupNamespaceURI( const DOMString& prefix) const; //! Puts the namespace into a normal form void normalizeNS(); //! Returns a key identifying this node DOMKey key() const; //! Determines if node is equal to argument node bool equalsNode( const Node* arg, bool deep) const; //! Gets the node's specialised interface Node* getAs( DOMString& feature); //! Determines if (something) is read only bool readOnly() const; //! Sets something read only void setReadOnly( const bool& newReadOnly, const bool& deep); //! Checks the child adding constraints void checkChildAddingConstraints1( const Node* newChild) const; //! Checks the child adding constraints virtual void checkChildAddingConstraints2( const Node* newChild) const;protected : DOMString myNodeName; //!< The current node as a DOMString bool myReadOnly; //!< The read only status of the node/document?private : const Document* myOwnerDocument; //!< The owner document Node* myParentNode; //!< The parent of the current node DOMKey myDOMKey; //!< The DOM key list<Node*> myNodeList; //!< The node list KissNodeList myKissNodeList; //!< The Kiss node list mutable DOMString myTextContent; //!< The text content of the node};// ******************************************************************************// ******************************************************************************// KissDocument// ******************************************************************************// ******************************************************************************//! Document class for the KISS DOM implementationclass KissDocument : public KissNode, public Document {public : //! Override of KissNode::nodeType() unsigned long nodeType() const; //! Override of KissNode::setParentNode() void setParentNode( Node* newParentNode); //! Override of KissNode::setOwnerDocument() void setOwnerDocument( const Document *const newOwnerDocument); //! Override of KissNode::insertBefore() Node* insertBefore( Node* newChild, Node* refChild); //! Override of KissNode::replaceChild() Node* replaceChild( Node* newChild, Node* oldChild); //! Override of KissNode::removeChild() Node* removeChild( Node* oldChild); //! Override of KissNode::appendChild() Node* appendChild( Node* newChild); //! Implementation of Node::cloneNode() Node* cloneNode( const bool& deep) const; //! Override of KissNode::namespaceURI() const DOMString* namespaceURI() const; //! Override of KissNode::compareDocumentOrder() DocumentOrder compareDocumentOrder( const Node* other) const; //! Override of KissNode::compareTreePosition() TreePosition compareTreePosition( const Node* other) const; //! Override of KissNode::setTextContent() void setTextContent( const DOMString& newTextContent); //! Override of KissNode::normalizeNS() void normalizeNS(); //! Override of KissNode::checkChildAddingConstraints2() void checkChildAddingConstraints2(const Node* newChild) const; //! Constructor of KissDocument object KissDocument( const DOMImplementation* yourDOMImplementation); //! Destructor ~KissDocument(); //! Gets the DOM key DOMKey getDOMKey() const; //! Obtains the doctype const DocumentType* doctype() const; //! Obtains the DOM implementation const DOMImplementation* implementation() const; //! Obtains a document element Element* documentElement() const; //! Creates an element Element* createElement( const DOMString& tagName); //! Creates a document fragment DocumentFragment* createDocumentFragment();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -