Updating Doxygen styling and Licenses
[baulk.git] / src / Common / baulkxml.h
blob9f9ba29f16aab4f7b835fdff9806918aa7512678
1 // Baulk - Common - Baulk XML Configuration Reader/Writer
2 //
3 // Baulk - Copyright (C) 2008 - Jacob Alexander
4 //
5 // Baulk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version, including version 3 of the License.
9 //
10 // Baulk 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
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __BAULKXML_H
19 #define __BAULKXML_H
21 #include <QDir>
22 #include <QDomAttr>
23 #include <QDomDocument>
24 #include <QDomElement>
25 #include <QDomNode>
26 #include <QFile>
27 #include <QObject>
28 #include <QTextStream>
29 #include <QVariant>
31 //! Reads/Writes custom XML Configuration files for Baulk.
32 /*!
33 * Custom XML Configuration class for reading and writing configuration files in Baulk and its sub-projects
35 class BaulkXML : public QObject {
36 Q_OBJECT
38 public:
39 BaulkXML( QString configName, QObject *parent = 0 );
40 ~BaulkXML();
42 //! Save Config to Disk
43 bool saveConfig();
45 //! Checks for successful XML load
46 bool loadSuccessful();
48 //! Load Option
49 QVariant option( QString settingName, QString propertyKey = "", QVariant property = QVariant(""), bool warnOnNotFound = true );
50 //! Save Option
51 void setOption( QString settingName, QVariant value, QString propertyKey = "", QVariant properties = QVariant("") );
53 //! Current Profile
54 /*!
55 * Profiles allow for different sets of options in the same configuration file.
57 QString profile();
58 //! Set options profile to use
59 void setProfile( QString profileName );
61 private:
62 bool loadConfig( QString configName );
63 bool loaded;
65 QString errorName() const { return tr("BaulkXML"); }
67 bool settingSearch( QString settingName, QString propertyKey = "", QVariant property = QVariant("") );
69 QDir configDir;
70 QDomAttr xmlDocElementProperty;
71 QDomDocument *xmlDoc;
72 QDomElement xmlDocElementProfile;
73 QDomElement xmlDocElementRoot;
74 QDomElement xmlDocElementSetting;
75 QDomText xmlDocElementSettingText;
76 QFile configFile;
77 QString currentProfile;
79 QStringList msgList;
81 void prepareConfig();
84 #endif