
/*	Copyright  (c)	GŸnter Woigk  1999
  					mailto:kio@little-bat.de

 	This program is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

 	Permission to use, copy, modify, distribute, and sell this software and
 	its documentation for any purpose is hereby granted without fee, provided
 	that the above copyright notice appear in all copies and that both that
 	copyright notice and this permission notice appear in supporting
 	documentation, and that the name of the copyright holder not be used
 	in advertising or publicity pertaining to distribution of the software
 	without specific, written prior permission.  The copyright holder makes no
 	representations about the suitability of this software for any purpose.
 	It is provided "as is" without express or implied warranty.

 	THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 	INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 	EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 	CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 	DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 	TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 	PERFORMANCE OF THIS SOFTWARE.

 
	manage preferences
	------------------

	the preferences file is automatically read when a pref is read or written.
	prefs may be fetched via get() from the buffered data
	char pointers remain valid until another put() or read()
	the preferences file is written:
	- at program exit if data is dirty or
	- when write() is called and data is dirty

	file is located in ~/prefs/ (unix, or similar named folder) 
	resp. in the preferences folder in the system folder (macintosh)

	file name is 'applName'.prefs  (applName should be defined in options.h)

	preferences are stored in a plain vanilla textfile which the user may edit.
	

	getxxx(name,default)	get an entry
	putxxx(name,value)		store/replace an entry
	del(name)				delete entry
	read()					reread file
	write()					write data back to file now
	home()					get home directory path "/home/myname"  (unix only)
*/


#ifndef _prefs_h_
#define _prefs_h_


class prefs
{
public:

// read/write from buffer
static cstr	 		GetStr	( cstr idf, cstr defaultvalue=NULL, bool secure=0 );
static void			PutStr	( cstr idf, cstr text,			  	bool secure=0 );
static long			GetNum	( cstr idf, long defaultvalue=0,	bool secure=0 );
static void			PutNum	( cstr idf, long value,				bool secure=0 );
static bool			GetBool	( cstr idf, bool defaultvalue=false );
static void			PutBool	( cstr idf, bool text );

static void			PutHex	( cstr idf, int n, const void* buffer );
static void			GetHex	( cstr idf, int n,       void* buffer );
static void 		PutNums	( cstr idf, int n, const long*  array );
static void 		GetNums	( cstr idf, int n,       long*  array );
static void 		PutNums	( cstr idf, int n, const short* array );
static void 		GetNums	( cstr idf, int n,       short* array );
static void			PutBox	( cstr idf, cBox& );
static void			GetBox	( cstr idf, Box& );

static void			Del		( cstr idf );

// read/write file
static void			Read	( );		// open-read-close
static void			Write	( );		// open-write-close

// get members
#if unix
static char*		GetHome ( )			{ return home; }
static char*		GetFile ( )			{ return filename; }
#endif
};



#endif











