author | kergoth <kergoth> | 2002-03-16 04:59:45 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-03-16 04:59:45 (UTC) |
commit | a4ae0b213389af1ca002b684d2493786311ab60f (patch) (unidiff) | |
tree | 67b729a64a50ed2dcab3cb5a6367d7ea72b15d80 | |
parent | 20cbfeefd68221f7b6f9dd512c6ff3e9a9484af2 (diff) | |
download | opie-a4ae0b213389af1ca002b684d2493786311ab60f.zip opie-a4ae0b213389af1ca002b684d2493786311ab60f.tar.gz opie-a4ae0b213389af1ca002b684d2493786311ab60f.tar.bz2 |
mark: added .pro for libopie. moved .h to includedir.
-rw-r--r-- | include/opie/xmltree.h | 110 | ||||
-rw-r--r-- | libopie/libopie.pro | 7 | ||||
-rw-r--r-- | libopie/xmltree.cc | 2 | ||||
-rw-r--r-- | libopie/xmltree.h | 110 | ||||
-rw-r--r-- | libopie2/opiecore/xmltree.cc | 2 | ||||
-rw-r--r-- | libopie2/opiecore/xmltree.h | 110 |
6 files changed, 339 insertions, 2 deletions
diff --git a/include/opie/xmltree.h b/include/opie/xmltree.h new file mode 100644 index 0000000..7f1b7b7 --- a/dev/null +++ b/include/opie/xmltree.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /* This file is part of the KDE project | ||
2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
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 | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #ifndef __bookmarks_h__ | ||
22 | #define __bookmarks_h__ | ||
23 | |||
24 | #include <qstring.h> | ||
25 | #include <qmap.h> | ||
26 | #include <qtextstream.h> | ||
27 | |||
28 | /** | ||
29 | * A small xml lib written by Simon Hausmann. | ||
30 | */ | ||
31 | class XMLElement | ||
32 | { | ||
33 | public: | ||
34 | typedef QMap<QString, QString> AttributeMap; | ||
35 | |||
36 | /** | ||
37 | * The constructor of XMLElement | ||
38 | */ | ||
39 | XMLElement(); | ||
40 | ~XMLElement(); | ||
41 | |||
42 | /** appendChild appends a child to the XMLElement behind the last element. | ||
43 | * The ownership of the child get's transfered to the | ||
44 | * this XMLElement. | ||
45 | * If child is already the child of another parent | ||
46 | * it's get removed from the other parent first. | ||
47 | */ | ||
48 | void appendChild( XMLElement *child ); | ||
49 | |||
50 | /** inserts newChild after refChild. If newChild is the child | ||
51 | * of another parent the child will get removed. | ||
52 | * The ownership of child gets transfered. | ||
53 | * | ||
54 | */ | ||
55 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | ||
56 | |||
57 | /** same as insertAfter but the element get's inserted before refChild. | ||
58 | * | ||
59 | */ | ||
60 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | ||
61 | |||
62 | /** removeChild removes the child from the XMLElement. | ||
63 | * The ownership gets dropped. You need to delete the | ||
64 | * child yourself. | ||
65 | */ | ||
66 | void removeChild( XMLElement *child ); | ||
67 | |||
68 | /** parent() returns the parent of this XMLElement | ||
69 | * If there is no parent 0l gets returned | ||
70 | */ | ||
71 | XMLElement *parent() const { return m_parent; } | ||
72 | XMLElement *firstChild() const { return m_first; } | ||
73 | XMLElement *nextChild() const { return m_next; } | ||
74 | XMLElement *prevChild() const { return m_prev; } | ||
75 | XMLElement *lastChild() const { return m_last; } | ||
76 | |||
77 | void setTagName( const QString &tag ) { m_tag = tag; } | ||
78 | QString tagName() const { return m_tag; } | ||
79 | |||
80 | void setValue( const QString &val ) { m_value = val; } | ||
81 | QString value() const { return m_value; } | ||
82 | |||
83 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | ||
84 | AttributeMap attributes() const { return m_attributes; } | ||
85 | AttributeMap &attributes() { return m_attributes; } | ||
86 | |||
87 | void save( QTextStream &stream, uint indent = 0 ); | ||
88 | |||
89 | XMLElement *namedItem( const QString &name ); | ||
90 | |||
91 | XMLElement *clone() const; | ||
92 | |||
93 | static XMLElement *load( const QString &fileName ); | ||
94 | |||
95 | private: | ||
96 | QString m_tag; | ||
97 | QString m_value; | ||
98 | AttributeMap m_attributes; | ||
99 | |||
100 | XMLElement *m_parent; | ||
101 | XMLElement *m_next; | ||
102 | XMLElement *m_prev; | ||
103 | XMLElement *m_first; | ||
104 | XMLElement *m_last; | ||
105 | |||
106 | XMLElement( const XMLElement &rhs ); | ||
107 | XMLElement &operator=( const XMLElement &rhs ); | ||
108 | }; | ||
109 | |||
110 | #endif | ||
diff --git a/libopie/libopie.pro b/libopie/libopie.pro new file mode 100644 index 0000000..95ec145 --- a/dev/null +++ b/libopie/libopie.pro | |||
@@ -0,0 +1,7 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qte warn_on release | ||
3 | HEADERS = $(OPIEDIR)/include/opie/xmltree.h | ||
4 | SOURCES = xmltree.cc | ||
5 | TARGET = opie | ||
6 | INCLUDEPATH += $(OPIEDIR)/include | ||
7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | ||
diff --git a/libopie/xmltree.cc b/libopie/xmltree.cc index bf93151..d5ce74a 100644 --- a/libopie/xmltree.cc +++ b/libopie/xmltree.cc | |||
@@ -1,85 +1,85 @@ | |||
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 | ||
27 | namespace | 27 | namespace |
28 | { | 28 | { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | Encode an attribute value upon saving. | 31 | Encode an attribute value upon saving. |
32 | replaces '"' with """ | 32 | replaces '"' with """ |
33 | replaces '<' with "<" | 33 | replaces '<' with "<" |
34 | replaces '&' with "&" | 34 | replaces '&' with "&" |
35 | replaces '>' with ">" | 35 | replaces '>' with ">" |
36 | */ | 36 | */ |
37 | QString encodeAttr( const QString& str ) | 37 | QString 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( "[<]" ), "<" ); | 40 | encAttr = encAttr.replace( QRegExp( "[<]" ), "<" ); |
41 | encAttr = encAttr.replace( QRegExp( "[>]" ), ">" ); | 41 | encAttr = encAttr.replace( QRegExp( "[>]" ), ">" ); |
42 | encAttr = encAttr.replace( QRegExp( "[\"]" ), """ ); | 42 | encAttr = encAttr.replace( QRegExp( "[\"]" ), """ ); |
43 | encAttr = encAttr.replace( QRegExp( "[&]" ), "&" ); | 43 | encAttr = encAttr.replace( QRegExp( "[&]" ), "&" ); |
44 | return encAttr; | 44 | return encAttr; |
45 | } | 45 | } |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | XMLElement::XMLElement() | 49 | XMLElement::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 | ||
54 | XMLElement::~XMLElement() | 54 | XMLElement::~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 | ||
66 | void XMLElement::appendChild( XMLElement *child ) | 66 | void 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 | ||
84 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | 84 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) |
85 | { | 85 | { |
diff --git a/libopie/xmltree.h b/libopie/xmltree.h new file mode 100644 index 0000000..7f1b7b7 --- a/dev/null +++ b/libopie/xmltree.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /* This file is part of the KDE project | ||
2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
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 | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #ifndef __bookmarks_h__ | ||
22 | #define __bookmarks_h__ | ||
23 | |||
24 | #include <qstring.h> | ||
25 | #include <qmap.h> | ||
26 | #include <qtextstream.h> | ||
27 | |||
28 | /** | ||
29 | * A small xml lib written by Simon Hausmann. | ||
30 | */ | ||
31 | class XMLElement | ||
32 | { | ||
33 | public: | ||
34 | typedef QMap<QString, QString> AttributeMap; | ||
35 | |||
36 | /** | ||
37 | * The constructor of XMLElement | ||
38 | */ | ||
39 | XMLElement(); | ||
40 | ~XMLElement(); | ||
41 | |||
42 | /** appendChild appends a child to the XMLElement behind the last element. | ||
43 | * The ownership of the child get's transfered to the | ||
44 | * this XMLElement. | ||
45 | * If child is already the child of another parent | ||
46 | * it's get removed from the other parent first. | ||
47 | */ | ||
48 | void appendChild( XMLElement *child ); | ||
49 | |||
50 | /** inserts newChild after refChild. If newChild is the child | ||
51 | * of another parent the child will get removed. | ||
52 | * The ownership of child gets transfered. | ||
53 | * | ||
54 | */ | ||
55 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | ||
56 | |||
57 | /** same as insertAfter but the element get's inserted before refChild. | ||
58 | * | ||
59 | */ | ||
60 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | ||
61 | |||
62 | /** removeChild removes the child from the XMLElement. | ||
63 | * The ownership gets dropped. You need to delete the | ||
64 | * child yourself. | ||
65 | */ | ||
66 | void removeChild( XMLElement *child ); | ||
67 | |||
68 | /** parent() returns the parent of this XMLElement | ||
69 | * If there is no parent 0l gets returned | ||
70 | */ | ||
71 | XMLElement *parent() const { return m_parent; } | ||
72 | XMLElement *firstChild() const { return m_first; } | ||
73 | XMLElement *nextChild() const { return m_next; } | ||
74 | XMLElement *prevChild() const { return m_prev; } | ||
75 | XMLElement *lastChild() const { return m_last; } | ||
76 | |||
77 | void setTagName( const QString &tag ) { m_tag = tag; } | ||
78 | QString tagName() const { return m_tag; } | ||
79 | |||
80 | void setValue( const QString &val ) { m_value = val; } | ||
81 | QString value() const { return m_value; } | ||
82 | |||
83 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | ||
84 | AttributeMap attributes() const { return m_attributes; } | ||
85 | AttributeMap &attributes() { return m_attributes; } | ||
86 | |||
87 | void save( QTextStream &stream, uint indent = 0 ); | ||
88 | |||
89 | XMLElement *namedItem( const QString &name ); | ||
90 | |||
91 | XMLElement *clone() const; | ||
92 | |||
93 | static XMLElement *load( const QString &fileName ); | ||
94 | |||
95 | private: | ||
96 | QString m_tag; | ||
97 | QString m_value; | ||
98 | AttributeMap m_attributes; | ||
99 | |||
100 | XMLElement *m_parent; | ||
101 | XMLElement *m_next; | ||
102 | XMLElement *m_prev; | ||
103 | XMLElement *m_first; | ||
104 | XMLElement *m_last; | ||
105 | |||
106 | XMLElement( const XMLElement &rhs ); | ||
107 | XMLElement &operator=( const XMLElement &rhs ); | ||
108 | }; | ||
109 | |||
110 | #endif | ||
diff --git a/libopie2/opiecore/xmltree.cc b/libopie2/opiecore/xmltree.cc index bf93151..d5ce74a 100644 --- a/libopie2/opiecore/xmltree.cc +++ b/libopie2/opiecore/xmltree.cc | |||
@@ -1,85 +1,85 @@ | |||
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 | ||
27 | namespace | 27 | namespace |
28 | { | 28 | { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | Encode an attribute value upon saving. | 31 | Encode an attribute value upon saving. |
32 | replaces '"' with """ | 32 | replaces '"' with """ |
33 | replaces '<' with "<" | 33 | replaces '<' with "<" |
34 | replaces '&' with "&" | 34 | replaces '&' with "&" |
35 | replaces '>' with ">" | 35 | replaces '>' with ">" |
36 | */ | 36 | */ |
37 | QString encodeAttr( const QString& str ) | 37 | QString 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( "[<]" ), "<" ); | 40 | encAttr = encAttr.replace( QRegExp( "[<]" ), "<" ); |
41 | encAttr = encAttr.replace( QRegExp( "[>]" ), ">" ); | 41 | encAttr = encAttr.replace( QRegExp( "[>]" ), ">" ); |
42 | encAttr = encAttr.replace( QRegExp( "[\"]" ), """ ); | 42 | encAttr = encAttr.replace( QRegExp( "[\"]" ), """ ); |
43 | encAttr = encAttr.replace( QRegExp( "[&]" ), "&" ); | 43 | encAttr = encAttr.replace( QRegExp( "[&]" ), "&" ); |
44 | return encAttr; | 44 | return encAttr; |
45 | } | 45 | } |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | XMLElement::XMLElement() | 49 | XMLElement::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 | ||
54 | XMLElement::~XMLElement() | 54 | XMLElement::~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 | ||
66 | void XMLElement::appendChild( XMLElement *child ) | 66 | void 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 | ||
84 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | 84 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) |
85 | { | 85 | { |
diff --git a/libopie2/opiecore/xmltree.h b/libopie2/opiecore/xmltree.h new file mode 100644 index 0000000..7f1b7b7 --- a/dev/null +++ b/libopie2/opiecore/xmltree.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /* This file is part of the KDE project | ||
2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
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 | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #ifndef __bookmarks_h__ | ||
22 | #define __bookmarks_h__ | ||
23 | |||
24 | #include <qstring.h> | ||
25 | #include <qmap.h> | ||
26 | #include <qtextstream.h> | ||
27 | |||
28 | /** | ||
29 | * A small xml lib written by Simon Hausmann. | ||
30 | */ | ||
31 | class XMLElement | ||
32 | { | ||
33 | public: | ||
34 | typedef QMap<QString, QString> AttributeMap; | ||
35 | |||
36 | /** | ||
37 | * The constructor of XMLElement | ||
38 | */ | ||
39 | XMLElement(); | ||
40 | ~XMLElement(); | ||
41 | |||
42 | /** appendChild appends a child to the XMLElement behind the last element. | ||
43 | * The ownership of the child get's transfered to the | ||
44 | * this XMLElement. | ||
45 | * If child is already the child of another parent | ||
46 | * it's get removed from the other parent first. | ||
47 | */ | ||
48 | void appendChild( XMLElement *child ); | ||
49 | |||
50 | /** inserts newChild after refChild. If newChild is the child | ||
51 | * of another parent the child will get removed. | ||
52 | * The ownership of child gets transfered. | ||
53 | * | ||
54 | */ | ||
55 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | ||
56 | |||
57 | /** same as insertAfter but the element get's inserted before refChild. | ||
58 | * | ||
59 | */ | ||
60 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | ||
61 | |||
62 | /** removeChild removes the child from the XMLElement. | ||
63 | * The ownership gets dropped. You need to delete the | ||
64 | * child yourself. | ||
65 | */ | ||
66 | void removeChild( XMLElement *child ); | ||
67 | |||
68 | /** parent() returns the parent of this XMLElement | ||
69 | * If there is no parent 0l gets returned | ||
70 | */ | ||
71 | XMLElement *parent() const { return m_parent; } | ||
72 | XMLElement *firstChild() const { return m_first; } | ||
73 | XMLElement *nextChild() const { return m_next; } | ||
74 | XMLElement *prevChild() const { return m_prev; } | ||
75 | XMLElement *lastChild() const { return m_last; } | ||
76 | |||
77 | void setTagName( const QString &tag ) { m_tag = tag; } | ||
78 | QString tagName() const { return m_tag; } | ||
79 | |||
80 | void setValue( const QString &val ) { m_value = val; } | ||
81 | QString value() const { return m_value; } | ||
82 | |||
83 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | ||
84 | AttributeMap attributes() const { return m_attributes; } | ||
85 | AttributeMap &attributes() { return m_attributes; } | ||
86 | |||
87 | void save( QTextStream &stream, uint indent = 0 ); | ||
88 | |||
89 | XMLElement *namedItem( const QString &name ); | ||
90 | |||
91 | XMLElement *clone() const; | ||
92 | |||
93 | static XMLElement *load( const QString &fileName ); | ||
94 | |||
95 | private: | ||
96 | QString m_tag; | ||
97 | QString m_value; | ||
98 | AttributeMap m_attributes; | ||
99 | |||
100 | XMLElement *m_parent; | ||
101 | XMLElement *m_next; | ||
102 | XMLElement *m_prev; | ||
103 | XMLElement *m_first; | ||
104 | XMLElement *m_last; | ||
105 | |||
106 | XMLElement( const XMLElement &rhs ); | ||
107 | XMLElement &operator=( const XMLElement &rhs ); | ||
108 | }; | ||
109 | |||
110 | #endif | ||