You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ar...@locus.apache.org on 2000/06/23 00:19:46 UTC

cvs commit: xml-xerces/c/src/dom ChildAndParentNode.cpp ChildAndParentNode.hpp ParentNode.cpp ParentNode.hpp

aruna1      00/06/22 15:19:45

  Modified:    c/src/dom ChildAndParentNode.cpp ChildAndParentNode.hpp
                        ParentNode.cpp ParentNode.hpp
  Log:
  OS/2 related changes
  
  Revision  Changes    Path
  1.2       +7 -4      xml-xerces/c/src/dom/ChildAndParentNode.cpp
  
  Index: ChildAndParentNode.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/ChildAndParentNode.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChildAndParentNode.cpp	2000/04/27 02:52:42	1.1
  +++ ChildAndParentNode.cpp	2000/06/22 22:19:42	1.2
  @@ -64,7 +64,7 @@
   //
   
   /*
  - * $Id: ChildAndParentNode.cpp,v 1.1 2000/04/27 02:52:42 lehors Exp $
  + * $Id: ChildAndParentNode.cpp,v 1.2 2000/06/22 22:19:42 aruna1 Exp $
    */
   
   /**
  @@ -74,9 +74,12 @@
    */
   
   #include "ChildAndParentNode.hpp"
  +#include "DOM_DOMException.hpp"
  +#include "TextImpl.hpp"
  +#include "DocumentImpl.hpp"
   
   #define THIS_CLASS ChildAndParentNode
   #define PARENT_CLASS ChildNode
  -#include "ParentNode.cpp"
  -#undef THIS_CLASS
  -#undef PARENT_CLASS
  +
  +#include "CommonParentNode.cpp"
  +
  
  
  
  1.2       +7 -4      xml-xerces/c/src/dom/ChildAndParentNode.hpp
  
  Index: ChildAndParentNode.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/ChildAndParentNode.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChildAndParentNode.hpp	2000/04/27 02:52:42	1.1
  +++ ChildAndParentNode.hpp	2000/06/22 22:19:43	1.2
  @@ -67,7 +67,7 @@
   //
   
   /*
  - * $Id: ChildAndParentNode.hpp,v 1.1 2000/04/27 02:52:42 lehors Exp $
  + * $Id: ChildAndParentNode.hpp,v 1.2 2000/06/22 22:19:43 aruna1 Exp $
    */
   
   /**
  @@ -76,12 +76,15 @@
    * ChildNode and all the code of ParentNode is "duplicated" here
    */
   
  -#include "ParentNode.hpp"
   
  +#include <util/XercesDefs.hpp>
  +#include "ChildNode.hpp"
  +
   #define THIS_CLASS ChildAndParentNode
   #define PARENT_CLASS ChildNode
  -#undef ParentNode_HEADER_GUARD_
  -#include "ParentNode.hpp"
  +
  +#include "CommonParentNode.hpp"
  +
   #undef THIS_CLASS
   #undef PARENT_CLASS
   
  
  
  
  1.3       +3 -334    xml-xerces/c/src/dom/ParentNode.cpp
  
  Index: ParentNode.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/ParentNode.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParentNode.cpp	2000/04/28 00:31:45	1.2
  +++ ParentNode.cpp	2000/06/22 22:19:43	1.3
  @@ -55,348 +55,17 @@
    */
   
   /*
  - * $Id: ParentNode.cpp,v 1.2 2000/04/28 00:31:45 lehors Exp $
  + * $Id: ParentNode.cpp,v 1.3 2000/06/22 22:19:43 aruna1 Exp $
    */
   
   #include "ParentNode.hpp"
   #include "DOM_DOMException.hpp"
  -#include "DOM_Node.hpp"
  -#include "DOM_DOMImplementation.hpp"
  -#include "DOMString.hpp"
  -#include "DStringPool.hpp"
   #include "DocumentImpl.hpp"
  -#include "stdio.h"
   #include "TextImpl.hpp"
   
  -// these are redefined in ChildAndParentNode so that the code can be reused.
  -#ifndef THIS_CLASS
   #define THIS_CLASS ParentNode
  -#endif
  -#ifndef PARENT_CLASS
   #define PARENT_CLASS NodeImpl
  -#endif
   
  -THIS_CLASS::THIS_CLASS(DocumentImpl *ownerDoc)
  -    : PARENT_CLASS(ownerDoc)
  -{
  -    this->ownerDocument = ownerDoc;
  -    this->firstChild = null;
  +#include "CommonParentNode.cpp"
   
  -    fChanges = 0;
  -};  
  -
  -// This only makes a shallow copy, cloneChildren must also be called for a
  -// deep clone
  -THIS_CLASS::THIS_CLASS(const THIS_CLASS &other)
  -    : PARENT_CLASS(other)
  -{
  -    this->ownerDocument = other.ownerDocument;
  -
  -    // Need to break the association w/ original kids
  -    this->firstChild = null;
  -
  -    fChanges = 0;
  -};
  -
  -
  -void THIS_CLASS::cloneChildren(const NodeImpl &other) {    
  -  //    for (NodeImpl *mykid = other.getFirstChild(); 
  -    for (NodeImpl *mykid = ((NodeImpl&)other).getFirstChild(); 
  -         mykid != null; 
  -         mykid = mykid->getNextSibling()) {
  -        this->appendChild(mykid->cloneNode(true));
  -    }
  -}
  -
  -DocumentImpl * THIS_CLASS::getOwnerDocument() {
  -    return ownerDocument;
  -}
  -
  -// unlike getOwnerDocument this is not overriden by DocumentImpl to return null
  -DocumentImpl * THIS_CLASS::getDocument() {
  -    return ownerDocument;
  -}
  -
  -void THIS_CLASS::setOwnerDocument(DocumentImpl *doc) {
  -    ownerDocument = doc;
  -    for (NodeImpl *child = firstChild;
  -         child != null; child = child->getNextSibling()) {
  -        child->setOwnerDocument(doc);
  -    }
  -}
  -
  -
  -void THIS_CLASS::changed()
  -{
  -    ++fChanges;
  -    NodeImpl *parentNode = getParentNode();
  -    if (parentNode != null) {
  -        parentNode->changed();
  -    }
  -};  
  -
  -int THIS_CLASS::changes()
  -{
  -    return fChanges;
  -};  
  -
  -
  -NodeListImpl *THIS_CLASS::getChildNodes() {
  -    return this;
  -};
  -
  -
  -NodeImpl * THIS_CLASS::getFirstChild() {
  -    return firstChild;
  -}; 
  -
  -
  -NodeImpl * THIS_CLASS::getLastChild()
  -{
  -    return lastChild();
  -}; 
  -
  -ChildNode * THIS_CLASS::lastChild()
  -{
  -    // last child is stored as the previous sibling of first child
  -    return firstChild != null ? firstChild->previousSibling : null;
  -}; 
  -
  -void THIS_CLASS::lastChild(ChildNode *node) {
  -        // store lastChild as previous sibling of first child
  -        if (firstChild != null) {
  -            firstChild->previousSibling = node;
  -        }
  -    }
  -
  -
  -unsigned int THIS_CLASS::getLength() {
  -    unsigned int count = 0;
  -    ChildNode *node = firstChild;
  -    while(node != null)
  -    {
  -        ++count;
  -        node = node->nextSibling;
  -    }
  -    return count;
  -};
  -
  -
  -bool THIS_CLASS::hasChildNodes()
  -{ 
  -    return firstChild!=null;
  -}; 
  -
  -
  -
  -NodeImpl *THIS_CLASS::insertBefore(NodeImpl *newChild, NodeImpl *refChild) {
  -    if (readOnly())
  -        throw DOM_DOMException(
  -        DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
  -    
  -    if (newChild->getOwnerDocument() != ownerDocument)
  -        throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR, null);
  -    
  -    // Convert to internal type, to avoid repeated casting  
  -    ChildNode * newInternal= (ChildNode *)newChild;
  -    
  -    // Prevent cycles in the tree
  -    bool treeSafe=true;
  -    for(NodeImpl *a=this->getParentNode();
  -        treeSafe && a!=null;
  -        a=a->getParentNode())
  -        treeSafe=(newInternal!=a);
  -    if(!treeSafe)
  -        throw DOM_DOMException(DOM_DOMException::HIERARCHY_REQUEST_ERR,null);
  -    
  -    // refChild must in fact be a child of this node (or null)
  -    if (refChild!=null && refChild->getParentNode() != this)
  -        throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR,null);
  -    
  -    if (newInternal->isDocumentFragmentImpl())
  -    {
  -        // SLOW BUT SAFE: We could insert the whole subtree without
  -        // juggling so many next/previous pointers. (Wipe out the
  -        // parent's child-list, patch the parent pointers, set the
  -        // ends of the list.) But we know some subclasses have special-
  -        // case behavior they add to insertBefore(), so we don't risk it.
  -        // This approch also takes fewer bytecodes.
  -        
  -        // NOTE: If one of the children is not a legal child of this
  -        // node, throw HIERARCHY_REQUEST_ERR before _any_ of the children
  -        // have been transferred. (Alternative behaviors would be to
  -        // reparent up to the first failure point or reparent all those
  -        // which are acceptable to the target node, neither of which is
  -        // as robust. PR-DOM-0818 isn't entirely clear on which it
  -        // recommends?????
  -        
  -        // No need to check kids for right-document; if they weren't,
  -        // they wouldn't be kids of that DocFrag.
  -        for(NodeImpl *kid=newInternal->getFirstChild(); // Prescan
  -        kid!=null;
  -        kid=kid->getNextSibling())
  -        {
  -            if (!DocumentImpl::isKidOK(this, kid))
  -              throw DOM_DOMException(DOM_DOMException::HIERARCHY_REQUEST_ERR,null);
  -        }                       
  -        while(newInternal->hasChildNodes())     // Move
  -            insertBefore(newInternal->getFirstChild(),refChild);
  -    }
  -    
  -    else if (!DocumentImpl::isKidOK(this, newInternal))
  -        throw DOM_DOMException(DOM_DOMException::HIERARCHY_REQUEST_ERR,null);
  -    
  -    else
  -    {
  -        // Convert to internal type, to avoid repeated casting
  -        ChildNode *refInternal = (ChildNode *)refChild;
  -
  -        NodeImpl *oldparent=newInternal->getParentNode();
  -        if(oldparent!=null)
  -            oldparent->removeChild(newInternal);
  -        
  -        ChildNode *prev;
  -        // Find the node we're inserting after, if any (null if
  -        // inserting to head of list)
  -        prev = (refInternal == null)
  -            ? lastChild() : refInternal->previousSibling;
  -        
  -        // Attach up
  -        newInternal->ownerNode = this;
  -        newInternal->owned(true);
  -        
  -        // Attach after
  -        newInternal->previousSibling=prev;
  -        if (refInternal == firstChild) {
  -            firstChild = newInternal;
  -            newInternal->firstChild(true);
  -        } else {
  -            prev->nextSibling = newInternal;
  -        }
  -
  -        // Attach before
  -        newInternal->nextSibling = refInternal;
  -        if(refInternal == null) {
  -            // store lastChild as previous sibling of first child
  -            firstChild->previousSibling = newInternal;
  -        } else {
  -            refInternal->previousSibling = newInternal;
  -            refInternal->firstChild(true);
  -        }
  -    }
  -    changed();
  -
  -    return newInternal;
  -};
  -  
  -  
  -NodeImpl *THIS_CLASS::item(unsigned int index) {
  -    ChildNode *node = firstChild;
  -    for(unsigned int i=0; i<index && node!=null; ++i)
  -        node = node->nextSibling;
  -    return node;
  -};
  -  
  -  
  -NodeImpl *THIS_CLASS::removeChild(NodeImpl *oldChild) 
  -{
  -    if (readOnly())
  -        throw DOM_DOMException(
  -          DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
  -      
  -      if (oldChild != null && oldChild->getParentNode() != this)
  -          throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null);
  -
  -      ChildNode * oldInternal = (ChildNode *) oldChild;
  -
  -      // Patch tree past oldChild
  -      ChildNode *prev = oldInternal->previousSibling;
  -      ChildNode *next = oldInternal->nextSibling;
  -
  -      if (oldInternal != firstChild)
  -          prev->nextSibling = next;
  -      else {
  -          oldInternal->firstChild(false);
  -          firstChild = next;
  -          if (next != null) {
  -              next->firstChild(true);
  -          }
  -      }
  -
  -      if (next != null)         // oldInternal != lastChild
  -          next->previousSibling = prev;
  -      else {
  -          if (firstChild != null) {
  -              // store lastChild as previous sibling of first child
  -              firstChild->previousSibling = prev;
  -          }
  -      }
  -      
  -      // Remove oldChild's references to tree
  -      oldInternal->ownerNode = ownerDocument;
  -      oldInternal->owned(false);
  -      oldInternal->nextSibling = null;
  -      oldInternal->previousSibling = null;
  -
  -      changed();
  -
  -      return oldInternal;
  -};
  -  
  -  
  -NodeImpl *THIS_CLASS::replaceChild(NodeImpl *newChild, NodeImpl *oldChild)
  -{
  -    insertBefore(newChild, oldChild);
  -    // changed() already done.
  -    return removeChild(oldChild);
  -};
  -  
  -
  -void THIS_CLASS::setReadOnly(bool readOnl, bool deep)
  -{
  -    NodeImpl::setReadOnly(readOnl, deep);
  -      
  -    if (deep)
  -        // Recursively set kids
  -        for (ChildNode *mykid = firstChild; 
  -             mykid != null; 
  -             mykid = mykid->nextSibling)
  -            if(! (mykid->isEntityReference()))
  -                mykid->setReadOnly(readOnl,true);
  -};
  -  
  -  
  -//Introduced in DOM Level 2
  -  
  -void THIS_CLASS::normalize()
  -{
  -    ChildNode *kid, *next;
  -    for (kid = firstChild; kid != null; kid = next)
  -    {
  -        next = kid->nextSibling;
  -        
  -        // If kid and next are both Text nodes (but _not_ CDATASection,
  -        // which is a subclass of Text), they can be merged.
  -        if (next != null && 
  -            kid->isTextImpl()   && !(kid->isCDATASectionImpl())  && 
  -            next->isTextImpl()  && !(next->isCDATASectionImpl()) )
  -        {
  -            ((TextImpl *) kid)->appendData(((TextImpl *) next)->getData());
  -            removeChild(next);
  -            if (next->nodeRefCount == 0)
  -                deleteIf(next);
  -            next = kid; // Don't advance; there might be another.
  -        }
  -        
  -        // Otherwise it might be an Element, which is handled recursively  
  -        else
  -            if (kid->isElementImpl())
  -                kid->normalize();
  -    };
  -    
  -    // changed() will have occurred when the removeChild() was done,
  -    // so does not have to be reissued.
  -};
  -
  -#undef THIS_CLASS
  -#undef PARENT_CLASS
  + 
  \ No newline at end of file
  
  
  
  1.3       +5 -50     xml-xerces/c/src/dom/ParentNode.hpp
  
  Index: ParentNode.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/ParentNode.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParentNode.hpp	2000/04/28 00:31:45	1.2
  +++ ParentNode.hpp	2000/06/22 22:19:43	1.3
  @@ -1,6 +1,3 @@
  -#ifndef ParentNode_HEADER_GUARD_
  -#define ParentNode_HEADER_GUARD_
  -
   /*
    * The Apache Software License, Version 1.1
    * 
  @@ -67,7 +64,7 @@
   //
   
   /*
  - * $Id: ParentNode.hpp,v 1.2 2000/04/28 00:31:45 lehors Exp $
  + * $Id: ParentNode.hpp,v 1.3 2000/06/22 22:19:43 aruna1 Exp $
    */
   
   /**
  @@ -80,60 +77,18 @@
    * marked as being so, and getNextSibling hides this fact.
    *
    **/
  +#ifndef ParentNode_HEADER_GUARD_
  +#define ParentNode_HEADER_GUARD_
   
   #include <util/XercesDefs.hpp>
   #include "ChildNode.hpp"
  -#include "DOMString.hpp"
   
  -// these are redefined in ChildAndParentNode so that the code can be reused.
  -#ifndef THIS_CLASS
   #define THIS_CLASS ParentNode
  -#endif
  -#ifndef PARENT_CLASS
   #define PARENT_CLASS NodeImpl
  -#endif
   
  -class CDOM_EXPORT THIS_CLASS: public PARENT_CLASS {
  -public:
  -    DocumentImpl            *ownerDocument; // Document this node belongs to
  -
  -    ChildNode                *firstChild;
  -
  -    int fChanges;
  -
  -public:
  -    THIS_CLASS(DocumentImpl *ownerDocument);
  -    THIS_CLASS(const THIS_CLASS &other);
  -    
  -    virtual DocumentImpl * getOwnerDocument();
  -    virtual void setOwnerDocument(DocumentImpl *doc);
  -
  -    virtual int changes();
  -    virtual void changed();
  -
  -    virtual NodeListImpl *getChildNodes();
  -    virtual NodeImpl * getFirstChild();
  -    virtual NodeImpl * getLastChild();
  -    virtual unsigned int getLength();
  -    virtual bool        hasChildNodes();
  -    virtual NodeImpl    *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
  -    virtual NodeImpl    *item(unsigned int index);
  -    virtual NodeImpl    * removeChild(NodeImpl *oldChild);
  -    virtual NodeImpl    *replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
  -    virtual void        setReadOnly(bool readOnly, bool deep);
  -
  -    //Introduced in DOM Level 2
  -    virtual void	normalize();
  -
  -    // NON-DOM
  -    // unlike getOwnerDocument this never returns null, even for Document nodes
  -    virtual DocumentImpl * getDocument();
  -protected:
  -    void cloneChildren(const NodeImpl &other);
  -    ChildNode * lastChild();
  -    void lastChild(ChildNode *);
  -};
  +#include "CommonParentNode.hpp"
   
   #undef THIS_CLASS
   #undef PARENT_CLASS
  +
   #endif