43#import <Foundation/Foundation.h>
47#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
53@interface NSArray (OOExtractor)
55- (char) oo_charAtIndex:(NSUInteger)index defaultValue:(
char)value;
56- (short) oo_shortAtIndex:(NSUInteger)index defaultValue:(
short)value;
57- (
int) oo_intAtIndex:(NSUInteger)index defaultValue:(
int)value;
58- (
long) oo_longAtIndex:(NSUInteger)index defaultValue:(
long)value;
59- (
long long) oo_longLongAtIndex:(NSUInteger)index defaultValue:(
long long)value;
60- (NSInteger) oo_integerAtIndex:(NSUInteger)index defaultValue:(NSInteger)value;
62- (
unsigned char) oo_unsignedCharAtIndex:(NSUInteger)index defaultValue:(
unsigned char)value;
63- (
unsigned short) oo_unsignedShortAtIndex:(NSUInteger)index defaultValue:(
unsigned short)value;
64- (
unsigned int) oo_unsignedIntAtIndex:(NSUInteger)index defaultValue:(
unsigned int)value;
65- (
unsigned long) oo_unsignedLongAtIndex:(NSUInteger)index defaultValue:(
unsigned long)value;
66- (
unsigned long long) oo_unsignedLongLongAtIndex:(NSUInteger)index defaultValue:(
unsigned long long)value;
67- (NSUInteger) oo_unsignedIntegerAtIndex:(NSUInteger)index defaultValue:(NSUInteger)value;
69- (BOOL) oo_boolAtIndex:(NSUInteger)index defaultValue:(BOOL)value;
70#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
71- (BOOL) oo_fuzzyBooleanAtIndex:(NSUInteger)index defaultValue:(
float)value;
74- (float) oo_floatAtIndex:(NSUInteger)index defaultValue:(
float)value;
75- (double) oo_doubleAtIndex:(NSUInteger)index defaultValue:(
double)value;
76- (float) oo_nonNegativeFloatAtIndex:(NSUInteger)index defaultValue:(
float)value;
77- (double) oo_nonNegativeDoubleAtIndex:(NSUInteger)index defaultValue:(
double)value;
79- (id) oo_objectAtIndex:(NSUInteger)index defaultValue:(
id)value;
80- (id) oo_objectOfClass:(Class)class atIndex:(NSUInteger)index defaultValue:(
id)value;
81- (NSString *) oo_stringAtIndex:(NSUInteger)index defaultValue:(NSString *)value;
82- (NSArray *) oo_arrayAtIndex:(NSUInteger)index defaultValue:(NSArray *)value;
83- (NSSet *) oo_setAtIndex:(NSUInteger)index defaultValue:(NSSet *)value;
84- (NSDictionary *) oo_dictionaryAtIndex:(NSUInteger)index defaultValue:(NSDictionary *)value;
85- (NSData *) oo_dataAtIndex:(NSUInteger)index defaultValue:(NSData *)value;
87#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
88- (Vector) oo_vectorAtIndex:(NSUInteger)index defaultValue:(Vector)value;
89- (Quaternion) oo_quaternionAtIndex:(NSUInteger)index defaultValue:(Quaternion)value;
94- (char) oo_charAtIndex:(NSUInteger)index;
95- (short) oo_shortAtIndex:(NSUInteger)index;
96- (
int) oo_intAtIndex:(NSUInteger)index;
97- (
long) oo_longAtIndex:(NSUInteger)index;
98- (
long long) oo_longLongAtIndex:(NSUInteger)index;
99- (NSInteger) oo_integerAtIndex:(NSUInteger)index;
101- (
unsigned char) oo_unsignedCharAtIndex:(NSUInteger)index;
102- (
unsigned short) oo_unsignedShortAtIndex:(NSUInteger)index;
103- (
unsigned int) oo_unsignedIntAtIndex:(NSUInteger)index;
104- (
unsigned long) oo_unsignedLongAtIndex:(NSUInteger)index;
105- (
unsigned long long) oo_unsignedLongLongAtIndex:(NSUInteger)index;
106- (NSUInteger) oo_unsignedIntegerAtIndex:(NSUInteger)index;
109- (BOOL) oo_boolAtIndex:(NSUInteger)index;
110#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
111- (BOOL) oo_fuzzyBooleanAtIndex:(NSUInteger)index;
115- (float) oo_floatAtIndex:(NSUInteger)index;
116- (double) oo_doubleAtIndex:(NSUInteger)index;
117- (float) oo_nonNegativeFloatAtIndex:(NSUInteger)index;
118- (double) oo_nonNegativeDoubleAtIndex:(NSUInteger)index;
121- (id) oo_objectAtIndex:(NSUInteger)index;
122- (id) oo_objectOfClass:(Class)class atIndex:(NSUInteger)index;
123- (NSString *) oo_stringAtIndex:(NSUInteger)index;
124- (NSArray *) oo_arrayAtIndex:(NSUInteger)index;
125- (NSSet *) oo_setAtIndex:(NSUInteger)index;
126- (NSDictionary *) oo_dictionaryAtIndex:(NSUInteger)index;
127- (NSData *) oo_dataAtIndex:(NSUInteger)index;
129#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
131- (Vector) oo_vectorAtIndex:(NSUInteger)index;
133- (Quaternion) oo_quaternionAtIndex:(NSUInteger)index;
139@interface NSDictionary (OOExtractor)
141- (char) oo_charForKey:(
id)key defaultValue:(
char)value;
142- (short) oo_shortForKey:(
id)key defaultValue:(
short)value;
143- (
int) oo_intForKey:(
id)key defaultValue:(
int)value;
144- (
long) oo_longForKey:(
id)key defaultValue:(
long)value;
145- (
long long) oo_longLongForKey:(
id)key defaultValue:(
long long)value;
146- (NSInteger) oo_integerForKey:(
id)key defaultValue:(NSInteger)value;
148- (
unsigned char) oo_unsignedCharForKey:(
id)key defaultValue:(
unsigned char)value;
149- (
unsigned short) oo_unsignedShortForKey:(
id)key defaultValue:(
unsigned short)value;
150- (
unsigned int) oo_unsignedIntForKey:(
id)key defaultValue:(
unsigned int)value;
151- (
unsigned long) oo_unsignedLongForKey:(
id)key defaultValue:(
unsigned long)value;
152- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key defaultValue:(
unsigned long long)value;
153- (NSUInteger) oo_unsignedIntegerForKey:(
id)key defaultValue:(NSUInteger)value;
155- (BOOL) oo_boolForKey:(
id)key defaultValue:(BOOL)value;
156#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
157- (BOOL) oo_fuzzyBooleanForKey:(
id)key defaultValue:(
float)value;
160- (float) oo_floatForKey:(
id)key defaultValue:(
float)value;
161- (double) oo_doubleForKey:(
id)key defaultValue:(
double)value;
162- (float) oo_nonNegativeFloatForKey:(
id)key defaultValue:(
float)value;
163- (double) oo_nonNegativeDoubleForKey:(
id)key defaultValue:(
double)value;
165- (id) oo_objectForKey:(
id)key defaultValue:(
id)value;
166- (id) oo_objectOfClass:(Class)class forKey:(
id)key defaultValue:(
id)value;
167- (NSString *) oo_stringForKey:(
id)key defaultValue:(NSString *)value;
168- (NSArray *) oo_arrayForKey:(
id)key defaultValue:(NSArray *)value;
169- (NSSet *) oo_setForKey:(
id)key defaultValue:(NSSet *)value;
170- (NSDictionary *) oo_dictionaryForKey:(
id)key defaultValue:(NSDictionary *)value;
171- (NSMutableDictionary *) oo_mutableDictionaryForKey:(
id)key defaultValue:(NSDictionary *)value;
172- (NSData *) oo_dataForKey:(
id)key defaultValue:(NSData *)value;
174#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
175- (Vector) oo_vectorForKey:(
id)key defaultValue:(Vector)value;
176- (HPVector) oo_hpvectorForKey:(
id)key defaultValue:(HPVector)value;
177- (Quaternion) oo_quaternionForKey:(
id)key defaultValue:(Quaternion)value;
182- (char) oo_charForKey:(
id)key;
183- (short) oo_shortForKey:(
id)key;
184- (
int) oo_intForKey:(
id)key;
185- (
long) oo_longForKey:(
id)key;
186- (
long long) oo_longLongForKey:(
id)key;
187- (NSInteger) oo_integerForKey:(
id)key;
189- (
unsigned char) oo_unsignedCharForKey:(
id)key;
190- (
unsigned short) oo_unsignedShortForKey:(
id)key;
191- (
unsigned int) oo_unsignedIntForKey:(
id)key;
192- (
unsigned long) oo_unsignedLongForKey:(
id)key;
193- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key;
194- (NSUInteger) oo_unsignedIntegerForKey:(
id)key;
197- (BOOL) oo_boolForKey:(
id)key;
198#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
199- (BOOL) oo_fuzzyBooleanForKey:(
id)key;
203- (float) oo_floatForKey:(
id)key;
204- (double) oo_doubleForKey:(
id)key;
205- (float) oo_nonNegativeFloatForKey:(
id)key;
206- (double) oo_nonNegativeDoubleForKey:(
id)key;
210- (id) oo_objectOfClass:(Class)class forKey:(
id)key;
211- (NSString *) oo_stringForKey:(
id)key;
212- (NSArray *) oo_arrayForKey:(
id)key;
213- (NSSet *) oo_setForKey:(
id)key;
214- (NSDictionary *) oo_dictionaryForKey:(
id)key;
215- (NSMutableDictionary *) oo_mutableDictionaryForKey:(
id)key;
216- (NSData *) oo_dataForKey:(
id)key;
218#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
220- (Vector) oo_vectorForKey:(
id)key;
222- (HPVector) oo_hpvectorForKey:(
id)key;
224- (Quaternion) oo_quaternionForKey:(
id)key;
230@interface NSUserDefaults (OOExtractor)
232- (char) oo_charForKey:(
id)key defaultValue:(
char)value;
233- (short) oo_shortForKey:(
id)key defaultValue:(
short)value;
234- (
int) oo_intForKey:(
id)key defaultValue:(
int)value;
235- (
long) oo_longForKey:(
id)key defaultValue:(
long)value;
236- (
long long) oo_longLongForKey:(
id)key defaultValue:(
long long)value;
237- (NSInteger) oo_integerForKey:(
id)key defaultValue:(NSInteger)value;
239- (
unsigned char) oo_unsignedCharForKey:(
id)key defaultValue:(
unsigned char)value;
240- (
unsigned short) oo_unsignedShortForKey:(
id)key defaultValue:(
unsigned short)value;
241- (
unsigned int) oo_unsignedIntForKey:(
id)key defaultValue:(
unsigned int)value;
242- (
unsigned long) oo_unsignedLongForKey:(
id)key defaultValue:(
unsigned long)value;
243- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key defaultValue:(
unsigned long long)value;
244- (NSUInteger) oo_unsignedIntegerForKey:(
id)key defaultValue:(NSUInteger)value;
246- (BOOL) oo_boolForKey:(
id)key defaultValue:(BOOL)value;
247#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
248- (BOOL) oo_fuzzyBooleanForKey:(
id)key defaultValue:(
float)value;
251- (float) oo_floatForKey:(
id)key defaultValue:(
float)value;
252- (double) oo_doubleForKey:(
id)key defaultValue:(
double)value;
253- (float) oo_nonNegativeFloatForKey:(
id)key defaultValue:(
float)value;
254- (double) oo_nonNegativeDoubleForKey:(
id)key defaultValue:(
double)value;
256- (id) oo_objectForKey:(
id)key defaultValue:(
id)value;
257- (id) oo_objectOfClass:(Class)class forKey:(
id)key defaultValue:(
id)value;
258- (NSString *) oo_stringForKey:(
id)key defaultValue:(NSString *)value;
259- (NSArray *) oo_arrayForKey:(
id)key defaultValue:(NSArray *)value;
260- (NSSet *) oo_setForKey:(
id)key defaultValue:(NSSet *)value;
261- (NSDictionary *) oo_dictionaryForKey:(
id)key defaultValue:(NSDictionary *)value;
262- (NSData *) oo_dataForKey:(
id)key defaultValue:(NSData *)value;
266- (char) oo_charForKey:(
id)key;
267- (short) oo_shortForKey:(
id)key;
268- (
int) oo_intForKey:(
id)key;
269- (
long) oo_longForKey:(
id)key;
270- (
long long) oo_longLongForKey:(
id)key;
272- (
unsigned char) oo_unsignedCharForKey:(
id)key;
273- (
unsigned short) oo_unsignedShortForKey:(
id)key;
274- (
unsigned int) oo_unsignedIntForKey:(
id)key;
275- (
unsigned long) oo_unsignedLongForKey:(
id)key;
276- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key;
280#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
281- (BOOL) oo_fuzzyBooleanForKey:(
id)key;
286- (double) oo_doubleForKey:(NSString *)key;
287- (float) oo_nonNegativeFloatForKey:(
id)key;
288- (double) oo_nonNegativeDoubleForKey:(
id)key;
292- (id) oo_objectOfClass:(Class)class forKey:(
id)key;
295- (NSSet *) oo_setForKey:(
id)key;
302@interface NSMutableArray (OOInserter)
304- (void) oo_addInteger:(
long)value;
305- (void) oo_addUnsignedInteger:(
unsigned long)value;
306- (void) oo_addFloat:(
double)value;
307- (void) oo_addBool:(BOOL)value;
308#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
309- (void) oo_addVector:(Vector)value;
310- (void) oo_addQuaternion:(Quaternion)value;
313- (void) oo_insertInteger:(
long)value atIndex:(NSUInteger)index;
314- (void) oo_insertUnsignedInteger:(
unsigned long)value atIndex:(NSUInteger)index;
315- (void) oo_insertFloat:(
double)value atIndex:(NSUInteger)index;
316- (void) oo_insertBool:(BOOL)value atIndex:(NSUInteger)index;
317#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
318- (void) oo_insertVector:(Vector)value atIndex:(NSUInteger)index;
319- (void) oo_insertQuaternion:(Quaternion)value atIndex:(NSUInteger)index;
325@interface NSMutableDictionary (OOInserter)
327- (void) oo_setInteger:(
long)value forKey:(
id)key;
328- (void) oo_setUnsignedInteger:(
unsigned long)value forKey:(
id)key;
329- (void) oo_setLongLong:(
long long)value forKey:(
id)key;
330- (void) oo_setUnsignedLongLong:(
unsigned long long)value forKey:(
id)key;
331- (void) oo_setFloat:(
double)value forKey:(
id)key;
332- (void) oo_setBool:(BOOL)value forKey:(
id)key;
333#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
334- (void) oo_setVector:(Vector)value forKey:(
id)key;
335- (void) oo_setHPVector:(HPVector)value forKey:(
id)key;
336- (void) oo_setQuaternion:(Quaternion)value forKey:(
id)key;
342@interface NSMutableSet (OOInserter)
344- (void)oo_addInteger:(
long)value;
345- (void)oo_addUnsignedInteger:(
unsigned long)value;
346- (void)oo_addFloat:(
double)value;
347- (void)oo_addBool:(BOOL)value;
348#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
349- (void)oo_addVector:(Vector)value;
350- (void)oo_addQuaternion:(Quaternion)value;
371#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
385#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
404 return (minValue < value) ? ((value < maxValue) ? value : maxValue) : minValue;
424#define OO_DEFINE_CLAMP(type, typeName, min, max) \
425 OOINLINE type OO ## typeName ## FromObject(id object, type defaultValue) \
427 return (type)OOClampInteger(OOLongLongFromObject(object, defaultValue), min, max); \
430#define OO_DEFINE_CLAMP_PAIR(type, typeName, minMaxSymb) \
431 OO_DEFINE_CLAMP(type, typeName, minMaxSymb ## _MIN, minMaxSymb ## _MAX) \
432 OO_DEFINE_CLAMP(unsigned type, Unsigned ## typeName, 0, U ## minMaxSymb ## _MAX)
444#define OO_ALIAS_CLAMP_LONG_LONG(type, typeName) \
445static inline type OO##typeName##FromObject(id object, type defaultValue) \
447 return OOLongLongFromObject(object, defaultValue); \
449#define OO_ALIAS_CLAMP_PAIR_LONG_LONG(type, typeName) \
450OO_ALIAS_CLAMP_LONG_LONG(type, typeName) \
451OO_ALIAS_CLAMP_LONG_LONG(unsigned type, Unsigned##typeName)
453#if INT_MAX == LLONG_MAX
460#if LONG_MAX == LLONG_MAX
480 return OOLongFromObject(
object, defaultValue);
485 return OOUnsignedLongFromObject(
object, defaultValue);
490#undef OO_DEFINE_CLAMP
491#undef OO_DEFINE_CLAMP_PAIR
492#undef OO_ALIAS_CLAMP_LONG_LONG
493#undef OO_ALIAS_CLAMP_PAIR_LONG_LONG
#define ALWAYS_INLINE_FUNC
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque