author | harlekin <harlekin> | 2002-03-19 00:18:04 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-19 00:18:04 (UTC) |
commit | 342ac04976065864b351c6b36087a483a8932da7 (patch) (unidiff) | |
tree | 646a89071882378786532ff587ac0e6e8fd0df03 | |
parent | 02bd3d07a8949bdfe0fe708ff8f3c01bc84fab08 (diff) | |
download | opie-342ac04976065864b351c6b36087a483a8932da7.zip opie-342ac04976065864b351c6b36087a483a8932da7.tar.gz opie-342ac04976065864b351c6b36087a483a8932da7.tar.bz2 |
along with tododb
-rw-r--r-- | include/opie/xmltree.h | 2 | ||||
-rw-r--r-- | libopie/xmltree.cc | 42 | ||||
-rw-r--r-- | libopie/xmltree.h | 2 | ||||
-rw-r--r-- | libopie2/opiecore/xmltree.cc | 42 | ||||
-rw-r--r-- | libopie2/opiecore/xmltree.h | 2 |
5 files changed, 40 insertions, 50 deletions
diff --git a/include/opie/xmltree.h b/include/opie/xmltree.h index 7f1b7b7..7f50365 100644 --- a/include/opie/xmltree.h +++ b/include/opie/xmltree.h | |||
@@ -85,4 +85,6 @@ public: | |||
85 | AttributeMap &attributes() { return m_attributes; } | 85 | AttributeMap &attributes() { return m_attributes; } |
86 | 86 | ||
87 | QString attribute(const QString &)const; | ||
88 | void setAttribute( const QString &attr, const QString &value ); | ||
87 | void save( QTextStream &stream, uint indent = 0 ); | 89 | void save( QTextStream &stream, uint indent = 0 ); |
88 | 90 | ||
diff --git a/libopie/xmltree.cc b/libopie/xmltree.cc index d5ce74a..3d03cc6 100644 --- a/libopie/xmltree.cc +++ b/libopie/xmltree.cc | |||
@@ -18,5 +18,5 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | #include <qpe/stringutil.h> | |
21 | #include <opie/xmltree.h> | 21 | #include <opie/xmltree.h> |
22 | 22 | ||
@@ -25,25 +25,4 @@ | |||
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | namespace | ||
28 | { | ||
29 | |||
30 | /** | ||
31 | Encode an attribute value upon saving. | ||
32 | replaces '"' with """ | ||
33 | replaces '<' with "<" | ||
34 | replaces '&' with "&" | ||
35 | replaces '>' with ">" | ||
36 | */ | ||
37 | QString encodeAttr( const QString& str ) | ||
38 | { | ||
39 | QString encAttr( str ); // cause of the const parameter | ||
40 | encAttr = encAttr.replace( QRegExp( "[<]" ), "<" ); | ||
41 | encAttr = encAttr.replace( QRegExp( "[>]" ), ">" ); | ||
42 | encAttr = encAttr.replace( QRegExp( "[\"]" ), """ ); | ||
43 | encAttr = encAttr.replace( QRegExp( "[&]" ), "&" ); | ||
44 | return encAttr; | ||
45 | } | ||
46 | |||
47 | } | ||
48 | 27 | ||
49 | XMLElement::XMLElement() | 28 | XMLElement::XMLElement() |
@@ -111,5 +90,16 @@ void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | |||
111 | next->m_prev = newChild; | 90 | next->m_prev = newChild; |
112 | } | 91 | } |
113 | 92 | QString XMLElement::attribute(const QString &attr )const | |
93 | { | ||
94 | if ( !m_attributes.contains( attr ) ) | ||
95 | return QString::null; | ||
96 | AttributeMap::ConstIterator it = m_attributes.find( attr ); | ||
97 | return it.data(); | ||
98 | } | ||
99 | void XMLElement::setAttribute(const QString &attr, const QString &value ) | ||
100 | { | ||
101 | m_attributes.remove( attr ); | ||
102 | m_attributes.insert( attr, value ); | ||
103 | } | ||
114 | void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) | 104 | void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) |
115 | { | 105 | { |
@@ -164,5 +154,5 @@ void XMLElement::save( QTextStream &s, uint indent ) | |||
164 | if ( !m_value.isEmpty() ) | 154 | if ( !m_value.isEmpty() ) |
165 | { | 155 | { |
166 | s << encodeAttr( m_value ); | 156 | s << Qtopia::escapeString( m_value ); |
167 | return; | 157 | return; |
168 | } | 158 | } |
@@ -180,5 +170,5 @@ void XMLElement::save( QTextStream &s, uint indent ) | |||
180 | for (; it != end; ++it ) | 170 | for (; it != end; ++it ) |
181 | { | 171 | { |
182 | s << it.key() << "=\"" << encodeAttr( it.data() ) << "\""; | 172 | s << it.key() << "=\"" << Qtopia::escapeString( it.data() ) << "\""; |
183 | s << " "; | 173 | s << " "; |
184 | } | 174 | } |
@@ -325,2 +315,4 @@ XMLElement *XMLElement::load( const QString &fileName ) | |||
325 | return handler.root();; | 315 | return handler.root();; |
326 | } | 316 | } |
317 | |||
318 | |||
diff --git a/libopie/xmltree.h b/libopie/xmltree.h index 7f1b7b7..7f50365 100644 --- a/libopie/xmltree.h +++ b/libopie/xmltree.h | |||
@@ -85,4 +85,6 @@ public: | |||
85 | AttributeMap &attributes() { return m_attributes; } | 85 | AttributeMap &attributes() { return m_attributes; } |
86 | 86 | ||
87 | QString attribute(const QString &)const; | ||
88 | void setAttribute( const QString &attr, const QString &value ); | ||
87 | void save( QTextStream &stream, uint indent = 0 ); | 89 | void save( QTextStream &stream, uint indent = 0 ); |
88 | 90 | ||
diff --git a/libopie2/opiecore/xmltree.cc b/libopie2/opiecore/xmltree.cc index d5ce74a..3d03cc6 100644 --- a/libopie2/opiecore/xmltree.cc +++ b/libopie2/opiecore/xmltree.cc | |||
@@ -18,5 +18,5 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | #include <qpe/stringutil.h> | |
21 | #include <opie/xmltree.h> | 21 | #include <opie/xmltree.h> |
22 | 22 | ||
@@ -25,25 +25,4 @@ | |||
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | namespace | ||
28 | { | ||
29 | |||
30 | /** | ||
31 | Encode an attribute value upon saving. | ||
32 | replaces '"' with """ | ||
33 | replaces '<' with "<" | ||
34 | replaces '&' with "&" | ||
35 | replaces '>' with ">" | ||
36 | */ | ||
37 | QString encodeAttr( const QString& str ) | ||
38 | { | ||
39 | QString encAttr( str ); // cause of the const parameter | ||
40 | encAttr = encAttr.replace( QRegExp( "[<]" ), "<" ); | ||
41 | encAttr = encAttr.replace( QRegExp( "[>]" ), ">" ); | ||
42 | encAttr = encAttr.replace( QRegExp( "[\"]" ), """ ); | ||
43 | encAttr = encAttr.replace( QRegExp( "[&]" ), "&" ); | ||
44 | return encAttr; | ||
45 | } | ||
46 | |||
47 | } | ||
48 | 27 | ||
49 | XMLElement::XMLElement() | 28 | XMLElement::XMLElement() |
@@ -111,5 +90,16 @@ void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | |||
111 | next->m_prev = newChild; | 90 | next->m_prev = newChild; |
112 | } | 91 | } |
113 | 92 | QString XMLElement::attribute(const QString &attr )const | |
93 | { | ||
94 | if ( !m_attributes.contains( attr ) ) | ||
95 | return QString::null; | ||
96 | AttributeMap::ConstIterator it = m_attributes.find( attr ); | ||
97 | return it.data(); | ||
98 | } | ||
99 | void XMLElement::setAttribute(const QString &attr, const QString &value ) | ||
100 | { | ||
101 | m_attributes.remove( attr ); | ||
102 | m_attributes.insert( attr, value ); | ||
103 | } | ||
114 | void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) | 104 | void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) |
115 | { | 105 | { |
@@ -164,5 +154,5 @@ void XMLElement::save( QTextStream &s, uint indent ) | |||
164 | if ( !m_value.isEmpty() ) | 154 | if ( !m_value.isEmpty() ) |
165 | { | 155 | { |
166 | s << encodeAttr( m_value ); | 156 | s << Qtopia::escapeString( m_value ); |
167 | return; | 157 | return; |
168 | } | 158 | } |
@@ -180,5 +170,5 @@ void XMLElement::save( QTextStream &s, uint indent ) | |||
180 | for (; it != end; ++it ) | 170 | for (; it != end; ++it ) |
181 | { | 171 | { |
182 | s << it.key() << "=\"" << encodeAttr( it.data() ) << "\""; | 172 | s << it.key() << "=\"" << Qtopia::escapeString( it.data() ) << "\""; |
183 | s << " "; | 173 | s << " "; |
184 | } | 174 | } |
@@ -325,2 +315,4 @@ XMLElement *XMLElement::load( const QString &fileName ) | |||
325 | return handler.root();; | 315 | return handler.root();; |
326 | } | 316 | } |
317 | |||
318 | |||
diff --git a/libopie2/opiecore/xmltree.h b/libopie2/opiecore/xmltree.h index 7f1b7b7..7f50365 100644 --- a/libopie2/opiecore/xmltree.h +++ b/libopie2/opiecore/xmltree.h | |||
@@ -85,4 +85,6 @@ public: | |||
85 | AttributeMap &attributes() { return m_attributes; } | 85 | AttributeMap &attributes() { return m_attributes; } |
86 | 86 | ||
87 | QString attribute(const QString &)const; | ||
88 | void setAttribute( const QString &attr, const QString &value ); | ||
87 | void save( QTextStream &stream, uint indent = 0 ); | 89 | void save( QTextStream &stream, uint indent = 0 ); |
88 | 90 | ||