summaryrefslogtreecommitdiff
path: root/libopie/xmltree.cc
Unidiff
Diffstat (limited to 'libopie/xmltree.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/xmltree.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie/xmltree.cc b/libopie/xmltree.cc
index 408e3c6..27db5b3 100644
--- a/libopie/xmltree.cc
+++ b/libopie/xmltree.cc
@@ -1,154 +1,155 @@
1/* This file is part of the KDE project 1/* This file is part of the KDE project
2 Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2001 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpe/stringutil.h> 20#include <qpe/stringutil.h>
21#include <opie/xmltree.h> 21#include <opie/xmltree.h>
22 22
23#include <qxml.h> 23#include <qxml.h>
24 24
25#include <assert.h> 25#include <assert.h>
26 26
27using namespace Opie;
27 28
28XMLElement::XMLElement() 29XMLElement::XMLElement()
29 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) 30 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 )
30{ 31{
31} 32}
32 33
33XMLElement::~XMLElement() 34XMLElement::~XMLElement()
34{ 35{
35 XMLElement *n = m_first; 36 XMLElement *n = m_first;
36 37
37 while ( n ) 38 while ( n )
38 { 39 {
39 XMLElement *tmp = n; 40 XMLElement *tmp = n;
40 n = n->m_next; 41 n = n->m_next;
41 delete tmp; 42 delete tmp;
42 } 43 }
43} 44}
44 45
45void XMLElement::appendChild( XMLElement *child ) 46void XMLElement::appendChild( XMLElement *child )
46{ 47{
47 if ( child->m_parent ) 48 if ( child->m_parent )
48 child->m_parent->removeChild( child ); 49 child->m_parent->removeChild( child );
49 50
50 child->m_parent = this; 51 child->m_parent = this;
51 52
52 if ( m_last ) 53 if ( m_last )
53 m_last->m_next = child; 54 m_last->m_next = child;
54 55
55 child->m_prev = m_last; 56 child->m_prev = m_last;
56 57
57 if ( !m_first ) 58 if ( !m_first )
58 m_first = child; 59 m_first = child;
59 60
60 m_last = child; 61 m_last = child;
61} 62}
62 63
63void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) 64void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild )
64{ 65{
65 assert( newChild != refChild ); 66 assert( newChild != refChild );
66 67
67 if ( refChild == m_last ) 68 if ( refChild == m_last )
68 { 69 {
69 appendChild( newChild ); 70 appendChild( newChild );
70 return; 71 return;
71 } 72 }
72 73
73 assert( refChild ); 74 assert( refChild );
74 assert( refChild->m_parent ); 75 assert( refChild->m_parent );
75 assert( refChild->m_parent == this ); 76 assert( refChild->m_parent == this );
76 77
77 if ( newChild->m_parent && newChild != refChild ) 78 if ( newChild->m_parent && newChild != refChild )
78 newChild->m_parent->removeChild( newChild ); 79 newChild->m_parent->removeChild( newChild );
79 80
80 newChild->m_parent = this; 81 newChild->m_parent = this;
81 82
82 XMLElement *next = refChild->m_next; 83 XMLElement *next = refChild->m_next;
83 84
84 refChild->m_next = newChild; 85 refChild->m_next = newChild;
85 86
86 newChild->m_prev = refChild; 87 newChild->m_prev = refChild;
87 newChild->m_next = next; 88 newChild->m_next = next;
88 89
89 if ( next ) 90 if ( next )
90 next->m_prev = newChild; 91 next->m_prev = newChild;
91} 92}
92 93
93QString XMLElement::attribute( const QString &attr ) const 94QString XMLElement::attribute( const QString &attr ) const
94{ 95{
95 AttributeMap::ConstIterator it = m_attributes.find( attr ); 96 AttributeMap::ConstIterator it = m_attributes.find( attr );
96 if ( it == m_attributes.end() ) 97 if ( it == m_attributes.end() )
97 return QString::null; 98 return QString::null;
98 return it.data(); 99 return it.data();
99} 100}
100 101
101void XMLElement::setAttribute( const QString &attr, const QString &value ) 102void XMLElement::setAttribute( const QString &attr, const QString &value )
102{ 103{
103 m_attributes.replace( attr, value ); 104 m_attributes.replace( attr, value );
104} 105}
105 106
106void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) 107void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild )
107{ 108{
108 assert( refChild ); 109 assert( refChild );
109 assert( refChild->m_parent ); 110 assert( refChild->m_parent );
110 assert( refChild->m_parent == this ); 111 assert( refChild->m_parent == this );
111 assert( newChild != refChild ); 112 assert( newChild != refChild );
112 113
113 if ( newChild->m_parent && newChild != refChild ) 114 if ( newChild->m_parent && newChild != refChild )
114 newChild->m_parent->removeChild( newChild ); 115 newChild->m_parent->removeChild( newChild );
115 116
116 newChild->m_parent = this; 117 newChild->m_parent = this;
117 118
118 XMLElement *prev = refChild->m_prev; 119 XMLElement *prev = refChild->m_prev;
119 120
120 refChild->m_prev = newChild; 121 refChild->m_prev = newChild;
121 122
122 newChild->m_prev = prev; 123 newChild->m_prev = prev;
123 newChild->m_next = refChild; 124 newChild->m_next = refChild;
124 125
125 if ( prev ) 126 if ( prev )
126 prev->m_next = newChild; 127 prev->m_next = newChild;
127 128
128 if ( refChild == m_first ) 129 if ( refChild == m_first )
129 m_first = newChild; 130 m_first = newChild;
130} 131}
131 132
132void XMLElement::removeChild( XMLElement *child ) 133void XMLElement::removeChild( XMLElement *child )
133{ 134{
134 if ( child->m_parent != this ) 135 if ( child->m_parent != this )
135 return; 136 return;
136 137
137 if ( m_first == child ) 138 if ( m_first == child )
138 m_first = child->m_next; 139 m_first = child->m_next;
139 140
140 if ( m_last == child ) 141 if ( m_last == child )
141 m_last = child->m_prev; 142 m_last = child->m_prev;
142 143
143 if ( child->m_prev ) 144 if ( child->m_prev )
144 child->m_prev->m_next = child->m_next; 145 child->m_prev->m_next = child->m_next;
145 146
146 if ( child->m_next ) 147 if ( child->m_next )
147 child->m_next->m_prev = child->m_prev; 148 child->m_next->m_prev = child->m_prev;
148 149
149 child->m_parent = 0; 150 child->m_parent = 0;
150 child->m_prev = 0; 151 child->m_prev = 0;
151 child->m_next = 0; 152 child->m_next = 0;
152} 153}
153 154
154void XMLElement::save( QTextStream &s, uint indent ) 155void XMLElement::save( QTextStream &s, uint indent )