File indexing completed on 2025-01-05 04:37:24
0001 /* 0002 SPDX-FileCopyrightText: 2005-2010 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef BTSTATSFILE_H 0007 #define BTSTATSFILE_H 0008 0009 #include <KSharedConfig> 0010 #include <ktorrent_export.h> 0011 #include <util/constants.h> 0012 0013 namespace bt 0014 { 0015 /** 0016 * @brief This class is used for loading/storing torrent stats in a file. 0017 * @author Ivan Vasic <ivasic@gmail.com> 0018 */ 0019 class KTORRENT_EXPORT StatsFile 0020 { 0021 public: 0022 /** 0023 * @brief A constructor. 0024 * Constructs StatsFile object and calls readSync(). 0025 */ 0026 StatsFile(const QString &filename); 0027 virtual ~StatsFile(); 0028 0029 QString readString(const QString &key); 0030 0031 Uint64 readUint64(const QString &key); 0032 bool readBoolean(const QString &key); 0033 int readInt(const QString &key); 0034 unsigned long readULong(const QString &key); 0035 float readFloat(const QString &key); 0036 0037 void write(const QString &key, const QString &value); 0038 0039 /// Sync with disk 0040 void sync(); 0041 0042 /** 0043 * See if there is a key in the stats file 0044 * @param key The key 0045 * @return true if key is in the stats file 0046 */ 0047 bool hasKey(const QString &key) const; 0048 0049 private: 0050 KSharedConfigPtr cfg; 0051 }; 0052 } 0053 0054 #endif