Code

Added an #undef for SEVERITY_ERROR, which conflicts with a Win32 macro
[inkscape.git] / src / dom / dom.h
1 #ifndef __DOM_H__
2 #define __DOM_H__
3 /**
4  * Phoebe DOM Implementation.
5  *
6  * This is a C++ approximation of the W3C DOM model, which follows
7  * fairly closely the specifications in the various .idl files, copies of
8  * which are provided for reference.  Most important is this one:
9  *
10  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11  *
12  * Authors:
13  *   Bob Jamison
14  *
15  * Copyright (C) 2006 Bob Jamison
16  *
17  *  This library is free software; you can redistribute it and/or
18  *  modify it under the terms of the GNU Lesser General Public
19  *  License as published by the Free Software Foundation; either
20  *  version 2.1 of the License, or (at your option) any later version.
21  *
22  *  This library is distributed in the hope that it will be useful,
23  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  *  Lesser General Public License for more details.
26  *
27  *  You should have received a copy of the GNU Lesser General Public
28  *  License along with this library; if not, write to the Free Software
29  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30  */
32 #include <vector>
34 //# include this before the #ifdefs below
35 #include "domconfig.h"
37 #ifdef DOM_STRING_OWN
38 #include "domstring.h"
39 #else
40 #ifdef DOM_STRING_GLIBMM
41 #include <glibmm.h>
42 #else
43 #include <string>
44 #endif
45 #endif
47 //# Unfortunate hack for a name collision
48 #ifdef SEVERITY_ERROR
49 #undef SEVERITY_ERROR
50 #endif
52 #define XMLNSNAME "http://www.w3.org/2000/xmlns/"
54 namespace org
55 {
56 namespace w3c
57 {
58 namespace dom
59 {
63 #ifdef DOM_STRING_OWN
64 #else
65 #ifdef DOM_STRING_GLIBMM
66 typedef Glib::ustring DOMString;
67 typedef gunichar XMLCh;
68 #else
69 typedef std::string DOMString;
70 typedef unsigned short XMLCh;
71 #endif
72 #endif
75 /**
76  *
77  */
78 typedef unsigned long long DOMTimeStamp;
80 /**
81  *
82  */
83 typedef void DOMUserData;
85 /**
86  *
87  */
88 typedef void DOMObject;
91 class DOMException;
92 class DOMStringList;
93 class NameList;
94 class DOMImplementationList;
95 class DOMImplementationSource;
96 class DOMImplementation;
97 class Node;
98 class NodeList;
99 class NamedNodeMap;
100 class CharacterData;
101 class Attr;
102 class Element;
103 class Text;
104 class Comment;
105 class TypeInfo;
106 class UserDataHandler;
107 class DOMError;
108 class DOMErrorHandler;
109 class DOMLocator;
110 class DOMConfiguration;
111 class CDATASection;
112 class DocumentType;
113 class Notation;
114 class Entity;
115 class EntityReference;
116 class ProcessingInstruction;
117 class DocumentFragment;
118 class Document;
121 /**
122  * NOTE: We were originally intending to split ALL specifications into
123  * interface and implementation.   After consideration, though, it behooves
124  * us to simplify things by implementing the base exception and
125  * container classes directly:
126  *
127  * DOMException
128  * DOMStringList
129  * NameList
130  * DOMImplementationList
131  * DOMImplementationSource
132  * DOMImplementation
133  * NodeList
134  * NamedNodeMap
135  */
138 /*#########################################################################
139 ## DOMException
140 #########################################################################*/
141 /**
142  *  This is the only non-interface class
143  */
144 class DOMException
147 public:
149     /**
150      * ExceptionCode
151      */
152     typedef enum
153         {
154         INDEX_SIZE_ERR                 = 1,
155         DOMSTRING_SIZE_ERR             = 2,
156         HIERARCHY_REQUEST_ERR          = 3,
157         WRONG_DOCUMENT_ERR             = 4,
158         INVALID_CHARACTER_ERR          = 5,
159         NO_DATA_ALLOWED_ERR            = 6,
160         NO_MODIFICATION_ALLOWED_ERR    = 7,
161         NOT_FOUND_ERR                  = 8,
162         NOT_SUPPORTED_ERR              = 9,
163         INUSE_ATTRIBUTE_ERR            = 10,
164         INVALID_STATE_ERR              = 11,
165         SYNTAX_ERR                     = 12,
166         INVALID_MODIFICATION_ERR       = 13,
167         NAMESPACE_ERR                  = 14,
168         INVALID_ACCESS_ERR             = 15,
169         VALIDATION_ERR                 = 16,
170         TYPE_MISMATCH_ERR              = 17
171         } ExceptionCode;
175     DOMException(const DOMString &reasonMsg)
176         { msg = reasonMsg; }
178     DOMException(short theCode)
179         {
180         code = theCode;
181         }
183     virtual ~DOMException() throw()
184        {}
186     /**
187      *
188      */
189     unsigned short code;
191     /**
192      *
193      */
194     DOMString msg;
196     /**
197      * Get a string, translated from the code.
198      * Like std::exception. Not in spec.
199      */
200     const char *what()
201         { return (const char *)msg.c_str(); }
205 };
212 /*#########################################################################
213 ## DOMStringList
214 #########################################################################*/
216 class DOMStringList
218 public:
220     /**
221      *
222      */
223     virtual DOMString item(unsigned long index)
224         {
225         if (index>=strings.size())
226             return "";
227         return strings[index];
228         }
230     /**
231      *
232      */
233     virtual unsigned long getLength()
234         {
235         return (unsigned long) strings.size();
236         }
238     /**
239      *
240      */
241     virtual bool contains(const DOMString &str)
242         {
243         for (unsigned int i=0; i<strings.size() ; i++)
244             {
245             if (strings[i] == str)
246                 return true;
247             }
248         return false;
249         }
252     //##################
253     //# Non-API methods
254     //##################
256     /**
257      *
258      */
259     DOMStringList() {}
262     /**
263      *
264      */
265     DOMStringList(const DOMStringList &other)
266         {
267         strings = other.strings;
268         }
270     /**
271      *
272      */
273     DOMStringList &operator=(const DOMStringList &other)
274         {
275         strings = other.strings;
276         return *this;
277         }
279     /**
280      *
281      */
282     virtual ~DOMStringList() {}
285 protected:
287     /**
288      *
289      */
290     virtual void add(const DOMString &str)
291         {
292         strings.push_back(str);
293         }
295     std::vector<DOMString>strings;
297 };
301 /*#########################################################################
302 ## NameList
303 #########################################################################*/
304 class NamePair
306 public:
307     NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
308         {
309         namespaceURI = theNamespaceURI;
310         name         = theName;
311         }
312     NamePair(const NamePair &other)
313         {
314         namespaceURI = other.namespaceURI;
315         name         = other.name;
316         }
317     NamePair &operator=(const NamePair &other)
318         {
319         namespaceURI = other.namespaceURI;
320         name         = other.name;
321         return *this;
322         }
323     virtual ~NamePair() {}
325     DOMString namespaceURI;
326     DOMString name;
327 };
331 class NameList
333 public:
335     /**
336      *
337      */
338     virtual DOMString getName(unsigned long index)
339         {
340         if (index>=namePairs.size())
341             return "";
342         return namePairs[index].name;
343         }
345     /**
346      *
347      */
348     virtual DOMString getNamespaceURI(unsigned long index)
349         {
350         if (index>=namePairs.size())
351             return "";
352         return namePairs[index].namespaceURI;
353         }
355     /**
356      *
357      */
358     virtual unsigned long getLength()
359         {
360         return (unsigned long)namePairs.size();
361         }
363     /**
364      *
365      */
366     virtual bool contains(const DOMString &name)
367         {
368         for (unsigned int i=0; i<namePairs.size() ; i++)
369             {
370             if (namePairs[i].name == name )
371                 return true;
372             }
373         return false;
374         }
376     /**
377      *
378      */
379     virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
380         {
381         for (unsigned int i=0; i<namePairs.size() ; i++)
382             {
383             if (namePairs[i].namespaceURI == namespaceURI ||
384                 namePairs[i].name         == name           )
385                 return true;
386             }
387         return false;
388         }
391     //##################
392     //# Non-API methods
393     //##################
395     /**
396      *
397      */
398     NameList() {}
400     /**
401      *
402      */
403     NameList(const NameList &other)
404         {
405         namePairs = other.namePairs;
406         }
408     /**
409      *
410      */
411     NameList &operator=(const NameList &other)
412         {
413         namePairs = other.namePairs;
414         return *this;
415         }
417     /**
418      *
419      */
420     virtual ~NameList() {}
421 protected:
423     std::vector<NamePair> namePairs;
425 };
427 /*#########################################################################
428 ## DOMImplementationList
429 #########################################################################*/
431 class DOMImplementationList
433 public:
435     /**
436      *
437      */
438     virtual DOMImplementation *getDOMImplementation(unsigned long index)
439         {
440         if (index >implementations.size())
441             return NULL;
442         return implementations[index];
443         }
445     /**
446      *
447      */
448     virtual unsigned long getLength()
449         {
450         return (unsigned long) implementations.size();
451         }
456     //##################
457     //# Non-API methods
458     //##################
460     /**
461      *
462      */
463     DOMImplementationList() {}
466     /**
467      *
468      */
469     DOMImplementationList(const DOMImplementationList &other)
470         {
471         implementations = other.implementations;
472         }
474     /**
475      *
476      */
477     DOMImplementationList &operator=(const DOMImplementationList &other)
478         {
479         implementations = other.implementations;
480         return *this;
481         }
483     /**
484      *
485      */
486     virtual ~DOMImplementationList() {}
488 protected:
490     std::vector<DOMImplementation *>implementations;
492 };
495 /*#########################################################################
496 ## DOMImplementationSource
497 #########################################################################*/
499 class DOMImplementationSource
501 public:
503     /**
504      *
505      */
506     virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
508     /**
509      *
510      */
511     virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
513     //##################
514     //# Non-API methods
515     //##################
517     /**
518      *
519      */
520     virtual ~DOMImplementationSource() {}
522 };
528 /*#########################################################################
529 ## DOMImplementation
530 #########################################################################*/
531 /**
532  *
533  */
534 class DOMImplementation
536 public:
537     /**
538      *
539      */
540     virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
543     /**
544      *
545      */
546     virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
547                                      const DOMString& publicId,
548                                      const DOMString& systemId)
549                                      throw(DOMException) = 0;
551     /**
552      *
553      */
554     virtual Document *createDocument(const DOMString& namespaceURI,
555                              const DOMString& qualifiedName,
556                              DocumentType *doctype)
557                              throw(DOMException) = 0;
558     /**
559      *
560      */
561     virtual DOMObject *getFeature(const DOMString& feature,
562                              const DOMString& version) = 0;
565     //##################
566     //# Non-API methods
567     //##################
569     /**
570      *
571      */
572     virtual ~DOMImplementation() {}
574 };
579 /*#########################################################################
580 ## Node
581 #########################################################################*/
583 /**
584  *
585  */
586 class Node
588 public:
590     typedef enum
591         {
592         ELEMENT_NODE                   = 1,
593         ATTRIBUTE_NODE                 = 2,
594         TEXT_NODE                      = 3,
595         CDATA_SECTION_NODE             = 4,
596         ENTITY_REFERENCE_NODE          = 5,
597         ENTITY_NODE                    = 6,
598         PROCESSING_INSTRUCTION_NODE    = 7,
599         COMMENT_NODE                   = 8,
600         DOCUMENT_NODE                  = 9,
601         DOCUMENT_TYPE_NODE             = 10,
602         DOCUMENT_FRAGMENT_NODE         = 11,
603         NOTATION_NODE                  = 12
604         } NodeType;
606     /**
607      *
608      */
609     virtual DOMString getNodeName() = 0;
611     /**
612      *
613      */
614     virtual DOMString getNodeValue() throw (DOMException) = 0;
616     /**
617      *
618      */
619     virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
621     /**
622      *
623      */
624     virtual unsigned short getNodeType() = 0;
626     /**
627      *
628      */
629     virtual Node *getParentNode() = 0;
631     /**
632      *
633      */
634     virtual NodeList getChildNodes() = 0;
636     /**
637      *
638      */
639     virtual Node *getFirstChild() = 0;
641     /**
642      *
643      */
644     virtual Node *getLastChild() = 0;
646     /**
647      *
648      */
649     virtual Node *getPreviousSibling() = 0;
651     /**
652      *
653      */
654     virtual Node *getNextSibling() = 0;
656     /**
657      *
658      */
659     virtual NamedNodeMap &getAttributes() = 0;
662     /**
663      *
664      */
665     virtual Document *getOwnerDocument() = 0;
667     /**
668      *
669      */
670     virtual Node *insertBefore(const Node *newChild,
671                        const Node *refChild)
672                        throw(DOMException) = 0;
674     /**
675      *
676      */
677     virtual Node *replaceChild(const Node *newChild,
678                        const Node *oldChild)
679                        throw(DOMException) = 0;
681     /**
682      *
683      */
684     virtual Node *removeChild(const Node *oldChild)
685                       throw(DOMException) = 0;
687     /**
688      *
689      */
690     virtual Node *appendChild(const Node *newChild)
691                       throw(DOMException) = 0;
693     /**
694      *
695      */
696     virtual bool hasChildNodes() = 0;
698     /**
699      *
700      */
701     virtual Node *cloneNode(bool deep) = 0;
703     /**
704      *
705      */
706     virtual void normalize() = 0;
708     /**
709      *
710      */
711     virtual bool isSupported(const DOMString& feature,
712                      const DOMString& version) = 0;
714     /**
715      *
716      */
717     virtual DOMString getNamespaceURI() = 0;
719     /**
720      *
721      */
722     virtual DOMString getPrefix() = 0;
724     /**
725      *
726      */
727     virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
729     /**
730      *
731      */
732     virtual DOMString getLocalName() = 0;
734     /**
735      *
736      */
737     virtual bool hasAttributes() = 0;
739     /**
740      *
741      */
742     virtual DOMString getBaseURI() = 0;
744     typedef enum
745         {
746         DOCUMENT_POSITION_DISCONNECTED            = 0x01,
747         DOCUMENT_POSITION_PRECEDING               = 0x02,
748         DOCUMENT_POSITION_FOLLOWING               = 0x04,
749         DOCUMENT_POSITION_CONTAINS                = 0x08,
750         DOCUMENT_POSITION_CONTAINED_BY            = 0x10,
751         DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
752         } DocumentPosition;
755     /**
756      *
757      */
758     virtual unsigned short compareDocumentPosition(const Node *other) = 0;
760     /**
761      *
762      */
763     virtual DOMString getTextContext() throw(DOMException) = 0;
766     /**
767      *
768      */
769     virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
772     /**
773      *
774      */
775     virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
778     /**
779      *
780      */
781     virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
784     /**
785      *
786      */
787     virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
790     /**
791      *
792      */
793     virtual bool isEqualNode(const Node *node) =0;
797     /**
798      *
799      */
800     virtual DOMObject *getFeature(const DOMString &feature,
801                                  const DOMString &version) =0;
803     /**
804      *
805      */
806     virtual DOMUserData *setUserData(const DOMString &key,
807                                      const DOMUserData *data,
808                                      const UserDataHandler *handler) =0;
811     /**
812      *
813      */
814     virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
816     //##################
817     //# Non-API methods
818     //##################
821     /**
822      *
823      */
824     virtual ~Node() {}
829 };
833 /*#########################################################################
834 ## NodeList
835 #########################################################################*/
837 /**
838  *
839  */
840 class NodeList
842 public:
843     /**
844      *
845      */
846     virtual Node *item(unsigned long index)
847         {
848         if (index>=nodes.size())
849             return NULL;
850         return nodes[index];
851         }
853     /**
854      *
855      */
856     virtual unsigned long getLength()
857         {
858         return (unsigned long) nodes.size();
859         }
861     //##################
862     //# Non-API methods
863     //##################
866     /**
867      *
868      */
869     NodeList() {}
871     /**
872      *
873      */
874     NodeList(const NodeList &other)
875         {
876         nodes = other.nodes;
877         }
879     /**
880      *
881      */
882     NodeList &operator=(const NodeList &other)
883         {
884         nodes = other.nodes;
885         return *this;
886         }
888     /**
889      *
890      */
891     virtual ~NodeList() {}
893     /**
894      *
895      */
896     virtual void clear()
897         {
898         nodes.clear();
899         }
901 protected:
903 friend class NodeImpl;
904 friend class ElementImpl;
906     /*
907      *
908      */
909     virtual void add(const Node *node)
910         {
911         nodes.push_back((Node *)node);
912         }
914 protected:
916     std::vector<Node *> nodes;
918 };
923 /*#########################################################################
924 ## NamedNodeMap
925 #########################################################################*/
927 class NamedNodeMapEntry
929 public:
930     NamedNodeMapEntry(const DOMString &theNamespaceURI,
931                       const DOMString &theName,
932                       const Node      *theNode)
933         {
934         namespaceURI = theNamespaceURI;
935         name         = theName;
936         node         = (Node *)theNode;
937         }
938     NamedNodeMapEntry(const NamedNodeMapEntry &other)
939         {
940         assign(other);
941         }
942     NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other)
943         {
944         assign(other);
945         return *this;
946         }
947     virtual ~NamedNodeMapEntry()
948         {
949         }
950     void assign(const NamedNodeMapEntry &other)
951         {
952         namespaceURI = other.namespaceURI;
953         name         = other.name;
954         node         = other.node;
955         }
956     DOMString namespaceURI;
957     DOMString name;
958     Node      *node;
959 };
961 /**
962  *
963  */
964 class NamedNodeMap
966 public:
968     /**
969      *
970      */
971     virtual Node *getNamedItem(const DOMString& name)
972         {
973         std::vector<NamedNodeMapEntry>::iterator iter;
974         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
975             {
976             if (iter->name == name)
977                 {
978                 Node *node = iter->node;
979                 return node;
980                 }
981             }
982         return NULL;
983         }
985     /**
986      *
987      */
988     virtual Node *setNamedItem(Node *arg) throw(DOMException)
989         {
990         if (!arg)
991             return NULL;
992         DOMString namespaceURI = arg->getNamespaceURI();
993         DOMString name         = arg->getNodeName();
994         std::vector<NamedNodeMapEntry>::iterator iter;
995         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
996             {
997             if (iter->name == name)
998                 {
999                 Node *node = iter->node;
1000                 iter->node = arg;
1001                 return node;
1002                 }
1003             }
1004         NamedNodeMapEntry entry(namespaceURI, name, arg);
1005         entries.push_back(entry);
1006         return arg;
1007         }
1010     /**
1011      *
1012      */
1013     virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
1014         {
1015         std::vector<NamedNodeMapEntry>::iterator iter;
1016         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1017             {
1018             if (iter->name == name)
1019                 {
1020                 Node *node = iter->node;
1021                 entries.erase(iter);
1022                 return node;
1023                 }
1024             }
1025         return NULL;
1026         }
1028     /**
1029      *
1030      */
1031     virtual Node *item(unsigned long index)
1032         {
1033         if (index>=entries.size())
1034             return NULL;
1035         return entries[index].node;
1036         }
1038     /**
1039      *
1040      */
1041     virtual unsigned long getLength()
1042         {
1043         return (unsigned long)entries.size();
1044         }
1046     /**
1047      *
1048      */
1049     virtual Node *getNamedItemNS(const DOMString& namespaceURI,
1050                                  const DOMString& localName)
1051         {
1052         std::vector<NamedNodeMapEntry>::iterator iter;
1053         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1054             {
1055             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1056                 {
1057                 Node *node = iter->node;
1058                 return node;
1059                 }
1060             }
1061         return NULL;
1062         }
1064     /**
1065      *
1066      */
1067     virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
1068         {
1069         if (!arg)
1070             return NULL;
1071         DOMString namespaceURI = arg->getNamespaceURI();
1072         DOMString name         = arg->getNodeName();
1073         std::vector<NamedNodeMapEntry>::iterator iter;
1074         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1075             {
1076             if (iter->namespaceURI == namespaceURI && iter->name == name)
1077                 {
1078                 Node *node = iter->node;
1079                 iter->node = arg;
1080                 return node;
1081                 }
1082             }
1083         NamedNodeMapEntry entry(namespaceURI, name, arg);
1084         entries.push_back(entry);
1085         return arg;
1086         }
1088     /**
1089      *
1090      */
1091     virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1092                                     const DOMString& localName)
1093                                     throw(DOMException)
1094         {
1095         std::vector<NamedNodeMapEntry>::iterator iter;
1096         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1097             {
1098             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1099                 {
1100                 Node *node = iter->node;
1101                 entries.erase(iter);
1102                 return node;
1103                 }
1104             }
1105         return NULL;
1106         }
1108     //##################
1109     //# Non-API methods
1110     //##################
1112     /**
1113      *
1114      */
1115     NamedNodeMap() {}
1118     /**
1119      *
1120      */
1121     NamedNodeMap(const NamedNodeMap &other)
1122         {
1123         entries = other.entries;
1124         }
1126     /**
1127      *
1128      */
1129     NamedNodeMap &operator=(const NamedNodeMap &other)
1130         {
1131         entries = other.entries;
1132         return *this;
1133         }
1136     /**
1137      *
1138      */
1139     virtual ~NamedNodeMap() {}
1141 protected:
1143     std::vector<NamedNodeMapEntry> entries;
1145 };
1150 /*#########################################################################
1151 ## CharacterData
1152 #########################################################################*/
1154 /**
1155  *
1156  */
1157 class CharacterData : virtual public Node
1159 public:
1161     /**
1162      *
1163      */
1164     virtual DOMString getData() throw(DOMException) = 0;
1166     /**
1167      *
1168      */
1169     virtual void setData(const DOMString& val) throw(DOMException) = 0;
1171     /**
1172      *
1173      */
1174     virtual unsigned long getLength() = 0;
1176     /**
1177      *
1178      */
1179     virtual DOMString substringData(unsigned long offset,
1180                             unsigned long count)
1181                             throw(DOMException) = 0;
1183     /**
1184      *
1185      */
1186     virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1188     /**
1189      *
1190      */
1191     virtual void insertData(unsigned long offset,
1192                     const DOMString& arg)
1193                     throw(DOMException) = 0;
1195     /**
1196      *
1197      */
1198     virtual void deleteData(unsigned long offset,
1199                     unsigned long count)
1200                     throw(DOMException) = 0;
1202     /**
1203      *
1204      */
1205     virtual void  replaceData(unsigned long offset,
1206                       unsigned long count,
1207                       const DOMString& arg)
1208                       throw(DOMException) = 0;
1211     //##################
1212     //# Non-API methods
1213     //##################
1216     /**
1217      *
1218      */
1219     virtual ~CharacterData() {}
1221 };
1227 /*#########################################################################
1228 ## Attr
1229 #########################################################################*/
1231 /**
1232  *
1233  */
1234 class Attr : virtual public Node
1236 public:
1238     /**
1239      *
1240      */
1241     virtual DOMString getName() = 0;
1243     /**
1244      *
1245      */
1246     virtual bool getSpecified() = 0;
1248     /**
1249      *
1250      */
1251     virtual DOMString getValue() = 0;
1253     /**
1254      *
1255      */
1256     virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1258     /**
1259      *
1260      */
1261     virtual Element *getOwnerElement() = 0;
1264     /**
1265      *
1266      */
1267     virtual TypeInfo *getSchemaTypeInfo() = 0;
1270     /**
1271      *
1272      */
1273     virtual bool getIsId() = 0;
1275     //##################
1276     //# Non-API methods
1277     //##################
1280     /**
1281      *
1282      */
1283     virtual ~Attr() {}
1285 };
1291 /*#########################################################################
1292 ## Element
1293 #########################################################################*/
1295 /**
1296  *
1297  */
1298 class Element : virtual public Node
1300 public:
1303     /**
1304      *
1305      */
1306     virtual DOMString getTagName() = 0;
1308     /**
1309      *
1310      */
1311     virtual DOMString getAttribute(const DOMString& name) = 0;
1313     /**
1314      *
1315      */
1316     virtual void setAttribute(const DOMString& name,
1317                       const DOMString& value)
1318                       throw(DOMException) = 0;
1320     /**
1321      *
1322      */
1323     virtual void removeAttribute(const DOMString& name)
1324                          throw(DOMException) = 0;
1326     /**
1327      *
1328      */
1329     virtual Attr *getAttributeNode(const DOMString& name) = 0;
1331     /**
1332      *
1333      */
1334     virtual Attr *setAttributeNode(Attr *newAttr)
1335                           throw(DOMException) = 0;
1337     /**
1338      *
1339      */
1340     virtual Attr *removeAttributeNode(Attr *oldAttr)
1341                              throw(DOMException) = 0;
1343     /**
1344      *
1345      */
1346     virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1348     /**
1349      *
1350      */
1351     virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1352                              const DOMString& localName) = 0;
1354     /**
1355      *
1356      */
1357     virtual void setAttributeNS(const DOMString& namespaceURI,
1358                         const DOMString& qualifiedName,
1359                         const DOMString& value)
1360                         throw(DOMException) = 0;
1362     /**
1363      *
1364      */
1365     virtual void removeAttributeNS(const DOMString& namespaceURI,
1366                            const DOMString& localName)
1367                            throw(DOMException) = 0;
1369     /**
1370      *
1371      */
1372     virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1373                             const DOMString& localName) = 0;
1375     /**
1376      *
1377      */
1378     virtual Attr *setAttributeNodeNS(Attr *newAttr)
1379                             throw(DOMException) = 0;
1381     /**
1382      *
1383      */
1384     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1385                                     const DOMString& localName) = 0;
1387     /**
1388      *
1389      */
1390     virtual bool hasAttribute(const DOMString& name) = 0;
1392     /**
1393      *
1394      */
1395     virtual bool hasAttributeNS(const DOMString& namespaceURI,
1396                         const DOMString& localName) = 0;
1398     /**
1399      *
1400      */
1401     virtual TypeInfo *getSchemaTypeInto() = 0;
1404     /**
1405      *
1406      */
1407     virtual void setIdAttribute(const DOMString &name,
1408                                 bool isId) throw (DOMException) = 0;
1410     /**
1411      *
1412      */
1413     virtual void setIdAttributeNS(const DOMString &namespaceURI,
1414                                   const DOMString &localName,
1415                                   bool isId) throw (DOMException) = 0;
1417     /**
1418      *
1419      */
1420     virtual void setIdAttributeNode(const Attr *idAttr,
1421                                     bool isId) throw (DOMException) = 0;
1423     //##################
1424     //# Non-API methods
1425     //##################
1427     /**
1428      *
1429      */
1430     virtual ~Element() {}
1432 };
1438 /*#########################################################################
1439 ## Text
1440 #########################################################################*/
1442 /**
1443  *
1444  */
1445 class Text : virtual public CharacterData
1447 public:
1449     /**
1450      *
1451      */
1452     virtual Text *splitText(unsigned long offset)
1453                     throw(DOMException) = 0;
1455     /**
1456      *
1457      */
1458     virtual bool getIsElementContentWhitespace()= 0;
1460     /**
1461      *
1462      */
1463     virtual DOMString getWholeText() = 0;
1466     /**
1467      *
1468      */
1469     virtual Text *replaceWholeText(const DOMString &content)
1470                                  throw(DOMException) = 0;
1472     //##################
1473     //# Non-API methods
1474     //##################
1477     /**
1478      *
1479      */
1480     virtual ~Text() {}
1482 };
1486 /*#########################################################################
1487 ## Comment
1488 #########################################################################*/
1490 /**
1491  *
1492  */
1493 class Comment : virtual public CharacterData
1495 public:
1497     //##################
1498     //# Non-API methods
1499     //##################
1502     /**
1503      *
1504      */
1505     virtual ~Comment() {}
1508 };
1512 /*#########################################################################
1513 ## TypeInfo
1514 #########################################################################*/
1516 /**
1517  *
1518  */
1519 class TypeInfo
1521 public:
1523     /**
1524      *
1525      */
1526     virtual DOMString getTypeName() =0;
1528     /**
1529      *
1530      */
1531     virtual DOMString getTypeNamespace() =0;
1533     typedef enum
1534         {
1535         DERIVATION_RESTRICTION = 0x00000001,
1536         DERIVATION_EXTENSION   = 0x00000002,
1537         DERIVATION_UNION       = 0x00000004,
1538         DERIVATION_LIST        = 0x00000008
1539         } DerivationMethod;
1542     /**
1543      *
1544      */
1545     virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1546                                const DOMString &typeNameArg,
1547                                DerivationMethod derivationMethod) =0;
1549     //##################
1550     //# Non-API methods
1551     //##################
1554     /**
1555      *
1556      */
1557     virtual ~TypeInfo() {}
1559 };
1564 /*#########################################################################
1565 ## UserDataHandler
1566 #########################################################################*/
1568 /**
1569  *
1570  */
1571 class UserDataHandler
1573 public:
1575     typedef enum
1576         {
1577         NODE_CLONED     = 1,
1578         NODE_IMPORTED   = 2,
1579         NODE_DELETED    = 3,
1580         NODE_RENAMED    = 4,
1581         NODE_ADOPTED    = 5
1582         } OperationType;
1585     /**
1586      *
1587      */
1588     virtual  void handle(unsigned short operation,
1589                          const DOMString &key,
1590                          const DOMUserData *data,
1591                          const Node *src,
1592                          const Node *dst) =0;
1594     //##################
1595     //# Non-API methods
1596     //##################
1599     /**
1600      *
1601      */
1602     virtual ~UserDataHandler() {}
1604 };
1607 /*#########################################################################
1608 ## DOMError
1609 #########################################################################*/
1611 /**
1612  *
1613  */
1614 class DOMError
1616 public:
1618     typedef enum
1619         {
1620         SEVERITY_WARNING     = 1,
1621         SEVERITY_ERROR       = 2,
1622         SEVERITY_FATAL_ERROR = 3
1623         } ErrorSeverity;
1626     /**
1627      *
1628      */
1629     virtual unsigned short getSeverity() =0;
1631     /**
1632      *
1633      */
1634     virtual DOMString getMessage() =0;
1636     /**
1637      *
1638      */
1639     virtual DOMString getType() =0;
1641     /**
1642      *
1643      */
1644     virtual DOMObject *getRelatedException() =0;
1646     /**
1647      *
1648      */
1649     virtual DOMObject *getRelatedData() =0;
1651     /**
1652      *
1653      */
1654     virtual DOMLocator *getLocation() =0;
1657     //##################
1658     //# Non-API methods
1659     //##################
1662     /**
1663      *
1664      */
1665     virtual ~DOMError() {}
1667 };
1670 /*#########################################################################
1671 ## DOMErrorHandler
1672 #########################################################################*/
1674 /**
1675  *
1676  */
1677 class DOMErrorHandler
1679 public:
1680     /**
1681      *
1682      */
1683     virtual bool handleError(const DOMError *error) =0;
1685     //##################
1686     //# Non-API methods
1687     //##################
1690     /**
1691      *
1692      */
1693     virtual ~DOMErrorHandler() {}
1695 };
1699 /*#########################################################################
1700 ## DOMLocator
1701 #########################################################################*/
1703 /**
1704  *
1705  */
1706 class DOMLocator
1708 public:
1710     /**
1711      *
1712      */
1713     virtual long getLineNumber() =0;
1715     /**
1716      *
1717      */
1718     virtual long getColumnNumber() =0;
1720     /**
1721      *
1722      */
1723     virtual long getByteOffset() =0;
1725     /**
1726      *
1727      */
1728     virtual long getUtf16Offset() =0;
1731     /**
1732      *
1733      */
1734     virtual Node *getRelatedNode() =0;
1737     /**
1738      *
1739      */
1740     virtual DOMString getUri() =0;
1742     //##################
1743     //# Non-API methods
1744     //##################
1746     /**
1747      *
1748      */
1749     virtual ~DOMLocator() {}
1750 };
1753 /*#########################################################################
1754 ## DOMConfiguration
1755 #########################################################################*/
1757 /**
1758  *
1759  */
1760 class DOMConfiguration
1762 public:
1764     /**
1765      *
1766      */
1767     virtual void setParameter(const DOMString &name,
1768                               const DOMUserData *value) throw (DOMException) =0;
1770     /**
1771      *
1772      */
1773     virtual DOMUserData *getParameter(const DOMString &name)
1774                                       throw (DOMException) =0;
1776     /**
1777      *
1778      */
1779     virtual bool canSetParameter(const DOMString &name,
1780                                  const DOMUserData *data) =0;
1782     /**
1783      *
1784      */
1785     virtual DOMStringList *getParameterNames() =0;
1787     //##################
1788     //# Non-API methods
1789     //##################
1792     /**
1793      *
1794      */
1795     virtual ~DOMConfiguration() {}
1797 };
1804 /*#########################################################################
1805 ## CDATASection
1806 #########################################################################*/
1807 /**
1808  *
1809  */
1810 class CDATASection : virtual public Text
1812 public:
1814     //##################
1815     //# Non-API methods
1816     //##################
1819     /**
1820      *
1821      */
1822     virtual ~CDATASection() {}
1824 };
1829 /*#########################################################################
1830 ## DocumentType
1831 #########################################################################*/
1833 /**
1834  *
1835  */
1836 class DocumentType : virtual public Node
1838 public:
1840     /**
1841      *
1842      */
1843     virtual DOMString getName() = 0;
1845     /**
1846      *
1847      */
1848     virtual NamedNodeMap getEntities() = 0;
1850     /**
1851      *
1852      */
1853     virtual NamedNodeMap getNotations() = 0;
1855     /**
1856      *
1857      */
1858     virtual DOMString getPublicId() = 0;
1860     /**
1861      *
1862      */
1863     virtual DOMString getSystemId() = 0;
1865     /**
1866      *
1867      */
1868     virtual DOMString getInternalSubset() = 0;
1870     //##################
1871     //# Non-API methods
1872     //##################
1874     /**
1875      *
1876      */
1877     virtual ~DocumentType() {}
1879 };
1885 /*#########################################################################
1886 ## Notation
1887 #########################################################################*/
1889 /**
1890  *
1891  */
1892 class Notation : virtual public Node
1894 public:
1896     /**
1897      *
1898      */
1899     virtual DOMString getPublicId() = 0;
1901     /**
1902      *
1903      */
1904     virtual DOMString getSystemId() = 0;
1906     //##################
1907     //# Non-API methods
1908     //##################
1911     /**
1912      *
1913      */
1914     virtual ~Notation() {}
1915 };
1922 /*#########################################################################
1923 ## Entity
1924 #########################################################################*/
1926 /**
1927  *
1928  */
1929 class Entity : virtual public Node
1931 public:
1933     /**
1934      *
1935      */
1936     virtual DOMString getPublicId() = 0;
1938     /**
1939      *
1940      */
1941     virtual DOMString getSystemId() = 0;
1943     /**
1944      *
1945      */
1946     virtual DOMString getNotationName() = 0;
1948     /**
1949      *
1950      */
1951     virtual DOMString getInputEncoding() = 0;
1953     /**
1954      *
1955      */
1956     virtual DOMString getXmlEncoding() = 0;
1958     /**
1959      *
1960      */
1961     virtual DOMString getXmlVersion() = 0;
1963     //##################
1964     //# Non-API methods
1965     //##################
1968     /**
1969      *
1970      */
1971     virtual ~Entity() {}
1972 };
1978 /*#########################################################################
1979 ## EntityReference
1980 #########################################################################*/
1981 /**
1982  *
1983  */
1984 class EntityReference : virtual public Node
1986 public:
1989     //##################
1990     //# Non-API methods
1991     //##################
1993     /**
1994      *
1995      */
1996     virtual ~EntityReference() {}
1997 };
2003 /*#########################################################################
2004 ## ProcessingInstruction
2005 #########################################################################*/
2007 /**
2008  *
2009  */
2010 class ProcessingInstruction : virtual public Node
2012 public:
2014     /**
2015      *
2016      */
2017     virtual DOMString getTarget() = 0;
2019     /**
2020      *
2021      */
2022     virtual DOMString getData() = 0;
2024     /**
2025      *
2026      */
2027    virtual void setData(const DOMString& val) throw(DOMException) = 0;
2029     //##################
2030     //# Non-API methods
2031     //##################
2034     /**
2035      *
2036      */
2037     virtual ~ProcessingInstruction() {}
2039 };
2045 /*#########################################################################
2046 ## DocumentFragment
2047 #########################################################################*/
2048 /**
2049  *
2050  */
2051 class DocumentFragment : virtual public Node
2053 public:
2055     //##################
2056     //# Non-API methods
2057     //##################
2060     /**
2061      *
2062      */
2063     virtual ~DocumentFragment() {}
2064 };
2071 /*#########################################################################
2072 ## Document
2073 #########################################################################*/
2075 /**
2076  *
2077  */
2078 class Document : virtual public Node
2080 public:
2082     /**
2083      *
2084      */
2085     virtual DocumentType *getDoctype() = 0;
2087     /**
2088      *
2089      */
2090     virtual DOMImplementation *getImplementation() = 0;
2092     /**
2093      *
2094      */
2095     virtual Element *getDocumentElement() = 0;
2097     /**
2098      *
2099      */
2100     virtual Element *createElement(const DOMString& tagName)
2101                            throw(DOMException) = 0;
2103     /**
2104      *
2105      */
2106     virtual DocumentFragment *createDocumentFragment() = 0;
2108     /**
2109      *
2110      */
2111     virtual Text *createTextNode(const DOMString& data) = 0;
2113     /**
2114      *
2115      */
2116     virtual Comment  *createComment(const DOMString& data) = 0;
2118     /**
2119      *
2120      */
2121     virtual CDATASection *createCDATASection(const DOMString& data)
2122                                      throw(DOMException) = 0;
2124     /**
2125      *
2126      */
2127     virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2128                                                        const DOMString& data)
2129                                                        throw(DOMException) = 0;
2131     /**
2132      *
2133      */
2134     virtual Attr *createAttribute(const DOMString& name)
2135                           throw(DOMException) = 0;
2137     /**
2138      *
2139      */
2140     virtual EntityReference *createEntityReference(const DOMString& name)
2141                                            throw(DOMException) = 0;
2143     /**
2144      *
2145      */
2146     virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2149     /**
2150      *
2151      */
2152     virtual Node *importNode(const Node *importedNode,
2153                      bool deep)
2154                      throw(DOMException) = 0;
2156     /**
2157      *
2158      */
2159     virtual Element *createElementNS(const DOMString& namespaceURI,
2160                              const DOMString& qualifiedName)
2161                              throw(DOMException) = 0;
2163     /**
2164      *
2165      */
2166     virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2167                             const DOMString& qualifiedName)
2168                             throw(DOMException) = 0;
2170     /**
2171      *
2172      */
2173     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2174                                      const DOMString& localName) = 0;
2176     /**
2177      *
2178      */
2179     virtual Element *getElementById(const DOMString& elementId) = 0;
2182     /**
2183      *
2184      */
2185     virtual DOMString getInputEncoding() = 0;
2188     /**
2189      *
2190      */
2191     virtual DOMString getXmlEncoding() = 0;
2193     /**
2194      *
2195      */
2196     virtual bool getXmlStandalone() = 0;
2198     /**
2199      *
2200      */
2201     virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2203     /**
2204      *
2205      */
2206     virtual DOMString getXmlVersion() = 0;
2208     /**
2209      *
2210      */
2211     virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2213     /**
2214      *
2215      */
2216     virtual bool getStrictErrorChecking() = 0;
2218     /**
2219      *
2220      */
2221     virtual void setStrictErrorChecking(bool val) = 0;
2224     /**
2225      *
2226      */
2227     virtual DOMString getDocumentURI() = 0;
2229     /**
2230      *
2231      */
2232     virtual void setDocumentURI(const DOMString &uri) = 0;
2234     /**
2235      *
2236      */
2237     virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2239     /**
2240      *
2241      */
2242     virtual DOMConfiguration *getDomConfig() = 0;
2244     /**
2245      *
2246      */
2247     virtual void normalizeDocument() = 0;
2249     /**
2250      *
2251      */
2252     virtual Node *renameNode(const Node *n,
2253                              const DOMString &namespaceURI,
2254                              const DOMString &qualifiedName)
2255                              throw (DOMException) = 0;
2258     //##################
2259     //# Non-API methods
2260     //##################
2262     /**
2263      *
2264      */
2265     virtual ~Document() {}
2267 };
2279 }  //namespace dom
2280 }  //namespace w3c
2281 }  //namespace org
2284 #endif // __DOM_H__
2287 /*#########################################################################
2288 ## E N D    O F    F I L E
2289 #########################################################################*/