lib

KoOasisSettings.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Laurent Montel <montel@kde.org>
3 David Faure <faure@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21
22#ifndef KOOASISSETTINGS_H
23#define KOOASISSETTINGS_H
24
25#include <tqdom.h>
26#include <koffice_export.h>
27
70class KOFFICECORE_EXPORT KoOasisSettings
71{
72public:
76 explicit KoOasisSettings( const TQDomDocument& doc );
77
81 KoOasisSettings( const TQDomDocument& doc, const char* officeNSURI, const char* configNSURI );
82
83 class Items;
84
89 Items itemSet( const TQString& itemSetName ) const;
90
91 class IndexedMap;
92 class NamedMap;
94 class KOFFICECORE_EXPORT Items
95 {
96 friend class KoOasisSettings;
97 friend class IndexedMap;
98 friend class NamedMap;
99 Items( const TQDomElement& elem, const KoOasisSettings* settings )
100 : m_element( elem ), m_settings( settings ) {}
101 public:
102 bool isNull() const { return m_element.isNull(); }
103
110 IndexedMap indexedMap( const TQString& itemMapName ) const;
111
118 NamedMap namedMap( const TQString& itemMapName ) const;
119
120 int parseConfigItemInt( const TQString& configName, int defValue = 0 ) const;
121 double parseConfigItemDouble( const TQString& configName, double defValue = 0 ) const;
122 TQString parseConfigItemString( const TQString& configName, const TQString& defValue = TQString() ) const;
123 bool parseConfigItemBool( const TQString& configName, bool defValue = false ) const;
124 short parseConfigItemShort( const TQString& configName, short defValue = 0 ) const;
125 long parseConfigItemLong( const TQString& configName, long defValue = 0 ) const;
126 private:
128 TQString findConfigItem( const TQString& item, bool* ok ) const;
130 TQString findConfigItem( const TQDomElement& element, const TQString& item, bool* ok ) const;
131
132 TQDomElement m_element;
133 const KoOasisSettings* m_settings;
134 };
135
137 class Map
138 {
139 public:
140 bool isNull() const { return m_element.isNull(); }
141 protected:
142 Map( const TQDomElement& elem, const KoOasisSettings* settings )
143 : m_element( elem ), m_settings( settings ) {}
144 const TQDomElement m_element;
145 const KoOasisSettings* m_settings;
146 };
147
148 class KOFFICECORE_EXPORT IndexedMap : public Map
149 {
150 friend class Items;
151 IndexedMap( const TQDomElement& elem, const KoOasisSettings* settings )
152 : Map( elem, settings ) {}
153 public:
155 Items entry( int entryIndex ) const;
156 };
157
158 class KOFFICECORE_EXPORT NamedMap : public Map
159 {
160 friend class Items;
161 NamedMap( const TQDomElement& elem, const KoOasisSettings* settings )
162 : Map( elem, settings ) {}
163 public:
165 Items entry( const TQString& entryName ) const;
166 };
167
168private:
169 friend class Items;
170 friend class IndexedMap;
171 friend class NamedMap;
172 const TQDomElement m_settingsElement;
173 const char* m_configNSURI;
174
175 class Private;
176 Private* d;
177};
178
179#endif
Represents a collection of items (config-item or maps).
IndexedMap indexedMap(const TQString &itemMapName) const
Look for the config-item-map-indexed named itemMapName and return it.
NamedMap namedMap(const TQString &itemMapName) const
Look for the config-item-map-named named mapItemName and return it.
Internal base class for IndexedMap and NamedMap.
KoOasisSettings(const TQDomDocument &doc)
Normal KoOasisSettings constructor, for an OASIS settings.xml.
Items itemSet(const TQString &itemSetName) const
Returns the toplevel item-set named itemSetName.
@ Map
TQStringVariantMap.
Definition property.h:69