Warning, file /sdk/kdesvn/src/svnqt/cache/ReposConfig.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2009 by Rajko Albrecht  ral@alwins-world.de        *
0003  *   https://kde.org/applications/development/org.kde.kdesvn               *
0004  *                                                                         *
0005  * This program is free software; you can redistribute it and/or           *
0006  * modify it under the terms of the GNU Lesser General Public              *
0007  * License as published by the Free Software Foundation; either            *
0008  * version 2.1 of the License, or (at your option) any later version.      *
0009  *                                                                         *
0010  * This program is distributed in the hope that it will be useful,         *
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0013  * Lesser General Public License for more details.                         *
0014  *                                                                         *
0015  * You should have received a copy of the GNU Lesser General Public        *
0016  * License along with this program (in the file LGPL.txt); if not,         *
0017  * write to the Free Software Foundation, Inc., 51 Franklin St,            *
0018  * Fifth Floor, Boston, MA  02110-1301  USA                                *
0019  *                                                                         *
0020  * This software consists of voluntary contributions made by many          *
0021  * individuals.  For exact contribution history, see the revision          *
0022  * history and logs, available at https://commits.kde.org/kdesvn.          *
0023  ***************************************************************************/
0024 
0025 /***************************************************************************
0026  * Lot of code and ideas taken from KDE 4 KConfigGroup source code         *
0027  * ksvn://anonsvn.kde.org/home/kde/branches/KDE/4.2/kdelibs/kdecore/config *
0028  ***************************************************************************/
0029 
0030 #ifndef REPOSCONFIG_HPP
0031 #define REPOSCONFIG_HPP
0032 
0033 #include <QList>
0034 #include <QString>
0035 #include <QVariant>
0036 
0037 #include "svnqt/svnqt_defines.h"
0038 #include <ConversionCheck>
0039 
0040 namespace svn
0041 {
0042 namespace cache
0043 {
0044 
0045 class SVNQT_EXPORT ReposConfig
0046 {
0047 private:
0048     static ReposConfig *mSelf;
0049 
0050 protected:
0051     ReposConfig();
0052     template<typename T>
0053     void writeCheck(const QString &repository, const QString &key, const T &value);
0054     template<typename T>
0055     void writeListCheck(const QString &repository, const QString &key, const QList<T> &value);
0056 
0057 public:
0058     static ReposConfig *self();
0059 
0060     template<typename T>
0061     void setValue(const QString &repository, const QString &key, const T &value);
0062     template<typename T>
0063     void setValue(const QString &repository, const QString &key, const QList<T> &value);
0064     void setValue(const QString &repository, const QString &key, const QStringList &value);
0065     void setValue(const QString &repository, const QString &key, const QVariant &value);
0066     void setValue(const QString &repository, const QString &key, const QVariantList &list);
0067     void setValue(const QString &repository, const QString &key, const QString &value);
0068 
0069     //! special setter
0070     void eraseValue(const QString &repository, const QString &key);
0071 
0072     QVariant readEntry(const QString &repository, const QString &key, const QVariant &aDefault);
0073     int readEntry(const QString &repository, const QString &key, int aDefault);
0074     bool readEntry(const QString &repository, const QString &key, bool aDefault);
0075     QStringList readEntry(const QString &repository, const QString &key, const QStringList &aDefault);
0076 };
0077 
0078 template<typename T>
0079 inline void ReposConfig::setValue(const QString &repository, const QString &key, const T &value)
0080 {
0081     writeCheck(repository, key, value);
0082 }
0083 
0084 template<typename T>
0085 inline void ReposConfig::writeCheck(const QString &repository, const QString &key, const T &value)
0086 {
0087     ConversionCheck::to_QVariant<T>();
0088     setValue(repository, key, QVariant::fromValue(value));
0089 }
0090 
0091 template<typename T>
0092 inline void ReposConfig::setValue(const QString &repository, const QString &key, const QList<T> &value)
0093 {
0094     writeListCheck(repository, key, value);
0095 }
0096 
0097 template<typename T>
0098 inline void ReposConfig::writeListCheck(const QString &repository, const QString &key, const QList<T> &list)
0099 {
0100     ConversionCheck::to_QVariant<T>();
0101     ConversionCheck::to_QString<T>();
0102     QVariantList data;
0103     for (const T &value : list)
0104         data.append(qVariantFromValue(value));
0105     setValue(repository, key, data);
0106 }
0107 
0108 } // namespace cache
0109 } // namespace svn
0110 
0111 #endif