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

preferencestool.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad     *
00003  *   bjoern_erik_nilsen@hotmail.com & fredrikbk@hotmail.com                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef PREFERENCESTOOL_H
00021 #define PREFERENCESTOOL_H
00022 
00023 #include <libxml/tree.h>
00024 
00025 
00033 class PreferencesTool
00034 {
00035 public:
00040         static PreferencesTool* get();
00041         
00050         bool setPreferencesFile(const char* filePath, const char* version);
00051         
00057 //      void setVersion(int versionNumber);
00058         
00065 //      int getVersion();
00066         
00079         bool setPreference(const char* key, const char* attribute, bool flushLater = false);
00080         
00093         bool setPreference(const char* key, const int attribute, bool flushLater = false);
00094         
00103         const char* getPreference(const char* key, const char* defaultValue);
00104         
00113         const int getPreference(const char* key, const int defaultValue);
00114         
00120         void removePreference(const char* key);
00121         
00126         bool flushPreferences();
00127         
00128         
00129 protected:
00133         PreferencesTool();
00134         
00138         ~PreferencesTool();
00139         
00140 private:
00142         static PreferencesTool *preferencesTool;
00143         
00144         xmlDocPtr doc;
00145         xmlDtdPtr dtd; 
00146         xmlNodePtr rootNode;
00147         xmlNodePtr preferences;
00148         
00149         char *preferencesFile;
00150         
00156         xmlNodePtr findNode(const char* key);
00157         
00162         bool fileExists(const char* filePath);
00163         
00168         void checkInitialized();
00169         
00173         void cleanTree();
00174 };
00175 
00176 #endif

Generated on Thu May 19 01:51:20 2005 for stopmotion.kdevelop by  doxygen 1.4.2