27#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
37static NSSet *
SetForObject(
id object, NSSet *defaultValue);
41@implementation NSArray (OOExtractor)
43- (char) oo_charAtIndex:(NSUInteger)index defaultValue:(
char)value
45 return OOCharFromObject([
self oo_objectAtIndex:index], value);
49- (short) oo_shortAtIndex:(NSUInteger)index defaultValue:(
short)value
51 return OOShortFromObject([
self oo_objectAtIndex:index], value);
55- (
int) oo_intAtIndex:(NSUInteger)index defaultValue:(
int)value
57 return OOIntFromObject([
self oo_objectAtIndex:index], value);
61- (
long) oo_longAtIndex:(NSUInteger)index defaultValue:(
long)value
63 return OOLongFromObject([
self oo_objectAtIndex:index], value);
67- (
long long) oo_longLongAtIndex:(NSUInteger)index defaultValue:(
long long)value
73- (NSInteger) oo_integerAtIndex:(NSUInteger)index defaultValue:(NSInteger)value
79- (
unsigned char) oo_unsignedCharAtIndex:(NSUInteger)index defaultValue:(
unsigned char)value
81 return OOUnsignedCharFromObject([
self oo_objectAtIndex:index], value);
85- (
unsigned short) oo_unsignedShortAtIndex:(NSUInteger)index defaultValue:(
unsigned short)value
87 return OOUnsignedShortFromObject([
self oo_objectAtIndex:index], value);
91- (
unsigned int) oo_unsignedIntAtIndex:(NSUInteger)index defaultValue:(
unsigned int)value
93 return OOUnsignedIntFromObject([
self oo_objectAtIndex:index], value);
97- (
unsigned long) oo_unsignedLongAtIndex:(NSUInteger)index defaultValue:(
unsigned long)value
99 return OOUnsignedLongFromObject([
self oo_objectAtIndex:index], value);
103- (
unsigned long long) oo_unsignedLongLongAtIndex:(NSUInteger)index defaultValue:(
unsigned long long)value
109- (NSUInteger) oo_unsignedIntegerAtIndex:(NSUInteger)index defaultValue:(NSUInteger)value
115- (BOOL) oo_boolAtIndex:(NSUInteger)index defaultValue:(BOOL)value
121#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
122- (BOOL) oo_fuzzyBooleanAtIndex:(NSUInteger)index defaultValue:(
float)value
129- (float) oo_floatAtIndex:(NSUInteger)index defaultValue:(
float)value
135- (double) oo_doubleAtIndex:(NSUInteger)index defaultValue:(
double)value
141- (float) oo_nonNegativeFloatAtIndex:(NSUInteger)index defaultValue:(
float)value
147- (double) oo_nonNegativeDoubleAtIndex:(NSUInteger)index defaultValue:(
double)value
153- (id) oo_objectAtIndex:(NSUInteger)index defaultValue:(
id)value
155 id objVal = [
self oo_objectAtIndex:index];
158 if (objVal !=
nil) result = objVal;
165- (id) oo_objectOfClass:(Class)class atIndex:(NSUInteger)index defaultValue:(
id)value
167 id objVal = [
self oo_objectAtIndex:index];
170 if ([objVal isKindOfClass:
class]) result = objVal;
177- (NSString *) oo_stringAtIndex:(NSUInteger)index defaultValue:(NSString *)value
183- (NSArray *) oo_arrayAtIndex:(NSUInteger)index defaultValue:(NSArray *)value
185 return [
self oo_objectOfClass:[NSArray class] atIndex:index defaultValue:value];
189- (NSSet *) oo_setAtIndex:(NSUInteger)index defaultValue:(NSSet *)value
191 return SetForObject([
self oo_objectAtIndex:index], value);
195- (NSDictionary *) oo_dictionaryAtIndex:(NSUInteger)index defaultValue:(NSDictionary *)value
197 return [
self oo_objectOfClass:[NSDictionary class] atIndex:index defaultValue:value];
201- (NSData *) oo_dataAtIndex:(NSUInteger)index defaultValue:(NSData *)value
203 return [
self oo_objectOfClass:[NSData class] atIndex:index defaultValue:value];
207#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
208- (Vector) oo_vectorAtIndex:(NSUInteger)index defaultValue:(Vector)value
214- (Quaternion) oo_quaternionAtIndex:(NSUInteger)index defaultValue:(Quaternion)value
221- (char) oo_charAtIndex:(NSUInteger)index
223 return [
self oo_charAtIndex:index defaultValue:0];
227- (short) oo_shortAtIndex:(NSUInteger)index
229 return [
self oo_shortAtIndex:index defaultValue:0];
233- (
int) oo_intAtIndex:(NSUInteger)index
235 return [
self oo_intAtIndex:index defaultValue:0];
239- (
long) oo_longAtIndex:(NSUInteger)index
241 return [
self oo_longAtIndex:index defaultValue:0];
245- (
long long) oo_longLongAtIndex:(NSUInteger)index
247 return [
self oo_longLongAtIndex:index defaultValue:0];
251- (NSInteger) oo_integerAtIndex:(NSUInteger)index
253 return [
self oo_integerAtIndex:index defaultValue:0];
257- (
unsigned char) oo_unsignedCharAtIndex:(NSUInteger)index
259 return [
self oo_unsignedCharAtIndex:index defaultValue:0];
263- (
unsigned short) oo_unsignedShortAtIndex:(NSUInteger)index
265 return [
self oo_unsignedShortAtIndex:index defaultValue:0];
269- (
unsigned int) oo_unsignedIntAtIndex:(NSUInteger)index
271 return [
self oo_unsignedIntAtIndex:index defaultValue:0];
275- (
unsigned long) oo_unsignedLongAtIndex:(NSUInteger)index
277 return [
self oo_unsignedLongAtIndex:index defaultValue:0];
281- (
unsigned long long) oo_unsignedLongLongAtIndex:(NSUInteger)index
283 return [
self oo_unsignedLongLongAtIndex:index defaultValue:0];
287- (NSUInteger) oo_unsignedIntegerAtIndex:(NSUInteger)index
289 return [
self oo_unsignedIntegerAtIndex:index defaultValue:0];
293- (BOOL) oo_boolAtIndex:(NSUInteger)index
295 return [
self oo_boolAtIndex:index defaultValue:NO];
299#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
300- (BOOL) oo_fuzzyBooleanAtIndex:(NSUInteger)index
302 return [
self oo_fuzzyBooleanAtIndex:index defaultValue:0.0f];
307- (float) oo_floatAtIndex:(NSUInteger)index
313- (double) oo_doubleAtIndex:(NSUInteger)index
319- (float) oo_nonNegativeFloatAtIndex:(NSUInteger)index
325- (double) oo_nonNegativeDoubleAtIndex:(NSUInteger)index
331- (id) oo_objectAtIndex:(NSUInteger)index
333 if (index < [
self count])
return [
self objectAtIndex:index];
338- (id) oo_objectOfClass:(Class)class atIndex:(NSUInteger)index
340 return [
self oo_objectOfClass:class atIndex:index defaultValue:nil];
344- (NSString *) oo_stringAtIndex:(NSUInteger)index
346 return [
self oo_stringAtIndex:index defaultValue:nil];
350- (NSArray *) oo_arrayAtIndex:(NSUInteger)index
352 return [
self oo_arrayAtIndex:index defaultValue:nil];
356- (NSSet *) oo_setAtIndex:(NSUInteger)index
358 return [
self oo_setAtIndex:index defaultValue:nil];
362- (NSDictionary *) oo_dictionaryAtIndex:(NSUInteger)index
364 return [
self oo_dictionaryAtIndex:index defaultValue:nil];
368- (NSData *) oo_dataAtIndex:(NSUInteger)index
370 return [
self oo_dataAtIndex:index defaultValue:nil];
374#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
375- (Vector) oo_vectorAtIndex:(NSUInteger)index
377 return [
self oo_vectorAtIndex:index defaultValue:kZeroVector];
381- (Quaternion) oo_quaternionAtIndex:(NSUInteger)index
383 return [
self oo_quaternionAtIndex:index defaultValue:kIdentityQuaternion];
390@implementation NSDictionary (OOExtractor)
392- (char) oo_charForKey:(
id)key defaultValue:(
char)value
394 return OOCharFromObject([
self objectForKey:key], value);
398- (short) oo_shortForKey:(
id)key defaultValue:(
short)value
400 return OOShortFromObject([
self objectForKey:key], value);
404- (
int) oo_intForKey:(
id)key defaultValue:(
int)value
406 return OOIntFromObject([
self objectForKey:key], value);
410- (
long) oo_longForKey:(
id)key defaultValue:(
long)value
412 return OOLongFromObject([
self objectForKey:key], value);
416- (
long long) oo_longLongForKey:(
id)key defaultValue:(
long long)value
422- (NSInteger) oo_integerForKey:(
id)key defaultValue:(NSInteger)value
428- (
unsigned char) oo_unsignedCharForKey:(
id)key defaultValue:(
unsigned char)value
430 return OOUnsignedCharFromObject([
self objectForKey:key], value);
434- (
unsigned short) oo_unsignedShortForKey:(
id)key defaultValue:(
unsigned short)value
436 return OOUnsignedShortFromObject([
self objectForKey:key], value);
440- (
unsigned int) oo_unsignedIntForKey:(
id)key defaultValue:(
unsigned int)value
442 return OOUnsignedIntFromObject([
self objectForKey:key], value);
446- (
unsigned long) oo_unsignedLongForKey:(
id)key defaultValue:(
unsigned long)value
448 return OOUnsignedLongFromObject([
self objectForKey:key], value);
452- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key defaultValue:(
unsigned long long)value
458- (NSUInteger) oo_unsignedIntegerForKey:(
id)key defaultValue:(NSUInteger)value
464- (BOOL) oo_boolForKey:(
id)key defaultValue:(BOOL)value
470#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
471- (BOOL) oo_fuzzyBooleanForKey:(
id)key defaultValue:(
float)value
478- (float) oo_floatForKey:(
id)key defaultValue:(
float)value
484- (double) oo_doubleForKey:(
id)key defaultValue:(
double)value
490- (float) oo_nonNegativeFloatForKey:(
id)key defaultValue:(
float)value
496- (double) oo_nonNegativeDoubleForKey:(
id)key defaultValue:(
double)value
502- (id) oo_objectForKey:(
id)key defaultValue:(
id)value
504 id objVal = [
self objectForKey:key];
507 if (objVal !=
nil) result = objVal;
514- (id) oo_objectOfClass:(Class)class forKey:(
id)key defaultValue:(
id)value
516 id objVal = [
self objectForKey:key];
519 if ([objVal isKindOfClass:
class]) result = objVal;
526- (NSString *) oo_stringForKey:(
id)key defaultValue:(NSString *)value
532- (NSArray *) oo_arrayForKey:(
id)key defaultValue:(NSArray *)value
534 return [
self oo_objectOfClass:[NSArray class] forKey:key defaultValue:value];
538- (NSSet *) oo_setForKey:(
id)key defaultValue:(NSSet *)value
544- (NSDictionary *) oo_dictionaryForKey:(
id)key defaultValue:(NSDictionary *)value
546 return [
self oo_objectOfClass:[NSDictionary class] forKey:key defaultValue:value];
550- (NSMutableDictionary *) oo_mutableDictionaryForKey:(
id)key defaultValue:(NSDictionary *)value
552 return [
self oo_objectOfClass:[NSMutableDictionary class] forKey:key defaultValue:value];
557- (NSData *) oo_dataForKey:(
id)key defaultValue:(NSData *)value
559 return [
self oo_objectOfClass:[NSData class] forKey:key defaultValue:value];
563#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
564- (Vector) oo_vectorForKey:(
id)key defaultValue:(Vector)value
569- (HPVector) oo_hpvectorForKey:(
id)key defaultValue:(HPVector)value
575- (Quaternion) oo_quaternionForKey:(
id)key defaultValue:(Quaternion)value
582- (char) oo_charForKey:(
id)key
584 return [
self oo_charForKey:key defaultValue:0];
588- (short) oo_shortForKey:(
id)key
590 return [
self oo_shortForKey:key defaultValue:0];
594- (
int) oo_intForKey:(
id)key
596 return [
self oo_intForKey:key defaultValue:0];
600- (
long) oo_longForKey:(
id)key
602 return [
self oo_longForKey:key defaultValue:0];
606- (
long long) oo_longLongForKey:(
id)key
608 return [
self oo_longLongForKey:key defaultValue:0];
612- (NSInteger) oo_integerForKey:(
id)key
614 return [
self oo_integerForKey:key defaultValue:0];
618- (
unsigned char) oo_unsignedCharForKey:(
id)key
620 return [
self oo_unsignedCharForKey:key defaultValue:0];
624- (
unsigned short) oo_unsignedShortForKey:(
id)key
626 return [
self oo_unsignedShortForKey:key defaultValue:0];
630- (
unsigned int) oo_unsignedIntForKey:(
id)key
632 return [
self oo_unsignedIntForKey:key defaultValue:0];
636- (
unsigned long) oo_unsignedLongForKey:(
id)key
638 return [
self oo_unsignedLongForKey:key defaultValue:0];
642- (NSUInteger) oo_unsignedIntegerForKey:(
id)key
644 return [
self oo_unsignedIntegerForKey:key defaultValue:0];
648- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key
650 return [
self oo_unsignedLongLongForKey:key defaultValue:0];
654- (BOOL) oo_boolForKey:(
id)key
656 return [
self oo_boolForKey:key defaultValue:NO];
660#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
661- (BOOL) oo_fuzzyBooleanForKey:(
id)key
663 return [
self oo_fuzzyBooleanForKey:key defaultValue:0.0f];
668- (float) oo_floatForKey:(
id)key
674- (double) oo_doubleForKey:(
id)key
680- (float) oo_nonNegativeFloatForKey:(
id)key
686- (double) oo_nonNegativeDoubleForKey:(
id)key
692- (id) oo_objectOfClass:(Class)class forKey:(
id)key
694 return [
self oo_objectOfClass:class forKey:key defaultValue:nil];
698- (NSString *) oo_stringForKey:(
id)key
700 return [
self oo_stringForKey:key defaultValue:nil];
704- (NSArray *) oo_arrayForKey:(
id)key
706 return [
self oo_arrayForKey:key defaultValue:nil];
710- (NSSet *) oo_setForKey:(
id)key
712 return [
self oo_setForKey:key defaultValue:nil];
716- (NSDictionary *) oo_dictionaryForKey:(
id)key
718 return [
self oo_dictionaryForKey:key defaultValue:nil];
722- (NSMutableDictionary *) oo_mutableDictionaryForKey:(
id)key
724 return [
self oo_mutableDictionaryForKey:key defaultValue:nil];
728- (NSData *) oo_dataForKey:(
id)key
730 return [
self oo_dataForKey:key defaultValue:nil];
734#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
735- (Vector) oo_vectorForKey:(
id)key
737 return [
self oo_vectorForKey:key defaultValue:kZeroVector];
740- (HPVector) oo_hpvectorForKey:(
id)key
742 return [
self oo_hpvectorForKey:key defaultValue:kZeroHPVector];
746- (Quaternion) oo_quaternionForKey:(
id)key
748 return [
self oo_quaternionForKey:key defaultValue:kIdentityQuaternion];
755@implementation NSUserDefaults (OOExtractor)
757- (char) oo_charForKey:(
id)key defaultValue:(
char)value
759 return OOCharFromObject([
self objectForKey:key], value);
763- (short) oo_shortForKey:(
id)key defaultValue:(
short)value
765 return OOShortFromObject([
self objectForKey:key], value);
769- (
int) oo_intForKey:(
id)key defaultValue:(
int)value
771 return OOIntFromObject([
self objectForKey:key], value);
775- (
long) oo_longForKey:(
id)key defaultValue:(
long)value
777 return OOLongFromObject([
self objectForKey:key], value);
781- (
long long) oo_longLongForKey:(
id)key defaultValue:(
long long)value
787- (NSInteger) oo_integerForKey:(
id)key defaultValue:(NSInteger)value
793- (
unsigned char) oo_unsignedCharForKey:(
id)key defaultValue:(
unsigned char)value
795 return OOUnsignedCharFromObject([
self objectForKey:key], value);
799- (
unsigned short) oo_unsignedShortForKey:(
id)key defaultValue:(
unsigned short)value
801 return OOUnsignedShortFromObject([
self objectForKey:key], value);
805- (
unsigned int) oo_unsignedIntForKey:(
id)key defaultValue:(
unsigned int)value
807 return OOUnsignedIntFromObject([
self objectForKey:key], value);
811- (
unsigned long) oo_unsignedLongForKey:(
id)key defaultValue:(
unsigned long)value
813 return OOUnsignedLongFromObject([
self objectForKey:key], value);
817- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key defaultValue:(
unsigned long long)value
823- (NSUInteger) oo_unsignedIntegerForKey:(
id)key defaultValue:(NSUInteger)value
829- (BOOL) oo_boolForKey:(
id)key defaultValue:(BOOL)value
835#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
836- (BOOL) oo_fuzzyBooleanForKey:(
id)key defaultValue:(
float)value
843- (float) oo_floatForKey:(
id)key defaultValue:(
float)value
849- (double) oo_doubleForKey:(
id)key defaultValue:(
double)value
855- (float) oo_nonNegativeFloatForKey:(
id)key defaultValue:(
float)value
861- (double) oo_nonNegativeDoubleForKey:(
id)key defaultValue:(
double)value
867- (id) oo_objectForKey:(
id)key defaultValue:(
id)value
869 id objVal = [
self objectForKey:key];
872 if (objVal !=
nil) result = objVal;
879- (id) oo_objectOfClass:(Class)class forKey:(
id)key defaultValue:(
id)value
881 id objVal = [
self objectForKey:key];
884 if ([objVal isKindOfClass:
class]) result = objVal;
891- (NSString *) oo_stringForKey:(
id)key defaultValue:(NSString *)value
897- (NSArray *) oo_arrayForKey:(
id)key defaultValue:(NSArray *)value
899 return [
self oo_objectOfClass:[NSArray class] forKey:key defaultValue:value];
903- (NSSet *) oo_setForKey:(
id)key defaultValue:(NSSet *)value
909- (NSDictionary *) oo_dictionaryForKey:(
id)key defaultValue:(NSDictionary *)value
911 return [
self oo_objectOfClass:[NSDictionary class] forKey:key defaultValue:value];
915- (NSData *) oo_dataForKey:(
id)key defaultValue:(NSData *)value
917 return [
self oo_objectOfClass:[NSData class] forKey:key defaultValue:value];
921- (char) oo_charForKey:(
id)key
923 return [
self oo_charForKey:key defaultValue:0];
927- (short) oo_shortForKey:(
id)key
929 return [
self oo_shortForKey:key defaultValue:0];
933- (
int) oo_intForKey:(
id)key
935 return [
self oo_intForKey:key defaultValue:0];
939- (
long) oo_longForKey:(
id)key
941 return [
self oo_longForKey:key defaultValue:0];
945- (
long long) oo_longLongForKey:(
id)key
947 return [
self oo_longLongForKey:key defaultValue:0];
951- (
unsigned char) oo_unsignedCharForKey:(
id)key
953 return [
self oo_unsignedCharForKey:key defaultValue:0];
957- (
unsigned short) oo_unsignedShortForKey:(
id)key
959 return [
self oo_unsignedShortForKey:key defaultValue:0];
963- (
unsigned int) oo_unsignedIntForKey:(
id)key
965 return [
self oo_unsignedIntForKey:key defaultValue:0];
969- (
unsigned long) oo_unsignedLongForKey:(
id)key
971 return [
self oo_unsignedLongForKey:key defaultValue:0];
975- (
unsigned long long) oo_unsignedLongLongForKey:(
id)key
977 return [
self oo_unsignedLongLongForKey:key defaultValue:0];
981#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
982- (BOOL) oo_fuzzyBooleanForKey:(
id)key
984 return [
self oo_fuzzyBooleanForKey:key defaultValue:0.0f];
989- (double) oo_doubleForKey:(NSString *)key
995- (float) oo_nonNegativeFloatForKey:(
id)key
1001- (double) oo_nonNegativeDoubleForKey:(
id)key
1007- (id) oo_objectOfClass:(Class)class forKey:(
id)key
1009 return [
self oo_objectOfClass:class forKey:key defaultValue:nil];
1013- (NSSet *) oo_setForKey:(
id)key
1015 return [
self oo_setForKey:key defaultValue:nil];
1021@implementation NSMutableArray (OOInserter)
1023- (void) oo_addInteger:(
long)value
1025 [
self addObject:[NSNumber numberWithLong:value]];
1029- (void) oo_addUnsignedInteger:(
unsigned long)value
1031 [
self addObject:[NSNumber numberWithUnsignedLong:value]];
1035- (void) oo_addFloat:(
double)value
1037 [
self addObject:[NSNumber numberWithDouble:value]];
1041- (void) oo_addBool:(BOOL)value
1043 [
self addObject:[NSNumber numberWithBool:value]];
1047#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1048- (void) oo_addVector:(Vector)value
1050 [
self addObject:OOPropertyListFromVector(value)];
1054- (void) oo_addQuaternion:(Quaternion)value
1056 [
self addObject:OOPropertyListFromQuaternion(value)];
1061- (void) oo_insertInteger:(
long)value atIndex:(NSUInteger)index
1063 [
self insertObject:[NSNumber numberWithLong:value] atIndex:index];
1067- (void) oo_insertUnsignedInteger:(
unsigned long)value atIndex:(NSUInteger)index
1069 [
self insertObject:[NSNumber numberWithUnsignedLong:value] atIndex:index];
1073- (void) oo_insertFloat:(
double)value atIndex:(NSUInteger)index
1075 [
self insertObject:[NSNumber numberWithDouble:value] atIndex:index];
1079- (void) oo_insertBool:(BOOL)value atIndex:(NSUInteger)index
1081 [
self insertObject:[NSNumber numberWithBool:value] atIndex:index];
1085#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1086- (void) oo_insertVector:(Vector)value atIndex:(NSUInteger)index
1088 [
self insertObject:OOPropertyListFromVector(value) atIndex:index];
1092- (void) oo_insertQuaternion:(Quaternion)value atIndex:(NSUInteger)index
1094 [
self insertObject:OOPropertyListFromQuaternion(value) atIndex:index];
1101@implementation NSMutableDictionary (OOInserter)
1103- (void) oo_setInteger:(
long)value forKey:(
id)key
1105 [
self setObject:[NSNumber numberWithLong:value] forKey:key];
1109- (void) oo_setUnsignedInteger:(
unsigned long)value forKey:(
id)key
1111 [
self setObject:[NSNumber numberWithUnsignedLong:value] forKey:key];
1115- (void) oo_setLongLong:(
long long)value forKey:(
id)key
1117 [
self setObject:[NSNumber numberWithLongLong:value] forKey:key];
1121- (void) oo_setUnsignedLongLong:(
unsigned long long)value forKey:(
id)key
1123 [
self setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:key];
1127- (void) oo_setFloat:(
double)value forKey:(
id)key
1129 [
self setObject:[NSNumber numberWithDouble:value] forKey:key];
1133- (void) oo_setBool:(BOOL)value forKey:(
id)key
1135 [
self setObject:[NSNumber numberWithBool:value] forKey:key];
1139#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1140- (void) oo_setVector:(Vector)value forKey:(
id)key
1142 [
self setObject:OOPropertyListFromVector(value) forKey:key];
1145- (void) oo_setHPVector:(HPVector)value forKey:(
id)key
1147 [
self setObject:OOPropertyListFromHPVector(value) forKey:key];
1150- (void) oo_setQuaternion:(Quaternion)value forKey:(
id)key
1152 [
self setObject:OOPropertyListFromQuaternion(value) forKey:key];
1159@implementation NSMutableSet (OOInserter)
1161- (void) oo_addInteger:(
long)value
1163 [
self addObject:[NSNumber numberWithLong:value]];
1167- (void) oo_addUnsignedInteger:(
unsigned long)value
1169 [
self addObject:[NSNumber numberWithUnsignedLong:value]];
1173- (void) oo_addFloat:(
double)value
1175 [
self addObject:[NSNumber numberWithDouble:value]];
1179- (void) oo_addBool:(BOOL)value
1181 [
self addObject:[NSNumber numberWithBool:value]];
1185#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1186- (void) oo_addVector:(Vector)value
1188 [
self addObject:OOPropertyListFromVector(value)];
1192- (void) oo_addQuaternion:(Quaternion)value
1194 [
self addObject:OOPropertyListFromQuaternion(value)];
1205 if ([
object respondsToSelector:
@selector(longLongValue)]) llValue = [object longLongValue];
1206 else if ([
object respondsToSelector:
@selector(longValue)]) llValue = [object longValue];
1207 else if ([
object respondsToSelector:
@selector(intValue)]) llValue = [object intValue];
1208 else llValue = defaultValue;
1216 unsigned long long ullValue;
1218 if ([
object respondsToSelector:
@selector(unsignedLongLongValue)]) ullValue = [object unsignedLongLongValue];
1219 else if ([
object respondsToSelector:
@selector(unsignedLongValue)]) ullValue = [object unsignedLongValue];
1220 else if ([
object respondsToSelector:
@selector(unsignedIntValue)]) ullValue = [object unsignedIntValue];
1221 else if ([
object respondsToSelector:
@selector(intValue)]) ullValue = [object intValue];
1222 else ullValue = defaultValue;
1230 return value ==
' ' || value ==
'\t';
1244 unsigned long i = 0,
count = [string length];
1245#define PEEK() ((i >= count) ? -1 : [string characterAtIndex:i])
1248 if (
PEEK() ==
' ') ++i;
1249 return PEEK() ==
'0';
1257 if (NSOrderedSame == [
string caseInsensitiveCompare:
@"yes"] ||
1258 NSOrderedSame == [
string caseInsensitiveCompare:
@"true"] ||
1259 NSOrderedSame == [
string caseInsensitiveCompare:
@"on"] ||
1260 [
string doubleValue] != 0.0)
1264 else if (NSOrderedSame == [
string caseInsensitiveCompare:
@"no"] ||
1265 NSOrderedSame == [
string caseInsensitiveCompare:
@"false"] ||
1266 NSOrderedSame == [
string caseInsensitiveCompare:
@"off"] ||
1271 return defaultValue;
1275#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1278 if (NSOrderedSame == [
string caseInsensitiveCompare:
@"yes"] ||
1279 NSOrderedSame == [
string caseInsensitiveCompare:
@"true"] ||
1280 NSOrderedSame == [
string caseInsensitiveCompare:
@"on"] ||
1281 [
string doubleValue] != 0.0)
1285 else if (NSOrderedSame == [
string caseInsensitiveCompare:
@"no"] ||
1286 NSOrderedSame == [
string caseInsensitiveCompare:
@"false"] ||
1287 NSOrderedSame == [
string caseInsensitiveCompare:
@"off"] ||
1292 return defaultValue;
1301 if ([
object isKindOfClass:[NSString
class]])
1307 if ([
object respondsToSelector:
@selector(boolValue)]) result = [object boolValue];
1308 else if ([
object respondsToSelector:
@selector(intValue)]) result = [object intValue] != 0;
1309 else result = defaultValue;
1316#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1321 if ([
object isKindOfClass:[NSString
class]])
1323 probability = [object floatValue];
1341 return randf() < probability;
1350 if ([
object respondsToSelector:
@selector(floatValue)])
1352 result = [object floatValue];
1353 if (result == 0.0f && [
object isKindOfClass:[NSString
class]] && !
IsZeroString(
object)) result = defaultValue;
1355 else if ([
object respondsToSelector:
@selector(doubleValue)]) result = [object doubleValue];
1356 else if ([
object respondsToSelector:
@selector(intValue)]) result = [object intValue];
1357 else result = defaultValue;
1367 if ([
object respondsToSelector:
@selector(doubleValue)])
1369 result = [object doubleValue];
1370 if (result == 0.0 && [
object isKindOfClass:[NSString
class]] && !
IsZeroString(
object)) result = defaultValue;
1372 else if ([
object respondsToSelector:
@selector(floatValue)]) result = [object floatValue];
1373 else if ([
object respondsToSelector:
@selector(intValue)]) result = [object intValue];
1374 else result = defaultValue;
1384 if ([
object respondsToSelector:
@selector(floatValue)]) result = [object floatValue];
1385 else if ([
object respondsToSelector:
@selector(doubleValue)]) result = [object doubleValue];
1386 else if ([
object respondsToSelector:
@selector(intValue)]) result = [object intValue];
1387 else return defaultValue;
1389 return fmax(result, 0.0f);
1397 if ([
object respondsToSelector:
@selector(doubleValue)]) result = [object doubleValue];
1398 else if ([
object respondsToSelector:
@selector(floatValue)]) result = [object floatValue];
1399 else if ([
object respondsToSelector:
@selector(intValue)]) result = [object intValue];
1400 else return defaultValue;
1402 return fmax(result, 0.0);
1406#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1409 Vector result = defaultValue;
1410 NSDictionary *dict =
nil;
1412 if ([
object isKindOfClass:[OONativeVector
class]])
1414 result = [object getVector];
1416 else if ([
object isKindOfClass:[NSString
class]])
1421 else if ([
object isKindOfClass:[NSArray
class]] && [
object count] == 3)
1423 result.x = [object oo_floatAtIndex:0];
1424 result.y = [object oo_floatAtIndex:1];
1425 result.z = [object oo_floatAtIndex:2];
1427 else if ([
object isKindOfClass:[NSDictionary
class]])
1431 if ([dict objectForKey:
@"x"] !=
nil ||
1432 [dict objectForKey:
@"y"] !=
nil ||
1433 [dict objectForKey:
@"z"] !=
nil)
1436 result.x = [dict oo_floatForKey:@"x" defaultValue:0.0f];
1437 result.y = [dict oo_floatForKey:@"y" defaultValue:0.0f];
1438 result.z = [dict oo_floatForKey:@"z" defaultValue:0.0f];
1447 HPVector result = defaultValue;
1448 NSDictionary *dict =
nil;
1450 if ([
object isKindOfClass:[NSString
class]])
1455 else if ([
object isKindOfClass:[NSArray
class]] && [
object count] == 3)
1457 result.x = [object oo_doubleAtIndex:0];
1458 result.y = [object oo_doubleAtIndex:1];
1459 result.z = [object oo_doubleAtIndex:2];
1461 else if ([
object isKindOfClass:[NSDictionary
class]])
1465 if ([dict objectForKey:
@"x"] !=
nil ||
1466 [dict objectForKey:
@"y"] !=
nil ||
1467 [dict objectForKey:
@"z"] !=
nil)
1470 result.x = [dict oo_doubleForKey:@"x" defaultValue:0.0];
1471 result.y = [dict oo_doubleForKey:@"y" defaultValue:0.0];
1472 result.z = [dict oo_doubleForKey:@"z" defaultValue:0.0];
1482 Quaternion result = defaultValue;
1483 NSDictionary *dict =
nil;
1485 if ([
object isKindOfClass:[NSString
class]])
1490 else if ([
object isKindOfClass:[NSArray
class]] && [
object count] == 4)
1492 result.w = [object oo_floatAtIndex:0];
1493 result.x = [object oo_floatAtIndex:1];
1494 result.y = [object oo_floatAtIndex:2];
1495 result.z = [object oo_floatAtIndex:3];
1497 else if ([
object isKindOfClass:[NSDictionary
class]])
1501 if ([dict objectForKey:
@"w"] !=
nil ||
1502 [dict objectForKey:
@"x"] !=
nil ||
1503 [dict objectForKey:
@"y"] !=
nil ||
1504 [dict objectForKey:
@"z"] !=
nil)
1507 result.w = [dict oo_floatForKey:@"w" defaultValue:0.0f];
1508 result.x = [dict oo_floatForKey:@"x" defaultValue:0.0f];
1509 result.y = [dict oo_floatForKey:@"y" defaultValue:0.0f];
1510 result.z = [dict oo_floatForKey:@"z" defaultValue:0.0f];
1520 return [NSDictionary dictionaryWithObjectsAndKeys:
1521 [NSNumber numberWithFloat:value.x], @"x",
1522 [NSNumber numberWithFloat:value.y], @"y",
1523 [NSNumber numberWithFloat:value.z], @"z",
1529 return [NSDictionary dictionaryWithObjectsAndKeys:
1530 [NSNumber numberWithDouble:value.x], @"x",
1531 [NSNumber numberWithDouble:value.y], @"y",
1532 [NSNumber numberWithDouble:value.z], @"z",
1539 return [NSDictionary dictionaryWithObjectsAndKeys:
1540 [NSNumber numberWithFloat:value.w], @"w",
1541 [NSNumber numberWithFloat:value.x], @"x",
1542 [NSNumber numberWithFloat:value.y], @"y",
1543 [NSNumber numberWithFloat:value.z], @"z",
1551 if ([
object isKindOfClass:[NSArray
class]])
return [NSSet setWithArray:object];
1552 else if ([
object isKindOfClass:[NSSet
class]])
return [[object copy] autorelease];
1554 return defaultValue;
1560 if ([
object isKindOfClass:[NSString
class]])
return object;
1561 else if ([
object respondsToSelector:
@selector(stringValue)])
return [object stringValue];
1563 return defaultValue;
BOOL ScanHPVectorFromString(NSString *xyzString, HPVector *outVector)
BOOL ScanQuaternionFromString(NSString *wxyzString, Quaternion *outQuaternion)
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque