1999-01-19 12:58:53 +00:00
|
|
|
/* Interface for <NSUserDefaults> for GNUStep
|
1996-07-15 18:42:52 +00:00
|
|
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
Written by: Georg Tuparev, EMBL & Academia Naturalis,
|
1996-07-15 18:42:52 +00:00
|
|
|
Heidelberg, Germany
|
|
|
|
Tuparev@EMBL-Heidelberg.de
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
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 (at your option) 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
|
|
|
|
MERCHANTABILITY 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
|
2005-05-22 03:32:16 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
1996-07-15 18:42:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NSUserDefaults_h_OBJECTS_INCLUDE
|
|
|
|
#define __NSUserDefaults_h_OBJECTS_INCLUDE
|
|
|
|
|
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
|
|
|
|
@class NSArray;
|
|
|
|
@class NSMutableArray;
|
|
|
|
@class NSDictionary;
|
|
|
|
@class NSMutableDictionary;
|
|
|
|
@class NSData;
|
1999-01-19 12:58:53 +00:00
|
|
|
@class NSTimer;
|
2001-11-07 18:10:28 +00:00
|
|
|
@class NSRecursiveLock;
|
2002-08-27 08:52:14 +00:00
|
|
|
@class NSDistributedLock;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Standard domains */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* User defaults domain for process arguments. Command-line arguments
|
|
|
|
* (attribute-value pairs, as in "-NSFoo bar") are placed into this domain.
|
|
|
|
*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSArgumentDomain;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* User defaults domain for system defaults.
|
|
|
|
*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSGlobalDomain;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* User defaults domain for application-registered "default defaults".
|
|
|
|
*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSRegistrationDomain;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
2006-02-19 21:49:21 +00:00
|
|
|
#ifndef NO_GNUSTEP
|
|
|
|
/**
|
|
|
|
* User defaults domain for GNUstep config file.
|
|
|
|
*/
|
|
|
|
GS_EXPORT NSString* const GSConfigDomain;
|
|
|
|
#endif
|
|
|
|
|
2004-07-29 15:30:47 +00:00
|
|
|
|
1996-07-15 18:42:52 +00:00
|
|
|
/* Public notification */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification posted when a defaults synchronize has been performed (see
|
|
|
|
* [NSUserDefaults-synchronize]) and changes have been loaded in from disk.
|
|
|
|
*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSUserDefaultsDidChangeNotification;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
1998-09-04 06:50:18 +00:00
|
|
|
/* Backwards compatibility */
|
1998-11-09 20:24:09 +00:00
|
|
|
#define NSUserDefaultsChanged NSUserDefaultsDidChangeNotification
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Keys for language-dependent information */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: names of days of week. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSWeekDayNameArray;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: abbreviations of days of week. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSShortWeekDayNameArray;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: names of months of year. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSMonthNameArray;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: abbreviations of months of year. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSShortMonthNameArray;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: format string for feeding to [NSDateFormatter].*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSTimeFormatString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: format string for feeding to [NSDateFormatter].*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSDateFormatString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: format string for feeding to [NSDateFormatter].*/
|
2000-10-27 15:54:35 +00:00
|
|
|
GS_EXPORT NSString* const NSShortDateFormatString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: format string for feeding to [NSDateFormatter].*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSTimeDateFormatString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: format string for feeding to [NSDateFormatter].*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSShortTimeDateFormatString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: currency symbol. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSCurrencySymbol;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: decimal separator. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSDecimalSeparator;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: thousands separator. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSThousandsSeparator;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: three-letter ISO 4217 currency abbreviation. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSInternationalCurrencyString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: text formatter string for monetary amounts. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSCurrencyString;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: array of strings for 0-9. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSDecimalDigits;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: array of strings for AM and PM. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSAMPMDesignation;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
1998-12-02 20:16:23 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-02 18:10:58 +00:00
|
|
|
* Array of arrays of NSStrings, first member of each specifying a time,
|
|
|
|
* followed by one or more colloquial names for the time, as in "(0,
|
|
|
|
* midnight), (12, noon, lunch)".
|
2004-07-29 15:30:47 +00:00
|
|
|
*/
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSHourNameDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Strings for "year", "month", "week". */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSYearMonthWeekDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: adjectives that modify values in
|
|
|
|
NSYearMonthWeekDesignations, as in "last", "previous", etc.. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSEarlierTimeDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: adjectives that modify values in
|
|
|
|
NSYearMonthWeekDesignations, as in "next", "subsequent", etc.. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSLaterTimeDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: one or more strings designating the current
|
|
|
|
day, such as "today". */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSThisDayDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: one or more strings designating the next
|
|
|
|
day, such as "tomorrow". */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSNextDayDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: one or more strings designating the next
|
|
|
|
day, such as "day after tomorrow". */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSNextNextDayDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: one or more strings designating the previous
|
|
|
|
day, such as "yesterday". */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSPriorDayDesignations;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: string with 'Y', 'M', 'D', and 'H' designating
|
|
|
|
the default method of writing dates, as in "MDYH" for the U.S.. */
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT NSString* const NSDateTimeOrdering;
|
2000-10-27 15:54:35 +00:00
|
|
|
|
2004-07-29 15:30:47 +00:00
|
|
|
/** Key for locale dictionary: name of language. */
|
2000-10-27 15:54:35 +00:00
|
|
|
GS_EXPORT NSString* const NSLanguageName;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: two-letter ISO code. */
|
2000-10-27 15:54:35 +00:00
|
|
|
GS_EXPORT NSString* const NSLanguageCode;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
/** Key for locale dictionary: formal name of language. */
|
2000-10-27 15:54:35 +00:00
|
|
|
GS_EXPORT NSString* const NSFormalName;
|
|
|
|
#ifndef NO_GNUSTEP
|
2004-07-29 15:30:47 +00:00
|
|
|
/** Key for locale dictionary: name of locale. */
|
2000-10-27 15:54:35 +00:00
|
|
|
GS_EXPORT NSString* const NSLocale;
|
|
|
|
#endif
|
1998-12-02 20:16:23 +00:00
|
|
|
#endif
|
1996-07-15 18:42:52 +00:00
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
/* General implementation notes:
|
1996-07-15 18:42:52 +00:00
|
|
|
|
2004-08-02 18:10:58 +00:00
|
|
|
OpenStep spec currently is neither complete nor consistent. Therefore
|
|
|
|
we had to make several implementation decisions which may vary in
|
|
|
|
other OpenStep implementations.
|
1996-07-15 18:42:52 +00:00
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
- We add a new instance method initWithFile: as a designated
|
1996-07-15 18:42:52 +00:00
|
|
|
initialization method because it allows to create user defaults
|
|
|
|
database from a "default user" and also it will work for various
|
|
|
|
non-posix implementations.
|
|
|
|
|
|
|
|
- We add two new class methods for getting and setting a list of
|
1998-11-30 10:04:24 +00:00
|
|
|
user languages (userLanguages and setUserLanguages: ). They are
|
1996-07-15 18:42:52 +00:00
|
|
|
somehow equivalent to the NS3.x Application's systemLanguages
|
|
|
|
method.
|
|
|
|
|
|
|
|
- Definition of argument (command line parameters)
|
|
|
|
(-GSxxxx || --GSxxx) [value]
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
Note: As far as I know, there is nothing like home directory for
|
1996-07-15 18:42:52 +00:00
|
|
|
the M$ hell. God help the Win95/WinNT users of NSUserDefaults ;-)
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
To Do:
|
1996-07-15 18:42:52 +00:00
|
|
|
- polish & optimize;
|
|
|
|
- when tested, fix NSBundle (the system languages stuff);
|
1998-11-30 10:04:24 +00:00
|
|
|
- write docs : -(
|
1996-07-15 18:42:52 +00:00
|
|
|
*/
|
|
|
|
|
1998-11-30 10:04:24 +00:00
|
|
|
@interface NSUserDefaults: NSObject
|
1996-07-15 18:42:52 +00:00
|
|
|
{
|
|
|
|
@private
|
1999-09-16 07:21:34 +00:00
|
|
|
NSMutableArray *_searchList; // Current search list;
|
|
|
|
NSMutableDictionary *_persDomains; // Contains persistent defaults info;
|
|
|
|
NSMutableDictionary *_tempDomains; // Contains volatile defaults info;
|
|
|
|
NSMutableArray *_changedDomains; /* ..after first time that persistent
|
1998-11-30 10:04:24 +00:00
|
|
|
user defaults are changed */
|
1999-09-16 07:21:34 +00:00
|
|
|
NSDictionary *_dictionaryRep; // Cached dictionary representation
|
1999-10-05 10:04:12 +00:00
|
|
|
NSString *_defaultsDatabase;
|
1999-09-16 07:21:34 +00:00
|
|
|
NSDate *_lastSync;
|
2001-11-07 18:10:28 +00:00
|
|
|
NSRecursiveLock *_lock;
|
2002-08-27 08:52:14 +00:00
|
|
|
NSDistributedLock *_fileLock;
|
1996-07-15 18:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Getting the Shared Instance */
|
1998-11-30 10:04:24 +00:00
|
|
|
+ (NSUserDefaults*) standardUserDefaults;
|
2001-11-13 07:44:57 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
1999-02-20 21:19:15 +00:00
|
|
|
/*
|
|
|
|
* Called by GSSetUserName() to get the defaults system to use the defaults
|
|
|
|
* of a new user.
|
|
|
|
*/
|
2001-11-13 07:44:57 +00:00
|
|
|
+ (void) resetStandardUserDefaults;
|
1999-02-20 21:19:15 +00:00
|
|
|
#endif
|
2002-01-02 06:50:30 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
#ifndef STRICT_MACOS_X
|
1998-11-30 10:04:24 +00:00
|
|
|
+ (NSArray*) userLanguages;
|
|
|
|
+ (void) setUserLanguages: (NSArray*)languages;
|
2002-01-02 06:50:30 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Initializing the User Defaults */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (id) init;
|
|
|
|
- (id) initWithUser: (NSString*)userName;
|
|
|
|
- (id) initWithContentsOfFile: (NSString*)path; // This is a new method
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Getting and Setting a Default */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSArray*) arrayForKey: (NSString*)defaultName;
|
|
|
|
- (BOOL) boolForKey: (NSString*)defaultName;
|
|
|
|
- (NSData*) dataForKey: (NSString*)defaultName;
|
|
|
|
- (NSDictionary*) dictionaryForKey: (NSString*)defaultName;
|
|
|
|
- (float) floatForKey: (NSString*)defaultName;
|
|
|
|
- (int) integerForKey: (NSString*)defaultName;
|
|
|
|
- (id) objectForKey: (NSString*)defaultName;
|
|
|
|
- (void) removeObjectForKey: (NSString*)defaultName;
|
|
|
|
- (void) setBool: (BOOL)value forKey: (NSString*)defaultName;
|
|
|
|
- (void) setFloat: (float)value forKey: (NSString*)defaultName;
|
|
|
|
- (void) setInteger: (int)value forKey: (NSString*)defaultName;
|
|
|
|
- (void) setObject: (id)value forKey: (NSString*)defaultName;
|
|
|
|
- (NSArray*) stringArrayForKey: (NSString*)defaultName;
|
|
|
|
- (NSString*) stringForKey: (NSString*)defaultName;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Returning the Search List */
|
2005-07-08 11:48:37 +00:00
|
|
|
- (NSArray*) searchList;
|
2003-04-17 06:20:17 +00:00
|
|
|
- (void) setSearchList: (NSArray*)newList;
|
2004-06-29 10:31:05 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
- (void) addSuiteNamed: (NSString*)aName;
|
|
|
|
- (void) removeSuiteNamed: (NSString*)aName;
|
|
|
|
#endif
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Maintaining Persistent Domains */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSDictionary*) persistentDomainForName: (NSString*)domainName;
|
|
|
|
- (NSArray*) persistentDomainNames;
|
|
|
|
- (void) removePersistentDomainForName: (NSString*)domainName;
|
|
|
|
- (void) setPersistentDomain: (NSDictionary*)domain
|
|
|
|
forName: (NSString*)domainName;
|
|
|
|
- (BOOL) synchronize;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Maintaining Volatile Domains */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (void) removeVolatileDomainForName: (NSString*)domainName;
|
|
|
|
- (void) setVolatileDomain: (NSDictionary*)domain
|
|
|
|
forName: (NSString*)domainName;
|
|
|
|
- (NSDictionary*) volatileDomainForName: (NSString*)domainName;
|
|
|
|
- (NSArray*) volatileDomainNames;
|
1996-07-15 18:42:52 +00:00
|
|
|
|
|
|
|
/* Making Advanced Use of Defaults */
|
1998-11-30 10:04:24 +00:00
|
|
|
- (NSDictionary*) dictionaryRepresentation;
|
2001-12-17 14:31:42 +00:00
|
|
|
- (void) registerDefaults: (NSDictionary*)newVals;
|
1996-07-15 18:42:52 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
#endif /* __NSUserDefaults_h_OBJECTS_INCLUDE */
|