Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsNode.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dsNode.h,v 1.7 2003/08/27 15:40:41 dsamersoff Exp $
00003  */
00004 #ifndef dsNode_h
00005 #define dsNode_h
00006 
00007 #include <list>
00008 
00009 #include <dsSmartException.h>
00010 #include <dsutil.h>
00011 
00012 DECLARE_EXCEPTION(dsDOM);
00013 
00014 class dsDocument;
00015 class dsNode;
00016 class dsXMLParser;
00017 
00018 typedef char *DOMString;
00019 
00020 typedef std::list<dsNode *> dsNodeList;
00021 
00022 #include <dsNamedNodeMap.h>
00023 
00024 class dsXMLParserException : public dsDOMException
00025 {
00026     int _lineno;
00027 
00028 public:
00029     dsXMLParserException(int x_lineno, const char *format, ... )
00030     { 
00031          _lineno = x_lineno;
00032          va_list ap; 
00033          va_start(ap, format); 
00034          fire( (char *) format, ap); 
00035          va_end(ap); 
00036      }
00037 
00038 
00039     
00040     std::ostream& print(std::ostream& os)
00041      {
00042           os << tag() << ':' << _lineno << '#' << msg() << std::endl;
00043           return os;
00044      }
00045 };
00046 
00047 
00048 class dsNode 
00049 {
00050 public:
00051   enum dsNodeTypes{ EMPTY_NODE = 0, ELEMENT_NODE = 1, ATTRIBUTE_NODE = 2, TEXT_NODE = 3,
00052                   CDATA_SECTION_NODE = 4, ENTITY_REFERENCE_NODE = 5,
00053                   ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = 7,
00054                   COMMENT_NODE = 8, DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = 10,
00055                   DOCUMENT_FRAGMENT_NODE = 11, NOTATION_NODE = 12 };
00056 
00057  
00058  protected:
00059   DOMString _nodeName;
00060   DOMString _nodeValue;
00061 
00062   dsNodeTypes  _nodeType;
00063   dsNode*      _parentNode;
00064     
00065   dsNode*      _firstChild;
00066   dsNode*      _lastChild;
00067   dsNode*      _previousSibling;
00068   dsNode*      _nextSibling;
00069 
00070   dsDocument* _ownerDocument;
00071 
00072   DOMString _namespaceURI;
00073 
00074 
00075   /* Internals */
00076   void setNodeName(DOMString newone);
00077 
00078   dsNode(dsDocument* owner, dsNodeTypes type);
00079   dsNode(dsDocument* owner, DOMString name, dsNodeTypes type);
00080   dsNode();
00081 public:
00082   ~dsNode();
00083 
00084 public:
00085 
00086   dsNode*     insertBefore (dsNode* newChild, dsNode* refChild);
00087   dsNode*     replaceChild (dsNode* newChild, dsNode* oldChild);
00088   dsNode*     removeChild  (dsNode* oldChild);
00089   dsNode*     appendChild  (dsNode* newChild);
00090 
00091   bool*       hasChildNodes();
00092   dsNode*     cloneNode(bool deep);
00093   void        normalize();
00094   bool        isSupported(DOMString feature, DOMString version);
00095   
00096   
00097   
00098 
00099     /* interface functions */
00100 
00101       /* namespace support */
00102       DOMString prefix();
00103       DOMString localName();
00104 
00105 
00106       bool   hasAttributes();
00107       dsNamedNodeMap attributes();
00108       dsNodeList*    childNodes();
00109 
00110 
00111        DOMString nodeName()         { return _nodeName;   }
00112        DOMString nodeValue()        { return _nodeValue;  }
00113        dsNodeTypes nodeType()         { return _nodeType;   }
00114        dsNode*     parentNode()       { return _parentNode; }
00115 
00116        dsNode*     firstChild()       { return _firstChild; }
00117        dsNode*     lastChild()        { return _lastChild; }
00118        dsNode*     previousSibling()  { return _previousSibling; }
00119        dsNode*     nextSibling()      { return _nextSibling; }
00120        
00121        dsDocument* ownerDocument(){ return _ownerDocument; }
00122 
00123        void setNodeValue(DOMString value);
00124 
00125 
00126     /* extensions */
00127     bool isTextNode()     { return _nodeType == TEXT_NODE; }
00128     bool isAttrNode()     { return _nodeType == ATTRIBUTE_NODE; }
00129     bool isElementNode()  { return _nodeType == ELEMENT_NODE; }
00130     bool isDocumentNode() { return _nodeType == DOCUMENT_NODE; }
00131     bool isCommentNode()  { return _nodeType == COMMENT_NODE; }
00132     bool isProcessingInstructionNode() { return _nodeType == PROCESSING_INSTRUCTION_NODE; }
00133 
00134     friend class dsXMLParser;
00135     friend class dsAttr; // to clean namespaceURI on attr deletion
00136     friend class dsElement; // to perform correct Attr creation
00137     friend class dsDocument; // strange ??? 
00138 
00139 protected:
00140 /* internals */
00141     /* remove oldChild and return it or 0 */
00142     dsNode *__removeChildIfExists(dsNode *oldChild);
00143 
00144     /* find direct child like oldChild and retrn it or 0 */
00145     dsNode *__checkDirectChild(dsNode *oldChild);
00146     dsNode *__fastAppendChild(dsNode *newChild);
00147     void __checkReadOnly(); 
00148 };
00149 
00150 
00151 
00152 #endif

Generated on Mon May 16 18:26:58 2005 for libdms4 by doxygen1.3-rc2