/*	XPreferences.h
 *
 *		This defines the classes which are used to encapsulate
 *	the storage of preferences data.
 *
 *		Preferences are stored on the Macintosh in a
 *	preferences file named after the application, in the
 *	system's preferences folder. On Windows, preferences data
 *	is stored in the system registry. On Unix, preferences
 *	are written to an invisible file in the user's home
 */

/*  YAAF - Yet another application framework
 *  Copyright (C) 1997, 1998 William Edward Woody
 *  
 *  This library is free software; you can redistribute it
 *  and/or modify it under the terms of the GNU Library
 *  General Public License as published by the Free Software
 *  Foundation; either version 2 of the License, or any
 *  later version.
 *  
 *  This library is distributed in the hope that it will be
 *  useful, but WITHOUT ANY WARRANTY; without even the implied
 *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE. See the GNU Library General Public License for
 *  more details.
 *  
 *  You should have received a copy of the GNU Library General
 *  Public License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA 02111-1307, USA.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#ifndef PandaWave_XPREFERENCES
#define PandaWave_XPREFERENCES

#include <XConfig.h>
#include <XString.h>
#include <XHandle.h>

/************************************************************************/
/*																		*/
/*	Classes																*/
/*																		*/
/************************************************************************/

/*	@C"XGPreferences"
 *	@H"XPreferences.h"
 *	@I
 *
 *		The preferences record. While this exists, the preferences
 *	file is open and can be modified.
 */

class XGPreferences {
	public:
#if OPT_MACOS
								XGPreferences(char *name, long creator);
#endif

#if OPT_WINOS
								XGPreferences(char *comp, char *prod, char *vers);
#endif

#if OPT_XWIN
								XGPreferences(char *name);
#endif

		virtual					~XGPreferences();
		
		/*
		 *	Get values
		 */
		
		bool					GetBoolean(char *key);
		long					GetInteger(char *key);
		void					GetString(char *key, char *value);
		
		/*
		 *	Set values
		 */
		
		void					SetBoolean(char *key, bool value);
		void					SetInteger(char *key, long value);
		void					SetString(char *key, char *value);
		
		/*
		 *	Delete values
		 */
		
		void					DeleteValue(char *key);

	private:
	
#if OPT_MACOS
		long					fType;
#endif

#if OPT_MACOS || OPT_XWIN
		void					ReadData(void);
		void					WriteData(void);

		bool					fDirty;
		XGString				fFile;
		
		XGStringList			fDataKey;
		XGStringList			fDataValue;
#endif

#if OPT_WINOS
		HKEY					fKey;
#endif
};

#endif // PandaWave_XPREFERENCES
