1 /******************************************************************************** 2 * * 3 * R e g i s t r y C l a s s * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXRegistry.h 3297 2015-12-14 20:30:04Z arthurcnorman $ * 23 ********************************************************************************/ 24 #ifndef FXREGISTRY_H 25 #define FXREGISTRY_H 26 27 #ifndef FXSETTINGS_H 28 #include "FXSettings.h" 29 #endif 30 31 namespace FX { 32 33 34 /** 35 * The registry maintains a database of persistent settings for an application. 36 * The settings database is organized in two groups of three layers each. The 37 * system-wide settings group contains settings information pertaining to all 38 * users on a system. The per-user settings group contains settings affecting 39 * that user only. 40 * Each settings group contains a desktop layer, which comprises the settings 41 * which affect all FOX programs, a vendor layer which holds settings that 42 * affect all applications from that vendor (e.g. a application-suite), and 43 * an application layer which holds settings only for a single application. 44 * The vendor-key and application-key determine which files these layers come 45 * from, while the "Desktop" key is used for all FOX applications. 46 * Settings in the system-wide group are overwritten by the per-user group, 47 * and settings from the "Desktop" layer are overwritten by the vendor-layer; 48 * vendor-layer settings are overwritten by the application-layer settings. 49 * Only the per-user, per-application settings ever gets written; the layers 50 * in the system-group only get written during installation and configuration 51 * of the application. 52 * The registry is read when FXApp::init() is called, and written back to the 53 * system when FXApp::exit() is called. 54 */ 55 class FXAPI FXRegistry : public FXSettings { 56 FXDECLARE(FXRegistry) 57 protected: 58 FXString applicationkey; // Application key 59 FXString vendorkey; // Vendor key 60 bool ascii; // ASCII file-based registry 61 protected: 62 bool readFromDir(const FXString& dirname,bool mark); 63 #ifdef WIN32 64 bool readFromRegistry(void* hRootKey,bool mark); 65 bool writeToRegistry(void* hRootKey); 66 bool readFromRegistryGroup(void* org,const char* groupname,bool mark=false); 67 bool writeToRegistryGroup(void* org,const char* groupname); 68 #endif 69 private: 70 FXRegistry(const FXRegistry&); 71 FXRegistry &operator=(const FXRegistry&); 72 public: 73 74 /** 75 * Construct registry object; akey and vkey must be string constants. 76 * Regular applications SHOULD set a vendor key! 77 */ 78 FXRegistry(const FXString& akey=FXString::null,const FXString& vkey=FXString::null); 79 80 /// Read registry 81 bool read(); 82 83 /// Write registry 84 bool write(); 85 86 /// Return application key getAppKey()87 const FXString& getAppKey() const { return applicationkey; } 88 89 /// Return vendor key getVendorKey()90 const FXString& getVendorKey() const { return vendorkey; } 91 92 /** 93 * Set ASCII mode; under MS-Windows, this will switch the system to a 94 * file-based registry system, instead of using the System Registry API. 95 */ setAsciiMode(bool asciiMode)96 void setAsciiMode(bool asciiMode){ ascii=asciiMode; } 97 98 /// Get ASCII mode getAsciiMode()99 bool getAsciiMode() const { return ascii; } 100 }; 101 102 } 103 104 #endif 105