Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

config.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000, 2004 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #ifndef CONFIG_H
00022 #define CONFIG_H
00023 
00024 // ##### could use QSettings with Qt 3.0
00025 
00026 #include <qpe/qpeglobal.h>
00027 
00028 #include <qmap.h>
00029 #include <qstringlist.h>
00030 
00031 typedef QMap< QString, QString > ConfigGroup;
00032 typedef QMap< QString, ConfigGroup> ConfigGroupMap;
00033 
00034 class QTextStream;
00035 class ConfigPrivate;
00036 class Config
00037 {
00038 public:
00039 
00040     enum Domain { File, User };
00041     Config( const QString &name, Domain domain=User );
00042     ~Config();
00043 
00044     QTOPIA_MERGED_METHOD(static long timeStamp( const QString &name, Domain domain=User ), "2.1");
00045 
00046     bool operator == ( const Config & other ) const { return (filename == other.filename); }
00047     bool operator != ( const Config & other ) const { return (filename != other.filename); }
00048 
00049     bool isValid() const;
00050     bool hasKey( const QString &key ) const;
00051 
00052         // inline for better SharpROM BC
00053     NOT_IN_QPE(bool hasGroup ( const QString &gname ) const);
00054     NOT_IN_QPE(QStringList groupList ( ) const);
00055 
00056     void setGroup( const QString &gname );
00057     void writeEntry( const QString &key, const char* value );
00058     void writeEntry( const QString &key, const QString &value );
00059     void writeEntryCrypt( const QString &key, const QString &value );
00060     void writeEntry( const QString &key, int num );
00061 #ifdef Q_HAS_BOOL_TYPE
00062     void writeEntry( const QString &key, bool b );
00063 #endif
00064     void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
00065     QTOPIA_MERGED_METHOD(void writeEntry( const QString &key, const QStringList &lst ), "2.1.0");
00066 
00067     void removeEntry( const QString &key );
00068 
00069     QString readEntry( const QString &key, const QString &deflt = QString::null ) const;
00070     QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const;
00071     QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const;
00072     int readNumEntry( const QString &key, int deflt = -1 ) const;
00073     bool readBoolEntry( const QString &key, bool deflt = FALSE ) const;
00074     QStringList readListEntry( const QString &key, const QChar &sep ) const;
00075     QTOPIA_MERGED_METHOD(QStringList readListEntry( const QString &key ) const, "2.1.0");
00076 
00077     // For compatibility, non-const versions.
00078     QString readEntry( const QString &key, const QString &deflt );
00079     QString readEntryCrypt( const QString &key, const QString &deflt );
00080     QString readEntryDirect( const QString &key, const QString &deflt );
00081     int readNumEntry( const QString &key, int deflt );
00082     bool readBoolEntry( const QString &key, bool deflt );
00083     QStringList readListEntry( const QString &key, const QChar &sep );
00084 
00085     void clearGroup();
00086     QTOPIA_MERGED_METHOD(void removeGroup(), "2.1.0");
00087     QTOPIA_MERGED_METHOD(void removeGroup(const QString&), "2.1.0");
00088     QTOPIA_MERGED_METHOD(QStringList allGroups() const, "2.1.0");
00089 
00090     void write( const QString &fn = QString::null );
00091 
00092 protected:
00093     void read();
00094     bool parse( const QString &line );
00095 
00096     ConfigGroupMap groups;
00097     ConfigGroupMap::Iterator git;
00098     QString filename;
00099     QString lang;
00100     QString glang;
00101     bool changed;
00102     ConfigPrivate *d;
00103     static QString configFilename(const QString& name, Domain);
00104 
00105 private: // Sharp ROM compatibility
00106     Config( const QString &name, bool what );
00107     void read( QTextStream &s);
00108 };
00109 
00110 #endif

Generated on Sat Nov 5 16:16:34 2005 for OPIE by  doxygen 1.4.2