1 // Created on: 2001-06-27
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <LDOM_BasicNode.hxx>
22 #include <LDOM_BasicElement.hxx>
23 #include <LDOM_BasicAttribute.hxx>
24 #include <LDOM_BasicText.hxx>
26 //=======================================================================
27 //function : operator =
28 //purpose : Assignment
29 //=======================================================================
31 LDOM_BasicNode& LDOM_BasicNode::operator = (const LDOM_BasicNode& anOther)
33 myNodeType = anOther.getNodeType();
34 mySibling = anOther.GetSibling();
38 //=======================================================================
39 //function : GetSibling
40 //purpose : also detaches NULL siblings
41 //=======================================================================
43 const LDOM_BasicNode * LDOM_BasicNode::GetSibling () const
46 if (mySibling -> isNull())
47 (const LDOM_BasicNode *&) mySibling = mySibling -> mySibling;
54 //=======================================================================
55 // Debug Function for DBX: use "print -p <Variable> or pp <Variable>"
56 //=======================================================================
57 #include <LDOM_OSStream.hxx>
59 #define MAX_SIBLINGS 8
60 char * db_pretty_print (const LDOM_BasicNode * aBNode, int fl, char *)
62 LDOM_OSStream out (128);
63 switch (aBNode -> getNodeType()) {
64 case LDOM_Node::ELEMENT_NODE:
66 const LDOM_BasicElement& aBElem = * (const LDOM_BasicElement *) aBNode;
67 if ((fl & FLITERAL) == 0) out << "LDOM_BasicElement: ";
68 out << '<' << aBElem.GetTagName();
69 aBNode = aBElem.GetFirstChild();
71 if (aBNode -> getNodeType() == LDOM_Node::ATTRIBUTE_NODE)
73 db_pretty_print ((const LDOM_BasicAttribute *) aBNode, FLITERAL, 0);
74 aBNode = aBNode -> GetSibling();
77 if ((fl & FLITERAL) == 0) {
78 aBNode = aBElem.GetFirstChild();
79 int counter = MAX_SIBLINGS;
81 out << endl << " == Children:" << endl;
82 while (aBNode && counter--) {
83 if (aBNode -> getNodeType() == LDOM_Node::ATTRIBUTE_NODE) break;
84 out << " *(LDOM_BasicNode*)" << aBNode << " : " <<
85 db_pretty_print (aBNode, FLITERAL, 0) << endl;
86 aBNode = aBNode -> GetSibling();
89 aBNode = aBElem.GetSibling();
91 out << " == Siblings:" << endl;
92 counter = MAX_SIBLINGS;
93 while (aBNode && counter--) {
94 if (aBNode -> getNodeType() == LDOM_Node::ATTRIBUTE_NODE) break;
95 out << " *(LDOM_BasicNode*)" << aBNode << " : " <<
96 db_pretty_print (aBNode, FLITERAL, 0) << endl;
97 aBNode = aBNode -> GetSibling();
104 case LDOM_Node::ATTRIBUTE_NODE:
106 const LDOM_BasicAttribute& aBAtt = * (const LDOM_BasicAttribute *) aBNode;
107 if ((fl & FLITERAL) == 0) out << "LDOM_BasicAttribute: ";
108 out << aBAtt.GetName() << '='
109 << db_pretty_print (&aBAtt.GetValue(), FLITERAL, 0) << ends;
112 case LDOM_Node::TEXT_NODE:
113 case LDOM_Node::COMMENT_NODE:
114 case LDOM_Node::CDATA_SECTION_NODE:
116 const LDOM_BasicText& aBText = * (const LDOM_BasicText *) aBNode;
117 if ((fl & FLITERAL) == 0) out << "LDOM_BasicText: ";
118 out << db_pretty_print (&aBText.GetData(), FLITERAL, 0) << ends;
122 out << "UNKNOWN" << ends;
125 return (char *)out.str();
128 char * db_pretty_print (const LDOM_Node * aBNode, int fl, char * c)
130 return db_pretty_print (&aBNode -> Origin(), fl, c);