You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
850 B
C++
33 lines
850 B
C++
#ifndef QTPJSONFILE_H
|
|
#define QTPJSONFILE_H
|
|
|
|
#include "QZkJsonParser.h"
|
|
#include <QtCore\qreadwritelock.h>
|
|
|
|
class QTpJsonFile
|
|
{
|
|
public:
|
|
QTpJsonFile(const QString& fileName);
|
|
~QTpJsonFile();
|
|
|
|
int GetInt(const QString& skey, int nDefault);
|
|
void SetInt(const QString& skey, int value);
|
|
QString GetString(const QString& skey, const QString& default = "");
|
|
void SetString(const QString& skey, const QString& value);
|
|
bool Save(bool bWait = true);
|
|
private:
|
|
void Insert(const QString& skey, const QJsonValue& v) {
|
|
m_bNeedSave = true;
|
|
QWriteLocker locker(&m_wLock);
|
|
m_jsonObj.insert(skey, v);
|
|
}
|
|
private:
|
|
const static char cs_szSuffix[];
|
|
QJsonObject m_jsonObj;
|
|
QString m_fileName;
|
|
bool m_bNeedSave;
|
|
QReadWriteLock m_wLock;
|
|
};
|
|
|
|
#endif // QTPJSONFILE_H
|