1995-04-03 22:59:20 +00:00
|
|
|
/* Interface for NSDictionary for GNUStep
|
1999-09-16 07:21:34 +00:00
|
|
|
Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
|
1995-07-01 19:01:11 +00:00
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1995-07-01 19:01:11 +00:00
|
|
|
Date: 1995
|
2012-03-20 20:17:45 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1995-04-03 22:59:20 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2012-03-20 20:17:45 +00:00
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
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.
|
2012-03-20 20:17:45 +00:00
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1995-04-03 22:59:20 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
2012-03-20 20:17:45 +00:00
|
|
|
*/
|
1995-04-03 22:59:20 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef _NSDictionary_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define _NSDictionary_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2012-03-20 20:17:45 +00:00
|
|
|
#import <GNUstepBase/GSBlocks.h>
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
2009-12-29 16:21:01 +00:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
1995-04-03 22:59:20 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
@class GS_GENERIC_CLASS(NSArray, ElementT);
|
|
|
|
@class GS_GENERIC_CLASS(NSSet, ElementT);
|
|
|
|
@class NSString, NSURL;
|
|
|
|
|
|
|
|
@interface GS_GENERIC_CLASS(NSDictionary,
|
2016-02-24 07:41:20 +00:00
|
|
|
__covariant KeyT:id<NSCopying>, __covariant ValT)
|
|
|
|
: NSObject <NSCoding, NSCopying, NSMutableCopying, NSFastEnumeration>
|
2016-02-22 21:04:18 +00:00
|
|
|
+ (instancetype) dictionary;
|
|
|
|
+ (instancetype) dictionaryWithContentsOfFile: (NSString*)path;
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2016-02-22 21:04:18 +00:00
|
|
|
+ (instancetype) dictionaryWithContentsOfURL: (NSURL*)aURL;
|
2003-07-15 16:35:11 +00:00
|
|
|
#endif
|
2016-02-22 21:04:18 +00:00
|
|
|
+ (instancetype) dictionaryWithDictionary: (NSDictionary*)otherDictionary;
|
|
|
|
+ (instancetype) dictionaryWithObject: (GS_GENERIC_TYPE(ValT))object
|
2016-02-24 07:41:20 +00:00
|
|
|
forKey: (GS_GENERIC_TYPE(KeyT))key;
|
2016-02-22 21:04:18 +00:00
|
|
|
+ (instancetype) dictionaryWithObjects: (GS_GENERIC_CLASS(NSArray,ValT)*)objects
|
|
|
|
forKeys: (GS_GENERIC_CLASS(NSArray,KeyT)*)keys;
|
|
|
|
+ (instancetype) dictionaryWithObjects: (const GS_GENERIC_TYPE(ValT)[])objects
|
2016-02-24 07:41:20 +00:00
|
|
|
forKeys: (const GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys
|
|
|
|
count: (NSUInteger)count;
|
2016-02-22 21:04:18 +00:00
|
|
|
+ (instancetype) dictionaryWithObjectsAndKeys: (id)firstObject, ...;
|
|
|
|
|
|
|
|
- (GS_GENERIC_CLASS(NSArray,KeyT)*) allKeys;
|
|
|
|
- (GS_GENERIC_CLASS(NSArray,KeyT)*) allKeysForObject:
|
2016-02-24 07:41:20 +00:00
|
|
|
(GS_GENERIC_TYPE(ValT))anObject;
|
2016-02-22 21:04:18 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray,ValT)*) allValues;
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSUInteger) count; // Primitive
|
2001-01-09 09:17:31 +00:00
|
|
|
- (NSString*) description;
|
|
|
|
- (NSString*) descriptionInStringsFileFormat;
|
2011-02-23 11:52:17 +00:00
|
|
|
- (NSString*) descriptionWithLocale: (id)locale;
|
|
|
|
- (NSString*) descriptionWithLocale: (id)locale
|
2009-02-23 20:42:32 +00:00
|
|
|
indent: (NSUInteger)level;
|
2001-01-09 09:17:31 +00:00
|
|
|
|
2013-07-01 07:08:55 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
2016-02-22 21:04:18 +00:00
|
|
|
DEFINE_BLOCK_TYPE(GSKeysAndObjectsEnumeratorBlock, void,
|
2016-02-24 07:41:20 +00:00
|
|
|
GS_GENERIC_TYPE_F(KeyT,id<NSCopying>), GS_GENERIC_TYPE(ValT), BOOL*);
|
2012-03-22 20:58:27 +00:00
|
|
|
- (void) enumerateKeysAndObjectsUsingBlock:
|
|
|
|
(GSKeysAndObjectsEnumeratorBlock)aBlock;
|
|
|
|
- (void) enumerateKeysAndObjectsWithOptions: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSKeysAndObjectsEnumeratorBlock)aBlock;
|
|
|
|
#endif
|
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ValT)[])objects
|
2016-02-24 07:41:20 +00:00
|
|
|
andKeys: (__unsafe_unretained GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys;
|
2016-02-22 21:04:18 +00:00
|
|
|
- (instancetype) init;
|
|
|
|
- (instancetype) initWithContentsOfFile: (NSString*)path;
|
2012-03-22 20:58:27 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2016-02-22 21:04:18 +00:00
|
|
|
- (instancetype) initWithContentsOfURL: (NSURL*)aURL;
|
2003-07-15 16:35:11 +00:00
|
|
|
#endif
|
2012-03-22 20:58:27 +00:00
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
- (instancetype) initWithDictionary:
|
|
|
|
(GS_GENERIC_CLASS(NSDictionary,KeyT, ValT)*)otherDictionary;
|
|
|
|
- (id) initWithDictionary: (GS_GENERIC_CLASS(NSDictionary,KeyT, ValT)*)other
|
|
|
|
copyItems: (BOOL)shouldCopy;
|
|
|
|
- (id) initWithObjects: (GS_GENERIC_CLASS(NSArray,KeyT)*)objects
|
|
|
|
forKeys: (GS_GENERIC_CLASS(NSArray,ValT)*)keys;
|
|
|
|
- (id) initWithObjectsAndKeys: (GS_GENERIC_TYPE(ValT))firstObject, ...;
|
|
|
|
- (id) initWithObjects: (const GS_GENERIC_TYPE(ValT)[])objects
|
|
|
|
forKeys: (const GS_GENERIC_TYPE_F(KeyT,id<NSCopying>)[])keys
|
2016-02-24 07:41:20 +00:00
|
|
|
count: (NSUInteger)count; // Primitive
|
2016-02-22 21:04:18 +00:00
|
|
|
- (BOOL) isEqualToDictionary: (GS_GENERIC_CLASS(NSDictionary,KeyT, ValT)*)other;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
2016-02-24 07:41:20 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSEnumerator,KeyT)*) keyEnumerator; // Primitive
|
2012-03-22 20:58:27 +00:00
|
|
|
|
2013-07-01 07:08:55 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
2016-02-22 21:04:18 +00:00
|
|
|
DEFINE_BLOCK_TYPE(GSKeysAndObjectsPredicateBlock, BOOL,
|
|
|
|
GS_GENERIC_TYPE_F(KeyT,id<NSCopying>), GS_GENERIC_TYPE(ValT), BOOL*);
|
|
|
|
- (GS_GENERIC_CLASS(NSSet,KeyT)*) keysOfEntriesPassingTest:
|
|
|
|
(GSKeysAndObjectsPredicateBlock)aPredicate;
|
|
|
|
- (GS_GENERIC_CLASS(NSSet,KeyT)*) keysOfEntriesWithOptions:
|
2016-02-24 07:41:20 +00:00
|
|
|
(NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSKeysAndObjectsPredicateBlock)aPredicate;
|
2012-03-22 20:58:27 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray,ValT)*) keysSortedByValueUsingSelector: (SEL)comp;
|
2016-02-24 07:41:20 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSEnumerator,ValT)*) objectEnumerator; // Primitive
|
2016-02-22 21:04:18 +00:00
|
|
|
- (GS_GENERIC_TYPE(ValT)) objectForKey:
|
2016-02-24 07:41:20 +00:00
|
|
|
(GS_GENERIC_TYPE(KeyT))aKey; // Primitive
|
2016-02-22 21:04:18 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray,ValT)*) objectsForKeys:
|
2016-02-24 07:41:20 +00:00
|
|
|
(GS_GENERIC_CLASS(NSArray,KeyT)*)keys
|
|
|
|
notFoundMarker: (GS_GENERIC_TYPE(ValT))marker;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2016-02-22 21:04:18 +00:00
|
|
|
- (GS_GENERIC_TYPE(ValT)) valueForKey: (NSString*)key;
|
2001-07-16 07:08:47 +00:00
|
|
|
#endif
|
2012-03-20 20:17:45 +00:00
|
|
|
|
2012-03-22 20:58:27 +00:00
|
|
|
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
|
2012-03-20 20:17:45 +00:00
|
|
|
|
2012-03-22 20:58:27 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
|
|
|
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
|
2012-03-20 20:17:45 +00:00
|
|
|
#endif
|
2012-04-06 12:23:10 +00:00
|
|
|
/**
|
|
|
|
* Method called by array subscripting.
|
|
|
|
*/
|
2016-02-22 21:04:18 +00:00
|
|
|
- (GS_GENERIC_TYPE(ValT)) objectForKeyedSubscript:
|
2016-02-24 07:41:20 +00:00
|
|
|
(GS_GENERIC_TYPE(KeyT))aKey;
|
1995-04-03 22:59:20 +00:00
|
|
|
@end
|
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
@interface GS_GENERIC_CLASS(NSMutableDictionary, KeyT:id<NSCopying>, ValT) :
|
|
|
|
GS_GENERIC_CLASS(NSDictionary, KeyT, ValT)
|
1995-04-03 22:59:20 +00:00
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
+ (instancetype) dictionaryWithCapacity: (NSUInteger)numItems;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
2016-02-22 21:04:18 +00:00
|
|
|
- (void) addEntriesFromDictionary:
|
|
|
|
(GS_GENERIC_CLASS(NSDictionary, KeyT, ValT)*)otherDictionary;
|
2016-02-24 07:41:20 +00:00
|
|
|
- (instancetype) initWithCapacity: (NSUInteger)numItems; // Primitive
|
1995-05-05 18:32:50 +00:00
|
|
|
- (void) removeAllObjects;
|
2016-02-22 21:04:18 +00:00
|
|
|
/**
|
|
|
|
* Removes the object with the specified key from the receiver. This method
|
|
|
|
* is primitive.
|
|
|
|
*/
|
|
|
|
- (void) removeObjectForKey: (GS_GENERIC_TYPE(KeyT))aKey;
|
|
|
|
- (void) removeObjectsForKeys: (GS_GENERIC_CLASS(NSArray, KeyT) *)keyArray;
|
|
|
|
- (void) setObject: (GS_GENERIC_TYPE(ValT))anObject
|
|
|
|
forKey: (GS_GENERIC_TYPE(KeyT))aKey; // Primitive
|
|
|
|
- (void) setDictionary:
|
|
|
|
(GS_GENERIC_CLASS(NSDictionary, KeyT, ValT)*)otherDictionary;
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2016-02-22 21:04:18 +00:00
|
|
|
- (void) setValue: (GS_GENERIC_TYPE(ValT))value forKey: (NSString*)key;
|
|
|
|
- (void) takeStoredValue: (GS_GENERIC_TYPE(ValT))value forKey: (NSString*)key;
|
|
|
|
- (void) takeValue: (GS_GENERIC_TYPE(ValT))value forKey: (NSString*)key;
|
2002-02-27 09:25:30 +00:00
|
|
|
#endif
|
2012-04-06 12:23:10 +00:00
|
|
|
/**
|
|
|
|
* Method called by array subscripting.
|
|
|
|
*/
|
2016-02-22 21:04:18 +00:00
|
|
|
- (void) setObject: (GS_GENERIC_TYPE(ValT))anObject
|
|
|
|
forKeyedSubscript: (GS_GENERIC_TYPE(KeyT))aKey;
|
2012-04-06 12:23:10 +00:00
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
@end
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
#endif
|