0024512: clang++ compiler complains about extra semicolon
[occt.git] / src / LDOM / LDOM_BasicNode.cxx
CommitLineData
b311480e 1// Created on: 2001-06-27
2// Created by: Alexander GRIGORIEV
973c2be1 3// Copyright (c) 2001-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <LDOM_BasicNode.hxx>
17#include <LDOM_BasicElement.hxx>
18#include <LDOM_BasicAttribute.hxx>
19#include <LDOM_BasicText.hxx>
20
21//=======================================================================
22//function : operator =
23//purpose : Assignment
24//=======================================================================
25
26LDOM_BasicNode& LDOM_BasicNode::operator = (const LDOM_BasicNode& anOther)
27{
28 myNodeType = anOther.getNodeType();
29 mySibling = anOther.GetSibling();
30 return * this;
31}
32
33//=======================================================================
34//function : GetSibling
35//purpose : also detaches NULL siblings
36//=======================================================================
37
38const LDOM_BasicNode * LDOM_BasicNode::GetSibling () const
39{
40 while (mySibling)
41 if (mySibling -> isNull())
42 (const LDOM_BasicNode *&) mySibling = mySibling -> mySibling;
43 else break;
44 return mySibling;
45}
46
47#ifdef DEB
48#ifndef WNT
49//=======================================================================
50// Debug Function for DBX: use "print -p <Variable> or pp <Variable>"
51//=======================================================================
52#include <LDOM_OSStream.hxx>
53#define FLITERAL 0x10
54#define MAX_SIBLINGS 8
55char * db_pretty_print (const LDOM_BasicNode * aBNode, int fl, char *)
56{
57 LDOM_OSStream out (128);
58 switch (aBNode -> getNodeType()) {
59 case LDOM_Node::ELEMENT_NODE:
60 {
61 const LDOM_BasicElement& aBElem = * (const LDOM_BasicElement *) aBNode;
62 if ((fl & FLITERAL) == 0) out << "LDOM_BasicElement: ";
63 out << '<' << aBElem.GetTagName();
64 aBNode = aBElem.GetFirstChild();
65 while (aBNode) {
66 if (aBNode -> getNodeType() == LDOM_Node::ATTRIBUTE_NODE)
67 out << ' ' <<
68 db_pretty_print ((const LDOM_BasicAttribute *) aBNode, FLITERAL, 0);
69 aBNode = aBNode -> GetSibling();
70 }
71 out << '>';
72 if ((fl & FLITERAL) == 0) {
73 aBNode = aBElem.GetFirstChild();
74 int counter = MAX_SIBLINGS;
75 if (aBNode) {
76 out << endl << " == Children:" << endl;
77 while (aBNode && counter--) {
78 if (aBNode -> getNodeType() == LDOM_Node::ATTRIBUTE_NODE) break;
79 out << " *(LDOM_BasicNode*)" << aBNode << " : " <<
80 db_pretty_print (aBNode, FLITERAL, 0) << endl;
81 aBNode = aBNode -> GetSibling();
82 }
83 }
84 aBNode = aBElem.GetSibling();
85 if (aBNode) {
86 out << " == Siblings:" << endl;
87 counter = MAX_SIBLINGS;
88 while (aBNode && counter--) {
89 if (aBNode -> getNodeType() == LDOM_Node::ATTRIBUTE_NODE) break;
90 out << " *(LDOM_BasicNode*)" << aBNode << " : " <<
91 db_pretty_print (aBNode, FLITERAL, 0) << endl;
92 aBNode = aBNode -> GetSibling();
93 }
94 }
95 }
96 out << ends;
97 break;
98 }
99 case LDOM_Node::ATTRIBUTE_NODE:
100 {
101 const LDOM_BasicAttribute& aBAtt = * (const LDOM_BasicAttribute *) aBNode;
102 if ((fl & FLITERAL) == 0) out << "LDOM_BasicAttribute: ";
103 out << aBAtt.GetName() << '='
104 << db_pretty_print (&aBAtt.GetValue(), FLITERAL, 0) << ends;
105 break;
106 }
107 case LDOM_Node::TEXT_NODE:
108 case LDOM_Node::COMMENT_NODE:
109 case LDOM_Node::CDATA_SECTION_NODE:
110 {
111 const LDOM_BasicText& aBText = * (const LDOM_BasicText *) aBNode;
112 if ((fl & FLITERAL) == 0) out << "LDOM_BasicText: ";
113 out << db_pretty_print (&aBText.GetData(), FLITERAL, 0) << ends;
114 break;
115 }
116 default:
117 out << "UNKNOWN" << ends;
118 break;
119 }
120 return (char *)out.str();
121}
122
123char * db_pretty_print (const LDOM_Node * aBNode, int fl, char * c)
124{
125 return db_pretty_print (&aBNode -> Origin(), fl, c);
126}
127
128#endif
129#endif