1998-02-05 22:06:20 +00:00
|
|
|
/* Interface for NSValue for GNUStep
|
1996-02-22 15:59:37 +00:00
|
|
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
1995-07-01 19:01:11 +00:00
|
|
|
|
|
|
|
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
1996-02-22 15:59:37 +00:00
|
|
|
Created: 1995
|
1995-03-23 03:47:56 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-03-23 03:47:56 +00:00
|
|
|
|
|
|
|
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
|
1999-09-09 02:56:20 +00:00
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1995-03-23 03:47:56 +00:00
|
|
|
*/
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __NSValue_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSValue_h_GNUSTEP_BASE_INCLUDE
|
1995-03-18 17:15:15 +00:00
|
|
|
|
1995-04-17 21:13:20 +00:00
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
#include <Foundation/NSGeometry.h>
|
1995-03-18 17:15:15 +00:00
|
|
|
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
@interface NSValue : NSObject <NSCopying, NSCoding>
|
|
|
|
|
|
|
|
// Allocating and Initializing
|
|
|
|
|
1995-03-23 03:47:56 +00:00
|
|
|
+ (NSValue*) value: (const void*)value withObjCType: (const char*)type;
|
|
|
|
+ (NSValue*) valueWithNonretainedObject: (id)anObject;
|
|
|
|
+ (NSValue*) valueWithPoint: (NSPoint)point;
|
|
|
|
+ (NSValue*) valueWithPointer: (const void*)pointer;
|
2001-01-12 14:29:34 +00:00
|
|
|
+ (NSValue*) valueWithRange: (NSRange)range;
|
1995-03-23 03:47:56 +00:00
|
|
|
+ (NSValue*) valueWithRect: (NSRect)rect;
|
|
|
|
+ (NSValue*) valueWithSize: (NSSize)size;
|
1995-03-18 17:15:15 +00:00
|
|
|
|
1997-09-18 14:56:47 +00:00
|
|
|
#ifndef STRICT_OPENSTEP
|
1999-06-14 09:07:52 +00:00
|
|
|
+ (NSValue*) valueWithBytes: (const void*)value objCType: (const char*)type;
|
|
|
|
/* Designated initializer for all concrete subclasses */
|
2001-12-17 14:31:42 +00:00
|
|
|
- (id) initWithBytes: (const void*)data objCType: (const char*)type;
|
1998-03-12 14:21:20 +00:00
|
|
|
- (BOOL) isEqualToValue: (NSValue*)other;
|
1997-09-18 14:56:47 +00:00
|
|
|
#endif
|
|
|
|
|
1995-03-18 17:15:15 +00:00
|
|
|
// Accessing Data
|
|
|
|
|
1995-03-23 03:47:56 +00:00
|
|
|
- (void) getValue: (void*)value;
|
|
|
|
- (const char*) objCType;
|
|
|
|
- (id) nonretainedObjectValue;
|
|
|
|
- (void*) pointerValue;
|
2001-01-12 14:29:34 +00:00
|
|
|
- (NSRange) rangeValue;
|
1995-03-23 03:47:56 +00:00
|
|
|
- (NSRect) rectValue;
|
|
|
|
- (NSSize) sizeValue;
|
|
|
|
- (NSPoint) pointValue;
|
1995-03-18 17:15:15 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
1998-03-12 14:21:20 +00:00
|
|
|
@interface NSNumber : NSValue <NSCopying,NSCoding>
|
1995-03-18 17:15:15 +00:00
|
|
|
|
|
|
|
// Allocating and Initializing
|
|
|
|
|
1995-03-23 03:47:56 +00:00
|
|
|
+ (NSNumber*) numberWithBool: (BOOL)value;
|
2000-08-07 22:00:31 +00:00
|
|
|
+ (NSNumber*) numberWithChar: (signed char)value;
|
1995-03-23 03:47:56 +00:00
|
|
|
+ (NSNumber*) numberWithDouble: (double)value;
|
|
|
|
+ (NSNumber*) numberWithFloat: (float)value;
|
2000-08-07 22:00:31 +00:00
|
|
|
+ (NSNumber*) numberWithInt: (signed int)value;
|
|
|
|
+ (NSNumber*) numberWithLong: (signed long)value;
|
|
|
|
+ (NSNumber*) numberWithLongLong: (signed long long)value;
|
|
|
|
+ (NSNumber*) numberWithShort: (signed short)value;
|
1995-03-23 03:47:56 +00:00
|
|
|
+ (NSNumber*) numberWithUnsignedChar: (unsigned char)value;
|
|
|
|
+ (NSNumber*) numberWithUnsignedInt: (unsigned int)value;
|
|
|
|
+ (NSNumber*) numberWithUnsignedLong: (unsigned long)value;
|
|
|
|
+ (NSNumber*) numberWithUnsignedLongLong: (unsigned long long)value;
|
|
|
|
+ (NSNumber*) numberWithUnsignedShort: (unsigned short)value;
|
1995-03-18 17:15:15 +00:00
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (id) initWithBool: (BOOL)value;
|
2000-08-07 22:00:31 +00:00
|
|
|
- (id) initWithChar: (signed char)value;
|
2000-03-19 20:57:09 +00:00
|
|
|
- (id) initWithDouble: (double)value;
|
|
|
|
- (id) initWithFloat: (float)value;
|
2000-08-07 22:00:31 +00:00
|
|
|
- (id) initWithInt: (signed int)value;
|
|
|
|
- (id) initWithLong: (signed long)value;
|
|
|
|
- (id) initWithLongLong: (signed long long)value;
|
|
|
|
- (id) initWithShort: (signed short)value;
|
2000-03-19 20:57:09 +00:00
|
|
|
- (id) initWithUnsignedChar: (unsigned char)value;
|
|
|
|
- (id) initWithUnsignedInt: (unsigned int)value;
|
|
|
|
- (id) initWithUnsignedLong: (unsigned long)value;
|
|
|
|
- (id) initWithUnsignedLongLong: (unsigned long long)value;
|
|
|
|
- (id) initWithUnsignedShort: (unsigned short)value;
|
1998-02-05 22:06:20 +00:00
|
|
|
|
1995-03-18 17:15:15 +00:00
|
|
|
// Accessing Data
|
|
|
|
|
1995-03-23 03:47:56 +00:00
|
|
|
- (BOOL) boolValue;
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed char) charValue;
|
1995-03-23 03:47:56 +00:00
|
|
|
- (double) doubleValue;
|
|
|
|
- (float) floatValue;
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed int) intValue;
|
|
|
|
- (signed long long) longLongValue;
|
|
|
|
- (signed long) longValue;
|
|
|
|
- (signed short) shortValue;
|
1995-03-23 03:47:56 +00:00
|
|
|
- (NSString*) stringValue;
|
|
|
|
- (unsigned char) unsignedCharValue;
|
|
|
|
- (unsigned int) unsignedIntValue;
|
|
|
|
- (unsigned long long) unsignedLongLongValue;
|
|
|
|
- (unsigned long) unsignedLongValue;
|
|
|
|
- (unsigned short) unsignedShortValue;
|
|
|
|
|
1998-02-05 22:06:20 +00:00
|
|
|
- (NSString*) description;
|
|
|
|
- (NSString*) descriptionWithLocale: (NSDictionary*)locale;
|
|
|
|
|
1995-03-23 03:47:56 +00:00
|
|
|
- (NSComparisonResult) compare: (NSNumber*)otherNumber;
|
1998-02-05 22:06:20 +00:00
|
|
|
- (BOOL) isEqualToNumber: (NSNumber*)otherNumber;
|
1995-03-18 17:15:15 +00:00
|
|
|
@end
|
1995-03-23 03:47:56 +00:00
|
|
|
|
1999-06-14 09:07:52 +00:00
|
|
|
#ifndef NO_GNUSTEP
|
2003-04-17 06:20:17 +00:00
|
|
|
|
|
|
|
@interface NSNumber(GSCategories)
|
|
|
|
+ (NSValue*) valueFromString: (NSString *)string;
|
|
|
|
@end
|
|
|
|
|
1999-06-14 09:07:52 +00:00
|
|
|
/* Note: This method is not in the OpenStep spec, but they makes
|
1995-04-03 20:07:18 +00:00
|
|
|
subclassing easier. */
|
|
|
|
@interface NSValue (Subclassing)
|
|
|
|
|
1999-06-14 09:07:52 +00:00
|
|
|
/* Used by value: withObjCType: to determine the concrete subclass to alloc */
|
2000-03-19 20:57:09 +00:00
|
|
|
+ (Class) valueClassWithObjCType: (const char*)type;
|
1995-04-03 20:07:18 +00:00
|
|
|
|
|
|
|
@end
|
2000-03-19 20:57:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cache info for internal use by NSNumber concrete subclasses.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2000-03-23 18:57:43 +00:00
|
|
|
int typeLevel;
|
|
|
|
void (*getValue)(NSNumber*, SEL, void*);
|
2000-03-19 20:57:09 +00:00
|
|
|
} GSNumberInfo;
|
|
|
|
|
|
|
|
GSNumberInfo *GSNumberInfoFromObject(NSNumber *o);
|
|
|
|
#define GS_SMALL 16
|
|
|
|
/*
|
|
|
|
* Get cached values for integers in the range -GS_SMALL to +GS_SMALL
|
|
|
|
*/
|
|
|
|
unsigned GSSmallHash(int n);
|
1999-06-14 09:07:52 +00:00
|
|
|
#endif
|
1995-04-03 20:07:18 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#endif /* __NSValue_h_GNUSTEP_BASE_INCLUDE */
|