qtjsonsettings/qtjsonsettings.h

60 lines
1.6 KiB
C
Raw Normal View History

2011-03-05 20:37:24 +00:00
#ifndef QTJSONSETTINGS_H
#define QTJSONSETTINGS_H
#include <QtCore/QCoreApplication>
#include <QtCore/QString>
#include <QtCore/QSettings>
class QIODevice;
#if defined(QTJSONSETTINGS_EXPORTS)
# define QTJSONSETTINGS_EXPORT Q_DECL_EXPORT
#elif defined(QTJSONSETTINGS_IMPORTS)
# define QTJSONSETTINGS_EXPORT Q_DECL_IMPORT /**/
#else
# define QTJSONSETTINGS_EXPORT /**/
#endif
/**
2015-06-05 07:38:12 +00:00
* @brief Class for storing application setting in json file. This class implements QSettings interface.
2011-03-05 20:37:24 +00:00
*
2015-06-05 07:38:12 +00:00
* @class QtJsonSettings qtjsonsettings.h
2011-03-05 20:37:24 +00:00
*/
class QTJSONSETTINGS_EXPORT QtJsonSettings: public QSettings
{
Q_OBJECT
public:
QtJsonSettings(const QString &organization, const QString &application,
QObject *parent = 0) :
QSettings(json_format, QSettings::UserScope, organization, application,
parent)
{
}
QtJsonSettings(Scope scope, const QString &organization,
const QString &application = QString(), QObject *parent = 0) :
QSettings(json_format, scope, organization, application, parent)
{
}
QtJsonSettings(const QString &fileName, QObject *parent = 0) :
QSettings(fileName, json_format, parent)
{
}
QtJsonSettings(QObject * parent = 0) :
QSettings(json_format, QSettings::UserScope,
QCoreApplication::organizationName(),
QCoreApplication::applicationName(), parent)
{
}
static const QSettings::Format json_format;
private:
static bool readJsonFile(QIODevice &device, QSettings::SettingsMap &map);
static bool writeJsonFile(QIODevice &device,
const QSettings::SettingsMap &map);
};
#endif // #ifndef QTJSONSETTINGS_H