X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Flibs%2FCommon%2Finifile.cpp;h=ebdfd73affa70de1f0c75be772a31c541613d1f3;hb=4c0329c5c2690bde28212c89029015a5da4c7e34;hp=838ff723630f057cb4a7e750a2f229877df1c83b;hpb=72ea4a16988f1c28e97064222e722f19bc31b3a6;p=evaf diff --git a/src/libs/Common/inifile.cpp b/src/libs/Common/inifile.cpp index 838ff72..ebdfd73 100644 --- a/src/libs/Common/inifile.cpp +++ b/src/libs/Common/inifile.cpp @@ -3,7 +3,7 @@ * @brief Internal implementation of the class for reading and writing parameter values in INI files. * @author Enar Vaikene * - * Copyright (c) 2011 Enar Vaikene + * Copyright (c) 2011-2019 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * @@ -37,13 +37,13 @@ using namespace eVaf::Common; //------------------------------------------------------------------- IniFile::IniFile(QString const & fileName, QIODevice::OpenMode mode) + : d(new Internal::IniFileImpl(fileName, mode)) { - d = new Internal::IniFileImpl(fileName, mode); } IniFile::~IniFile() { - delete d; + d.reset(); } bool IniFile::isValid() const @@ -96,7 +96,7 @@ IniFileImpl::~IniFileImpl() mCache.clear(); } -void IniFileImpl::updateCache(quint64 pos, qint64 diff) +void IniFileImpl::updateCache(qint64 pos, qint64 diff) { // Walk through all the sections in the cache QHash >::const_iterator it; @@ -181,7 +181,7 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil while (mValid && !file.atEnd()) { // Current file position - quint64 currentPos = file.pos(); + qint64 currentPos = file.pos(); QByteArray line = file.readLine().trimmed(); @@ -207,7 +207,7 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil // Check for the 'windows:' or 'linux:' prefix in the parameter name bool thisOsOnly = false; -#ifdef Q_OS_LINUX +#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) if (name.startsWith("windows:")) continue; if (name.startsWith("linux:")) { @@ -352,7 +352,7 @@ bool IniFileImpl::setValue(QByteArray const & paramName, QVariant const & value) if (c.unicode() < 32 || c.unicode() >= 127) valueString = QByteArray("\\0x").append(QByteArray::number(c.unicode(), 16)); else - valueString = QByteArray(1, (char const)c.unicode()); + valueString = QByteArray(1, static_cast(c.unicode())); break; } case QVariant::ByteArray: @@ -399,7 +399,7 @@ bool IniFileImpl::setValue(QByteArray const & paramName, QVariant const & value) } // Current file position - quint64 currentPos = f.pos(); + qint64 currentPos = f.pos(); // Add the new section to the internal cache sectionObject = new IniFileSection(currentPos); @@ -423,8 +423,8 @@ bool IniFileImpl::setValue(QByteArray const & paramName, QVariant const & value) // If the section is found, use the existing section object from the cache else { - quint64 currentPos; - quint64 oldPos = f.pos(); + qint64 currentPos; + qint64 oldPos = f.pos(); QString prefix; // Platform-specific prefix // Locate the parameter value