* @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.
*
//-------------------------------------------------------------------
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
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<QByteArray, QExplicitlySharedDataPointer<IniFileSection> >::const_iterator it;
while (mValid && !file.atEnd()) {
// Current file position
- quint64 currentPos = file.pos();
+ qint64 currentPos = file.pos();
QByteArray line = file.readLine().trimmed();
// 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:")) {
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<char const>(c.unicode()));
break;
}
case QVariant::ByteArray:
}
// Current file position
- quint64 currentPos = f.pos();
+ qint64 currentPos = f.pos();
// Add the new section to the internal cache
sectionObject = new IniFileSection(currentPos);
// 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