summaryrefslogtreecommitdiff
path: root/libopie/xmltree.cc
Unidiff
Diffstat (limited to 'libopie/xmltree.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/xmltree.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/xmltree.cc b/libopie/xmltree.cc
index bf93151..d5ce74a 100644
--- a/libopie/xmltree.cc
+++ b/libopie/xmltree.cc
@@ -1,149 +1,149 @@
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 20
21#include "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
27namespace 27namespace
28{ 28{
29 29
30/** 30/**
31 Encode an attribute value upon saving. 31 Encode an attribute value upon saving.
32 replaces '"' with "&quot" 32 replaces '"' with "&quot"
33 replaces '<' with "&lt" 33 replaces '<' with "&lt"
34 replaces '&' with "&amp" 34 replaces '&' with "&amp"
35 replaces '>' with "&gt" 35 replaces '>' with "&gt"
36*/ 36*/
37QString encodeAttr( const QString& str ) 37QString encodeAttr( const QString& str )
38{ 38{
39 QString encAttr( str ); // cause of the const parameter 39 QString encAttr( str ); // cause of the const parameter
40 encAttr = encAttr.replace( QRegExp( "[<]" ), "&lt" ); 40 encAttr = encAttr.replace( QRegExp( "[<]" ), "&lt" );
41 encAttr = encAttr.replace( QRegExp( "[>]" ), "&gt" ); 41 encAttr = encAttr.replace( QRegExp( "[>]" ), "&gt" );
42 encAttr = encAttr.replace( QRegExp( "[\"]" ), "&quot" ); 42 encAttr = encAttr.replace( QRegExp( "[\"]" ), "&quot" );
43 encAttr = encAttr.replace( QRegExp( "[&]" ), "&amp" ); 43 encAttr = encAttr.replace( QRegExp( "[&]" ), "&amp" );
44 return encAttr; 44 return encAttr;
45} 45}
46 46
47} 47}
48 48
49XMLElement::XMLElement() 49XMLElement::XMLElement()
50 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) 50 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 )
51{ 51{
52} 52}
53 53
54XMLElement::~XMLElement() 54XMLElement::~XMLElement()
55{ 55{
56 XMLElement *n = m_first; 56 XMLElement *n = m_first;
57 57
58 while ( n ) 58 while ( n )
59 { 59 {
60 XMLElement *tmp = n; 60 XMLElement *tmp = n;
61 n = n->m_next; 61 n = n->m_next;
62 delete tmp; 62 delete tmp;
63 } 63 }
64} 64}
65 65
66void XMLElement::appendChild( XMLElement *child ) 66void XMLElement::appendChild( XMLElement *child )
67{ 67{
68 if ( child->m_parent ) 68 if ( child->m_parent )
69 child->m_parent->removeChild( child ); 69 child->m_parent->removeChild( child );
70 70
71 child->m_parent = this; 71 child->m_parent = this;
72 72
73 if ( m_last ) 73 if ( m_last )
74 m_last->m_next = child; 74 m_last->m_next = child;
75 75
76 child->m_prev = m_last; 76 child->m_prev = m_last;
77 77
78 if ( !m_first ) 78 if ( !m_first )
79 m_first = child; 79 m_first = child;
80 80
81 m_last = child; 81 m_last = child;
82} 82}
83 83
84void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) 84void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild )
85{ 85{
86 assert( newChild != refChild ); 86 assert( newChild != refChild );
87 87
88 if ( refChild == m_last ) 88 if ( refChild == m_last )
89 { 89 {
90 appendChild( newChild ); 90 appendChild( newChild );
91 return; 91 return;
92 } 92 }
93 93
94 assert( refChild ); 94 assert( refChild );
95 assert( refChild->m_parent ); 95 assert( refChild->m_parent );
96 assert( refChild->m_parent == this ); 96 assert( refChild->m_parent == this );
97 97
98 if ( newChild->m_parent && newChild != refChild ) 98 if ( newChild->m_parent && newChild != refChild )
99 newChild->m_parent->removeChild( newChild ); 99 newChild->m_parent->removeChild( newChild );
100 100
101 newChild->m_parent = this; 101 newChild->m_parent = this;
102 102
103 XMLElement *next = refChild->m_next; 103 XMLElement *next = refChild->m_next;
104 104
105 refChild->m_next = newChild; 105 refChild->m_next = newChild;
106 106
107 newChild->m_prev = refChild; 107 newChild->m_prev = refChild;
108 newChild->m_next = next; 108 newChild->m_next = next;
109 109
110 if ( next ) 110 if ( next )
111 next->m_prev = newChild; 111 next->m_prev = newChild;
112} 112}
113 113
114void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) 114void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild )
115{ 115{
116 assert( refChild ); 116 assert( refChild );
117 assert( refChild->m_parent ); 117 assert( refChild->m_parent );
118 assert( refChild->m_parent == this ); 118 assert( refChild->m_parent == this );
119 assert( newChild != refChild ); 119 assert( newChild != refChild );
120 120
121 if ( newChild->m_parent && newChild != refChild ) 121 if ( newChild->m_parent && newChild != refChild )
122 newChild->m_parent->removeChild( newChild ); 122 newChild->m_parent->removeChild( newChild );
123 123
124 newChild->m_parent = this; 124 newChild->m_parent = this;
125 125
126 XMLElement *prev = refChild->m_prev; 126 XMLElement *prev = refChild->m_prev;
127 127
128 refChild->m_prev = newChild; 128 refChild->m_prev = newChild;
129 129
130 newChild->m_prev = prev; 130 newChild->m_prev = prev;
131 newChild->m_next = refChild; 131 newChild->m_next = refChild;
132 132
133 if ( prev ) 133 if ( prev )
134 prev->m_next = newChild; 134 prev->m_next = newChild;
135 135
136 if ( refChild == m_first ) 136 if ( refChild == m_first )
137 m_first = newChild; 137 m_first = newChild;
138} 138}
139 139
140void XMLElement::removeChild( XMLElement *child ) 140void XMLElement::removeChild( XMLElement *child )
141{ 141{
142 if ( child->m_parent != this ) 142 if ( child->m_parent != this )
143 return; 143 return;
144 144
145 if ( m_first == child ) 145 if ( m_first == child )
146 m_first = child->m_next; 146 m_first = child->m_next;
147 147
148 if ( m_last == child ) 148 if ( m_last == child )
149 m_last = child->m_prev; 149 m_last = child->m_prev;