Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:12

0001 // Created on: 2001-06-26
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 //AGV 120202: Replace myDocument for myPtrDocument for better
0017 //                          consistency of data
0018 
0019 #ifndef LDOM_Node_HeaderFile
0020 #define LDOM_Node_HeaderFile
0021 
0022 #include <LDOMString.hxx>
0023 #include <LDOM_MemManager.hxx>
0024 
0025 class LDOM_BasicNode;
0026 
0027 //  LDOM_Node : base class for LDOM interface objects
0028 //              references LDOM_BasicNode - the real data stored in Document
0029 //  This type can be safely cast to any derived type, e.g. :
0030 //         LDOM_Node aNode          = MyGetElementNode();
0031 //         LDOM_Element& anElemNode = (LDOM_Element&) aNode;
0032 //         LDOMString anXcoord      = anElemNode.getAtttribute("x");
0033 
0034 class LDOM_Node
0035 {
0036  public:
0037   enum NodeType {
0038     UNKNOWN             = 0,
0039     ELEMENT_NODE        = 1,
0040     ATTRIBUTE_NODE      = 2,
0041     TEXT_NODE           = 3,
0042     CDATA_SECTION_NODE  = 4,
0043     COMMENT_NODE        = 8
0044     };
0045 
0046   // ---------- PUBLIC METHODS ----------
0047 
0048   LDOM_Node () : myOrigin        (NULL),
0049                  myLastChild     (NULL) {}
0050   //    Empty constructor
0051 
0052   LDOM_Node (const LDOM_Node& anOther)
0053     : myDocument        (anOther.myDocument),
0054       myOrigin          (anOther.myOrigin),
0055       myLastChild       (anOther.myLastChild) {}
0056   //    Copy constructor
0057 
0058   Standard_EXPORT const LDOM_MemManager& getOwnerDocument () const;
0059 
0060   Standard_EXPORT LDOM_Node&
0061                         operator =      (const LDOM_Node& anOther);
0062 
0063   Standard_EXPORT LDOM_Node&
0064                         operator =      (const LDOM_NullPtr * aNull); 
0065 
0066   Standard_Boolean      operator ==     (const LDOM_NullPtr *) const
0067                                         { return isNull(); }
0068 
0069   Standard_Boolean      operator !=     (const LDOM_NullPtr *) const
0070                                         { return ! isNull(); }
0071 
0072   Standard_EXPORT Standard_Boolean
0073                         operator ==     (const LDOM_Node& anOther) const;
0074 
0075   Standard_EXPORT Standard_Boolean
0076                         operator !=     (const LDOM_Node& anOther) const;
0077 
0078   Standard_EXPORT Standard_Boolean
0079                         isNull          () const;
0080 
0081   Standard_EXPORT NodeType
0082                         getNodeType     () const;
0083 
0084   Standard_EXPORT LDOMString
0085                         getNodeName     () const;
0086 
0087   Standard_EXPORT LDOMString
0088                         getNodeValue     () const;
0089 
0090   Standard_EXPORT LDOM_Node
0091                         getFirstChild   () const;
0092 
0093   Standard_EXPORT LDOM_Node
0094                         getLastChild   () const;
0095 
0096   Standard_EXPORT LDOM_Node
0097                         getNextSibling  () const;
0098 
0099   Standard_EXPORT void  removeChild     (const LDOM_Node& aChild);
0100 
0101   Standard_EXPORT void  appendChild     (const LDOM_Node& aChild);
0102 
0103   Standard_EXPORT Standard_Boolean
0104                         hasChildNodes   () const;
0105 
0106   Standard_EXPORT void  SetValueClear   () const;
0107   //    Avoids checking for '<', '&', '\'', '\"', etc. on storage (saves time)
0108   //    You MUST be pretty sure that the node value string is OK in this sense
0109   //    NEVER call this method if you are not stuck on the performance 
0110 
0111  protected:
0112 friend class LDOM_BasicAttribute;
0113 friend class LDOM_BasicElement;
0114 friend class LDOM_BasicText;
0115 friend class LDOM_NodeList;
0116   // ---------- PROTECTED METHODS ----------
0117 
0118   const LDOM_BasicNode& Origin          () const;
0119 
0120   LDOM_Node (const LDOM_BasicNode& anOrig, const Handle(LDOM_MemManager)& aDoc)
0121     : myDocument        (aDoc),
0122       myOrigin          ((LDOM_BasicNode *) &anOrig),
0123       myLastChild       (NULL) {}
0124   //    Copy constructor with assignment to Document
0125 
0126  protected:
0127   // ---------- PROTECTED FIELDS ----------
0128 
0129         // smart pointer to document owner of the node
0130   Handle(LDOM_MemManager)       myDocument;
0131 
0132         // pointer to (non-transient) node data in the document-managed memory
0133   LDOM_BasicNode                * myOrigin;
0134 
0135         // Transient data (only applicable to LDOM_Element type):
0136         // the last child; myLastChild->mySibling points to the first attribute
0137   const LDOM_BasicNode          * myLastChild;
0138 
0139   friend char * db_pretty_print (const LDOM_Node *, int, char *);
0140 };
0141 
0142 #endif