Qt 4.8
Public Functions | Static Public Functions | Public Variables | Private Functions | Friends | List of all members
QConfFile Class Reference

#include <qsettings_p.h>

Public Functions

bool isWritable () const
 
ParsedSettingsMap mergedKeyMap () const
 
 ~QConfFile ()
 

Static Public Functions

static void clearCache ()
 
static QConfFilefromName (const QString &name, bool _userPerms)
 

Public Variables

ParsedSettingsMap addedKeys
 
QMutex mutex
 
QString name
 
ParsedSettingsMap originalKeys
 
QAtomicInt ref
 
ParsedSettingsMap removedKeys
 
qint64 size
 
QDateTime timeStamp
 
UnparsedSettingsMap unparsedIniSections
 
bool userPerms
 

Private Functions

QConfFileoperator= (const QConfFile &)
 
 QConfFile (const QConfFile &)
 
 QConfFile (const QString &name, bool _userPerms)
 

Friends

class QConfFile_createsItself
 

Detailed Description

Definition at line 150 of file qsettings_p.h.

Constructors and Destructors

◆ ~QConfFile()

QConfFile::~QConfFile ( )

Definition at line 229 of file qsettings.cpp.

230 {
231  if (usedHashFunc())
232  usedHashFunc()->remove(name);
233 }
QString name
Definition: qsettings_p.h:161

◆ QConfFile() [1/2]

QConfFile::QConfFile ( const QConfFile )
private

Referenced by fromName().

◆ QConfFile() [2/2]

QConfFile::QConfFile ( const QString name,
bool  _userPerms 
)
private

Definition at line 223 of file qsettings.cpp.

224  : name(fileName), size(0), ref(1), userPerms(_userPerms)
225 {
226  usedHashFunc()->insert(name, this);
227 }
QString name
Definition: qsettings_p.h:161
bool userPerms
Definition: qsettings_p.h:170
QAtomicInt ref
Definition: qsettings_p.h:168
qint64 size
Definition: qsettings_p.h:163
static QString fileName(const QString &fileUrl)

Functions

◆ clearCache()

void QConfFile::clearCache ( )
static

Definition at line 293 of file qsettings.cpp.

294 {
295  QMutexLocker locker(globalMutex());
296  unusedCacheFunc()->clear();
297 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ fromName()

QConfFile * QConfFile::fromName ( const QString name,
bool  _userPerms 
)
static

Definition at line 272 of file qsettings.cpp.

Referenced by QConfFileSettingsPrivate::QConfFileSettingsPrivate().

273 {
275 
276  ConfFileHash *usedHash = usedHashFunc();
277  ConfFileCache *unusedCache = unusedCacheFunc();
278 
279  QConfFile *confFile = 0;
280  QMutexLocker locker(globalMutex());
281 
282  if (!(confFile = usedHash->value(absPath))) {
283  if ((confFile = unusedCache->take(absPath)))
284  usedHash->insert(absPath, confFile);
285  }
286  if (confFile) {
287  confFile->ref.ref();
288  return confFile;
289  }
290  return new QConfFile(absPath, _userPerms);
291 }
QConfFile(const QConfFile &)
Definition: qcache.h:54
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
bool ref()
Atomically increments the value of this QAtomicInt.
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
T * take(const Key &key)
Definition: qcache.h:167
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QAtomicInt ref
Definition: qsettings_p.h:168
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
static QString fileName(const QString &fileUrl)

◆ isWritable()

bool QConfFile::isWritable ( ) const

Definition at line 247 of file qsettings.cpp.

Referenced by QConfFileSettingsPrivate::isWritable(), and QConfFileSettingsPrivate::syncConfFile().

248 {
249  QFileInfo fileInfo(name);
250 
251 #ifndef QT_NO_TEMPORARYFILE
252  if (fileInfo.exists()) {
253 #endif
254  QFile file(name);
255  return file.open(QFile::ReadWrite);
256 #ifndef QT_NO_TEMPORARYFILE
257  } else {
258  // Create the directories to the file.
259  QDir dir(fileInfo.absolutePath());
260  if (!dir.exists()) {
261  if (!dir.mkpath(dir.absolutePath()))
262  return false;
263  }
264 
265  // we use a temporary file to avoid race conditions
266  QTemporaryFile file(name);
267  return file.open();
268  }
269 #endif
270 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
The QTemporaryFile class is an I/O device that operates on temporary files.
QString name
Definition: qsettings_p.h:161
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ mergedKeyMap()

ParsedSettingsMap QConfFile::mergedKeyMap ( ) const

Definition at line 235 of file qsettings.cpp.

Referenced by QConfFileSettingsPrivate::syncConfFile().

236 {
239 
240  for (i = removedKeys.begin(); i != removedKeys.end(); ++i)
241  result.remove(i.key());
242  for (i = addedKeys.begin(); i != addedKeys.end(); ++i)
243  result.insert(i.key(), i.value());
244  return result;
245 }
ParsedSettingsMap addedKeys
Definition: qsettings_p.h:166
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
int remove(const Key &key)
Removes all the items that have the key key from the map.
Definition: qmap.h:662
ParsedSettingsMap originalKeys
Definition: qsettings_p.h:165
ParsedSettingsMap removedKeys
Definition: qsettings_p.h:167
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
friend class const_iterator
Definition: qmap.h:369

◆ operator=()

QConfFile& QConfFile::operator= ( const QConfFile )
private

Friends and Related Functions

◆ QConfFile_createsItself

friend class QConfFile_createsItself
friend

Definition at line 179 of file qsettings_p.h.

Properties

◆ addedKeys

ParsedSettingsMap QConfFile::addedKeys

◆ mutex

QMutex QConfFile::mutex

◆ name

QString QConfFile::name

◆ originalKeys

ParsedSettingsMap QConfFile::originalKeys

◆ ref

QAtomicInt QConfFile::ref

Definition at line 168 of file qsettings_p.h.

Referenced by fromName().

◆ removedKeys

ParsedSettingsMap QConfFile::removedKeys

◆ size

qint64 QConfFile::size

Definition at line 163 of file qsettings_p.h.

Referenced by QConfFileSettingsPrivate::syncConfFile().

◆ timeStamp

QDateTime QConfFile::timeStamp

Definition at line 162 of file qsettings_p.h.

Referenced by QConfFileSettingsPrivate::syncConfFile().

◆ unparsedIniSections

UnparsedSettingsMap QConfFile::unparsedIniSections

◆ userPerms

bool QConfFile::userPerms

Definition at line 170 of file qsettings_p.h.

Referenced by QConfFileSettingsPrivate::syncConfFile().


The documentation for this class was generated from the following files: