Diffstat (limited to 'libopie2/opiepim/core/backends/private/xmltree.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/backends/private/xmltree.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/backends/private/xmltree.h b/libopie2/opiepim/core/backends/private/xmltree.h new file mode 100644 index 0000000..9817a02 --- a/dev/null +++ b/libopie2/opiepim/core/backends/private/xmltree.h | |||
@@ -0,0 +1,122 @@ | |||
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 | namespace Opie { | ||
29 | namespace Pim { | ||
30 | namespace Private{ | ||
31 | |||
32 | /** | ||
33 | * A small xml lib written by Simon Hausmann. | ||
34 | */ | ||
35 | class XMLElement | ||
36 | { | ||
37 | public: | ||
38 | typedef QMap<QString, QString> AttributeMap; | ||
39 | |||
40 | /** | ||
41 | * The constructor of XMLElement | ||
42 | */ | ||
43 | XMLElement(); | ||
44 | ~XMLElement(); | ||
45 | |||
46 | /** appendChild appends a child to the XMLElement behind the last element. | ||
47 | * The ownership of the child get's transfered to the | ||
48 | * this XMLElement. | ||
49 | * If child is already the child of another parent | ||
50 | * it's get removed from the other parent first. | ||
51 | */ | ||
52 | void appendChild( XMLElement *child ); | ||
53 | |||
54 | /** inserts newChild after refChild. If newChild is the child | ||
55 | * of another parent the child will get removed. | ||
56 | * The ownership of child gets transfered. | ||
57 | * | ||
58 | */ | ||
59 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | ||
60 | |||
61 | /** same as insertAfter but the element get's inserted before refChild. | ||
62 | * | ||
63 | */ | ||
64 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | ||
65 | |||
66 | /** removeChild removes the child from the XMLElement. | ||
67 | * The ownership gets dropped. You need to delete the | ||
68 | * child yourself. | ||
69 | */ | ||
70 | void removeChild( XMLElement *child ); | ||
71 | |||
72 | /** parent() returns the parent of this XMLElement | ||
73 | * If there is no parent 0l gets returned | ||
74 | */ | ||
75 | XMLElement *parent() const { return m_parent; } | ||
76 | XMLElement *firstChild() const { return m_first; } | ||
77 | XMLElement *nextChild() const { return m_next; } | ||
78 | XMLElement *prevChild() const { return m_prev; } | ||
79 | XMLElement *lastChild() const { return m_last; } | ||
80 | |||
81 | void setTagName( const QString &tag ) { m_tag = tag; } | ||
82 | QString tagName() const { return m_tag; } | ||
83 | |||
84 | void setValue( const QString &val ) { m_value = val; } | ||
85 | QString value() const { return m_value; } | ||
86 | |||
87 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | ||
88 | AttributeMap attributes() const { return m_attributes; } | ||
89 | AttributeMap &attributes() { return m_attributes; } | ||
90 | |||
91 | QString attribute( const QString & ) const; | ||
92 | void setAttribute( const QString &attr, const QString &value ); | ||
93 | void save( QTextStream &stream, uint indent = 0 ); | ||
94 | |||
95 | XMLElement *namedItem( const QString &name ); | ||
96 | |||
97 | XMLElement *clone() const; | ||
98 | |||
99 | static XMLElement *load( const QString &fileName ); | ||
100 | |||
101 | private: | ||
102 | QString m_tag; | ||
103 | QString m_value; | ||
104 | AttributeMap m_attributes; | ||
105 | |||
106 | XMLElement *m_parent; | ||
107 | XMLElement *m_next; | ||
108 | XMLElement *m_prev; | ||
109 | XMLElement *m_first; | ||
110 | XMLElement *m_last; | ||
111 | |||
112 | XMLElement( const XMLElement &rhs ); | ||
113 | XMLElement &operator=( const XMLElement &rhs ); | ||
114 | class Private; | ||
115 | Private* d; | ||
116 | }; | ||
117 | |||
118 | } | ||
119 | } | ||
120 | } // namespace Opie | ||
121 | |||
122 | #endif | ||