27#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
36static NSSet*
SetForObject(
id object, NSSet* defaultValue);
39@implementation NSArray (OOExtractor)
41- (char)oo_charAtIndex:(NSUInteger)index defaultValue:(
char)value
43 return OOCharFromObject([
self oo_objectAtIndex:index], value);
46- (short)oo_shortAtIndex:(NSUInteger)index defaultValue:(
short)value
48 return OOShortFromObject([
self oo_objectAtIndex:index], value);
51- (
int)oo_intAtIndex:(NSUInteger)index defaultValue:(
int)value
53 return OOIntFromObject([
self oo_objectAtIndex:index], value);
56- (
long)oo_longAtIndex:(NSUInteger)index defaultValue:(
long)value
58 return OOLongFromObject([
self oo_objectAtIndex:index], value);
61- (
long long)oo_longLongAtIndex:(NSUInteger)index defaultValue:(
long long)value
66- (NSInteger)oo_integerAtIndex:(NSUInteger)index defaultValue:(NSInteger)value
71- (
unsigned char)oo_unsignedCharAtIndex:(NSUInteger)index defaultValue:(
unsigned char)value
73 return OOUnsignedCharFromObject([
self oo_objectAtIndex:index], value);
76- (
unsigned short)oo_unsignedShortAtIndex:(NSUInteger)index defaultValue:(
unsigned short)value
78 return OOUnsignedShortFromObject([
self oo_objectAtIndex:index], value);
81- (
unsigned int)oo_unsignedIntAtIndex:(NSUInteger)index defaultValue:(
unsigned int)value
83 return OOUnsignedIntFromObject([
self oo_objectAtIndex:index], value);
86- (
unsigned long)oo_unsignedLongAtIndex:(NSUInteger)index defaultValue:(
unsigned long)value
88 return OOUnsignedLongFromObject([
self oo_objectAtIndex:index], value);
91- (
unsigned long long)oo_unsignedLongLongAtIndex:(NSUInteger)index defaultValue:(
unsigned long long)value
96- (NSUInteger)oo_unsignedIntegerAtIndex:(NSUInteger)index defaultValue:(NSUInteger)value
101- (BOOL)oo_boolAtIndex:(NSUInteger)index defaultValue:(BOOL)value
106#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
107- (BOOL)oo_fuzzyBooleanAtIndex:(NSUInteger)index defaultValue:(
float)value
113- (float)oo_floatAtIndex:(NSUInteger)index defaultValue:(
float)value
118- (double)oo_doubleAtIndex:(NSUInteger)index defaultValue:(
double)value
123- (float)oo_nonNegativeFloatAtIndex:(NSUInteger)index defaultValue:(
float)value
128- (double)oo_nonNegativeDoubleAtIndex:(NSUInteger)index defaultValue:(
double)value
133- (id)oo_objectAtIndex:(NSUInteger)index defaultValue:(
id)value
146- (id)oo_objectOfClass:(Class)class atIndex:(NSUInteger)index defaultValue:(
id)value
151 if ([objVal isKindOfClass:
class])
159- (NSString*)oo_stringAtIndex:(NSUInteger)index defaultValue:(NSString*)value
164- (NSArray*)oo_arrayAtIndex:(NSUInteger)index defaultValue:(NSArray*)value
169- (NSSet*)oo_setAtIndex:(NSUInteger)index defaultValue:(NSSet*)value
171 return SetForObject([
self oo_objectAtIndex:index], value);
174- (NSDictionary*)oo_dictionaryAtIndex:(NSUInteger)index defaultValue:(NSDictionary*)value
179- (NSData*)oo_dataAtIndex:(NSUInteger)index defaultValue:(NSData*)value
184#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
196- (char)oo_charAtIndex:(NSUInteger)index
201- (short)oo_shortAtIndex:(NSUInteger)index
206- (
int)oo_intAtIndex:(NSUInteger)index
211- (
long)oo_longAtIndex:(NSUInteger)index
216- (
long long)oo_longLongAtIndex:(NSUInteger)index
221- (NSInteger)oo_integerAtIndex:(NSUInteger)index
226- (
unsigned char)oo_unsignedCharAtIndex:(NSUInteger)index
231- (
unsigned short)oo_unsignedShortAtIndex:(NSUInteger)index
236- (
unsigned int)oo_unsignedIntAtIndex:(NSUInteger)index
241- (
unsigned long)oo_unsignedLongAtIndex:(NSUInteger)index
246- (
unsigned long long)oo_unsignedLongLongAtIndex:(NSUInteger)index
251- (NSUInteger)oo_unsignedIntegerAtIndex:(NSUInteger)index
256- (BOOL)oo_boolAtIndex:(NSUInteger)index
261#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
262- (BOOL)oo_fuzzyBooleanAtIndex:(NSUInteger)index
268- (float)oo_floatAtIndex:(NSUInteger)index
273- (double)oo_doubleAtIndex:(NSUInteger)index
278- (float)oo_nonNegativeFloatAtIndex:(NSUInteger)index
283- (double)oo_nonNegativeDoubleAtIndex:(NSUInteger)index
288- (id)oo_objectAtIndex:(NSUInteger)index
290 if (index < [
self count])
291 return [
self objectAtIndex:index];
296- (id)oo_objectOfClass:(Class)class atIndex:(NSUInteger)index
301- (NSString*)oo_stringAtIndex:(NSUInteger)index
306- (NSArray*)oo_arrayAtIndex:(NSUInteger)index
311- (NSSet*)oo_setAtIndex:(NSUInteger)index
316- (NSDictionary*)oo_dictionaryAtIndex:(NSUInteger)index
321- (NSData*)oo_dataAtIndex:(NSUInteger)index
326#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
327- (
Vector)oo_vectorAtIndex:(NSUInteger)index
340@implementation NSDictionary (OOExtractor)
342- (char)oo_charForKey:(
id)key defaultValue:(
char)value
344 return OOCharFromObject([
self objectForKey:key], value);
347- (short)oo_shortForKey:(
id)key defaultValue:(
short)value
349 return OOShortFromObject([
self objectForKey:key], value);
352- (
int)oo_intForKey:(
id)key defaultValue:(
int)value
354 return OOIntFromObject([
self objectForKey:key], value);
357- (
long)oo_longForKey:(
id)key defaultValue:(
long)value
359 return OOLongFromObject([
self objectForKey:key], value);
362- (
long long)oo_longLongForKey:(
id)key defaultValue:(
long long)value
367- (NSInteger)oo_integerForKey:(
id)key defaultValue:(NSInteger)value
372- (
unsigned char)oo_unsignedCharForKey:(
id)key defaultValue:(
unsigned char)value
374 return OOUnsignedCharFromObject([
self objectForKey:key], value);
377- (
unsigned short)oo_unsignedShortForKey:(
id)key defaultValue:(
unsigned short)value
379 return OOUnsignedShortFromObject([
self objectForKey:key], value);
382- (
unsigned int)oo_unsignedIntForKey:(
id)key defaultValue:(
unsigned int)value
384 return OOUnsignedIntFromObject([
self objectForKey:key], value);
387- (
unsigned long)oo_unsignedLongForKey:(
id)key defaultValue:(
unsigned long)value
389 return OOUnsignedLongFromObject([
self objectForKey:key], value);
392- (
unsigned long long)oo_unsignedLongLongForKey:(
id)key defaultValue:(
unsigned long long)value
397- (NSUInteger)oo_unsignedIntegerForKey:(
id)key defaultValue:(NSUInteger)value
402- (BOOL)oo_boolForKey:(
id)key defaultValue:(BOOL)value
407#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
408- (BOOL)oo_fuzzyBooleanForKey:(
id)key defaultValue:(
float)value
414- (float)oo_floatForKey:(
id)key defaultValue:(
float)value
419- (double)oo_doubleForKey:(
id)key defaultValue:(
double)value
424- (float)oo_nonNegativeFloatForKey:(
id)key defaultValue:(
float)value
429- (double)oo_nonNegativeDoubleForKey:(
id)key defaultValue:(
double)value
434- (id)oo_objectForKey:(
id)key defaultValue:(
id)value
436 id objVal = [
self objectForKey:key];
447- (id)oo_objectOfClass:(Class)class forKey:(
id)key defaultValue:(
id)value
449 id objVal = [
self objectForKey:key];
452 if ([objVal isKindOfClass:
class])
460- (NSString*)oo_stringForKey:(
id)key defaultValue:(NSString*)value
465- (NSArray*)oo_arrayForKey:(
id)key defaultValue:(NSArray*)value
470- (NSSet*)oo_setForKey:(
id)key defaultValue:(NSSet*)value
475- (NSDictionary*)oo_dictionaryForKey:(
id)key defaultValue:(NSDictionary*)value
480- (NSMutableDictionary*)oo_mutableDictionaryForKey:(
id)key defaultValue:(NSDictionary*)value
485- (NSData*)oo_dataForKey:(
id)key defaultValue:(NSData*)value
490#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
507- (char)oo_charForKey:(
id)key
512- (short)oo_shortForKey:(
id)key
517- (
int)oo_intForKey:(
id)key
527- (
long long)oo_longLongForKey:(
id)key
532- (NSInteger)oo_integerForKey:(
id)key
537- (
unsigned char)oo_unsignedCharForKey:(
id)key
542- (
unsigned short)oo_unsignedShortForKey:(
id)key
547- (
unsigned int)oo_unsignedIntForKey:(
id)key
552- (
unsigned long)oo_unsignedLongForKey:(
id)key
557- (NSUInteger)oo_unsignedIntegerForKey:(
id)key
562- (
unsigned long long)oo_unsignedLongLongForKey:(
id)key
567- (BOOL)oo_boolForKey:(
id)key
572#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
573- (BOOL)oo_fuzzyBooleanForKey:(
id)key
579- (float)oo_floatForKey:(
id)key
584- (double)oo_doubleForKey:(
id)key
589- (float)oo_nonNegativeFloatForKey:(
id)key
594- (double)oo_nonNegativeDoubleForKey:(
id)key
599- (id)oo_objectOfClass:(Class)class forKey:(
id)key
604- (NSString*)oo_stringForKey:(
id)key
609- (NSArray*)oo_arrayForKey:(
id)key
614- (NSSet*)oo_setForKey:(
id)key
619- (NSDictionary*)oo_dictionaryForKey:(
id)key
624- (NSMutableDictionary*)oo_mutableDictionaryForKey:(
id)key
629- (NSData*)oo_dataForKey:(
id)key
634#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
653@implementation NSUserDefaults (OOExtractor)
655- (char)oo_charForKey:(
id)key defaultValue:(
char)value
657 return OOCharFromObject([
self objectForKey:key], value);
660- (short)oo_shortForKey:(
id)key defaultValue:(
short)value
662 return OOShortFromObject([
self objectForKey:key], value);
665- (
int)oo_intForKey:(
id)key defaultValue:(
int)value
667 return OOIntFromObject([
self objectForKey:key], value);
670- (
long)oo_longForKey:(
id)key defaultValue:(
long)value
672 return OOLongFromObject([
self objectForKey:key], value);
675- (
long long)oo_longLongForKey:(
id)key defaultValue:(
long long)value
680- (NSInteger)oo_integerForKey:(
id)key defaultValue:(NSInteger)value
685- (
unsigned char)oo_unsignedCharForKey:(
id)key defaultValue:(
unsigned char)value
687 return OOUnsignedCharFromObject([
self objectForKey:key], value);
690- (
unsigned short)oo_unsignedShortForKey:(
id)key defaultValue:(
unsigned short)value
692 return OOUnsignedShortFromObject([
self objectForKey:key], value);
695- (
unsigned int)oo_unsignedIntForKey:(
id)key defaultValue:(
unsigned int)value
697 return OOUnsignedIntFromObject([
self objectForKey:key], value);
700- (
unsigned long)oo_unsignedLongForKey:(
id)key defaultValue:(
unsigned long)value
702 return OOUnsignedLongFromObject([
self objectForKey:key], value);
705- (
unsigned long long)oo_unsignedLongLongForKey:(
id)key defaultValue:(
unsigned long long)value
710- (NSUInteger)oo_unsignedIntegerForKey:(
id)key defaultValue:(NSUInteger)value
715- (BOOL)oo_boolForKey:(
id)key defaultValue:(BOOL)value
720#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
721- (BOOL)oo_fuzzyBooleanForKey:(
id)key defaultValue:(
float)value
727- (float)oo_floatForKey:(
id)key defaultValue:(
float)value
732- (double)oo_doubleForKey:(
id)key defaultValue:(
double)value
737- (float)oo_nonNegativeFloatForKey:(
id)key defaultValue:(
float)value
742- (double)oo_nonNegativeDoubleForKey:(
id)key defaultValue:(
double)value
747- (id)oo_objectForKey:(
id)key defaultValue:(
id)value
749 id objVal = [
self objectForKey:key];
760- (id)oo_objectOfClass:(Class)class forKey:(
id)key defaultValue:(
id)value
762 id objVal = [
self objectForKey:key];
765 if ([objVal isKindOfClass:
class])
773- (NSString*)oo_stringForKey:(
id)key defaultValue:(NSString*)value
778- (NSArray*)oo_arrayForKey:(
id)key defaultValue:(NSArray*)value
783- (NSSet*)oo_setForKey:(
id)key defaultValue:(NSSet*)value
788- (NSDictionary*)oo_dictionaryForKey:(
id)key defaultValue:(NSDictionary*)value
793- (NSData*)oo_dataForKey:(
id)key defaultValue:(NSData*)value
798- (char)oo_charForKey:(
id)key
803- (short)oo_shortForKey:(
id)key
808- (
int)oo_intForKey:(
id)key
818- (
long long)oo_longLongForKey:(
id)key
823- (
unsigned char)oo_unsignedCharForKey:(
id)key
828- (
unsigned short)oo_unsignedShortForKey:(
id)key
833- (
unsigned int)oo_unsignedIntForKey:(
id)key
838- (
unsigned long)oo_unsignedLongForKey:(
id)key
843- (
unsigned long long)oo_unsignedLongLongForKey:(
id)key
848#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
849- (BOOL)oo_fuzzyBooleanForKey:(
id)key
855- (double)oo_doubleForKey:(NSString*)key
860- (float)oo_nonNegativeFloatForKey:(
id)key
865- (double)oo_nonNegativeDoubleForKey:(
id)key
870- (id)oo_objectOfClass:(Class)class forKey:(
id)key
875- (NSSet*)oo_setForKey:(
id)key
882@implementation NSMutableArray (OOInserter)
884- (void)oo_addInteger:(
long)value
886 [
self addObject:[
NSNumber numberWithLong:value]];
889- (void)oo_addUnsignedInteger:(
unsigned long)value
891 [
self addObject:[
NSNumber numberWithUnsignedLong:value]];
894- (void)oo_addFloat:(
double)value
896 [
self addObject:[
NSNumber numberWithDouble:value]];
899- (void)oo_addBool:(BOOL)value
901 [
self addObject:[
NSNumber numberWithBool:value]];
904#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
907 [
self addObject:OOPropertyListFromVector(value)];
912 [
self addObject:OOPropertyListFromQuaternion(value)];
916- (void)oo_insertInteger:(
long)value atIndex:(NSUInteger)index
918 [
self insertObject:[
NSNumber numberWithLong:value] atIndex:index];
921- (void)oo_insertUnsignedInteger:(
unsigned long)value atIndex:(NSUInteger)index
923 [
self insertObject:[
NSNumber numberWithUnsignedLong:value] atIndex:index];
926- (void)oo_insertFloat:(
double)value atIndex:(NSUInteger)index
928 [
self insertObject:[
NSNumber numberWithDouble:value] atIndex:index];
931- (void)oo_insertBool:(BOOL)value atIndex:(NSUInteger)index
933 [
self insertObject:[
NSNumber numberWithBool:value] atIndex:index];
936#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
937- (void)oo_insertVector:(
Vector)value atIndex:(NSUInteger)index
939 [
self insertObject:OOPropertyListFromVector(value) atIndex:index];
942- (void)oo_insertQuaternion:(
Quaternion)value atIndex:(NSUInteger)index
944 [
self insertObject:OOPropertyListFromQuaternion(value) atIndex:index];
950@implementation NSMutableDictionary (OOInserter)
952- (void)oo_setInteger:(
long)value forKey:(
id)key
954 [
self setObject:[
NSNumber numberWithLong:value] forKey:key];
957- (void)oo_setUnsignedInteger:(
unsigned long)value forKey:(
id)key
959 [
self setObject:[
NSNumber numberWithUnsignedLong:value] forKey:key];
962- (void)oo_setLongLong:(
long long)value forKey:(
id)key
964 [
self setObject:[
NSNumber numberWithLongLong:value] forKey:key];
967- (void)oo_setUnsignedLongLong:(
unsigned long long)value forKey:(
id)key
969 [
self setObject:[
NSNumber numberWithUnsignedLongLong:value] forKey:key];
972- (void)oo_setFloat:(
double)value forKey:(
id)key
974 [
self setObject:[
NSNumber numberWithDouble:value] forKey:key];
977- (void)oo_setBool:(BOOL)value forKey:(
id)key
979 [
self setObject:[
NSNumber numberWithBool:value] forKey:key];
982#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
983- (void)oo_setVector:(
Vector)value forKey:(
id)key
985 [
self setObject:OOPropertyListFromVector(value) forKey:key];
988- (void)oo_setHPVector:(
HPVector)value forKey:(
id)key
990 [
self setObject:OOPropertyListFromHPVector(value) forKey:key];
995 [
self setObject:OOPropertyListFromQuaternion(value) forKey:key];
1001@implementation NSMutableSet (OOInserter)
1003- (void)oo_addInteger:(
long)value
1005 [
self addObject:[
NSNumber numberWithLong:value]];
1008- (void)oo_addUnsignedInteger:(
unsigned long)value
1010 [
self addObject:[
NSNumber numberWithUnsignedLong:value]];
1013- (void)oo_addFloat:(
double)value
1015 [
self addObject:[
NSNumber numberWithDouble:value]];
1018- (void)oo_addBool:(BOOL)value
1020 [
self addObject:[
NSNumber numberWithBool:value]];
1023#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1026 [
self addObject:OOPropertyListFromVector(value)];
1031 [
self addObject:OOPropertyListFromQuaternion(value)];
1041 if ([
object respondsToSelector:
@selector(longLongValue)])
1042 llValue = [object longLongValue];
1043 else if ([
object respondsToSelector:
@selector(longValue)])
1044 llValue = [object longValue];
1045 else if ([
object respondsToSelector:
@selector(intValue)])
1046 llValue = [object intValue];
1048 llValue = defaultValue;
1055 unsigned long long ullValue;
1057 if ([
object respondsToSelector:
@selector(unsignedLongLongValue)])
1058 ullValue = [object unsignedLongLongValue];
1059 else if ([
object respondsToSelector:
@selector(unsignedLongValue)])
1060 ullValue = [object unsignedLongValue];
1061 else if ([
object respondsToSelector:
@selector(unsignedIntValue)])
1062 ullValue = [object unsignedIntValue];
1063 else if ([
object respondsToSelector:
@selector(intValue)])
1064 ullValue = [object intValue];
1066 ullValue = defaultValue;
1073 return value ==
' ' || value ==
'\t';
1086 unsigned long i = 0,
count = [string length];
1087#define PEEK() ((i >= count) ? -1 : [string characterAtIndex:i])
1093 return PEEK() ==
'0';
1100 if (NSOrderedSame == [
string caseInsensitiveCompare:
@"yes"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"true"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"on"] ||
1101 [
string doubleValue] != 0.0)
1104 }
else if (NSOrderedSame == [
string caseInsensitiveCompare:
@"no"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"false"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"off"] ||
IsZeroString(
string)) {
1107 return defaultValue;
1110#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1113 if (NSOrderedSame == [
string caseInsensitiveCompare:
@"yes"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"true"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"on"] ||
1114 [
string doubleValue] != 0.0)
1117 }
else if (NSOrderedSame == [
string caseInsensitiveCompare:
@"no"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"false"] || NSOrderedSame == [
string caseInsensitiveCompare:
@"off"] ||
IsZeroString(
string)) {
1120 return defaultValue;
1128 if ([
object isKindOfClass:[NSString
class]]) {
1131 if ([
object respondsToSelector:
@selector(boolValue)])
1132 result = [object boolValue];
1133 else if ([
object respondsToSelector:
@selector(intValue)])
1134 result = [object intValue] != 0;
1136 result = defaultValue;
1142#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1147 if ([
object isKindOfClass:[NSString
class]]) {
1148 probability = [object floatValue];
1163 return randf() < probability;
1171 if ([
object respondsToSelector:
@selector(floatValue)]) {
1172 result = [object floatValue];
1173 if (result == 0.0f && [
object isKindOfClass:[NSString
class]] && !
IsZeroString(
object))
1174 result = defaultValue;
1175 }
else if ([
object respondsToSelector:
@selector(doubleValue)])
1176 result = [object doubleValue];
1177 else if ([
object respondsToSelector:
@selector(intValue)])
1178 result = [object intValue];
1180 result = defaultValue;
1189 if ([
object respondsToSelector:
@selector(doubleValue)]) {
1190 result = [object doubleValue];
1191 if (result == 0.0 && [
object isKindOfClass:[NSString
class]] && !
IsZeroString(
object))
1192 result = defaultValue;
1193 }
else if ([
object respondsToSelector:
@selector(floatValue)])
1194 result = [object floatValue];
1195 else if ([
object respondsToSelector:
@selector(intValue)])
1196 result = [object intValue];
1198 result = defaultValue;
1207 if ([
object respondsToSelector:
@selector(floatValue)])
1208 result = [object floatValue];
1209 else if ([
object respondsToSelector:
@selector(doubleValue)])
1210 result = [object doubleValue];
1211 else if ([
object respondsToSelector:
@selector(intValue)])
1212 result = [object intValue];
1214 return defaultValue;
1216 return fmax(result, 0.0f);
1223 if ([
object respondsToSelector:
@selector(doubleValue)])
1224 result = [object doubleValue];
1225 else if ([
object respondsToSelector:
@selector(floatValue)])
1226 result = [object floatValue];
1227 else if ([
object respondsToSelector:
@selector(intValue)])
1228 result = [object intValue];
1230 return defaultValue;
1232 return fmax(result, 0.0);
1235#ifndef OOCOLLECTIONEXTRACTORS_SIMPLE
1238 Vector result = defaultValue;
1239 NSDictionary* dict =
nil;
1241 if ([
object isKindOfClass:[OONativeVector
class]]) {
1242 result = [object getVector];
1243 }
else if ([
object isKindOfClass:[NSString
class]]) {
1246 }
else if ([
object isKindOfClass:[NSArray
class]] && [
object count] == 3) {
1247 result.
x = [object oo_floatAtIndex:0];
1248 result.
y = [object oo_floatAtIndex:1];
1249 result.
z = [object oo_floatAtIndex:2];
1250 }
else if ([
object isKindOfClass:[NSDictionary
class]]) {
1253 if ([dict objectForKey:
@"x"] !=
nil ||
1254 [dict objectForKey:
@"y"] !=
nil ||
1255 [dict objectForKey:
@"z"] !=
nil) {
1257 result.
x = [dict oo_floatForKey:@"x" defaultValue:0.0f];
1258 result.
y = [dict oo_floatForKey:@"y" defaultValue:0.0f];
1259 result.
z = [dict oo_floatForKey:@"z" defaultValue:0.0f];
1269 NSDictionary* dict =
nil;
1271 if ([
object isKindOfClass:[NSString
class]]) {
1274 }
else if ([
object isKindOfClass:[NSArray
class]] && [
object count] == 3) {
1275 result.
x = [object oo_doubleAtIndex:0];
1276 result.
y = [object oo_doubleAtIndex:1];
1277 result.
z = [object oo_doubleAtIndex:2];
1278 }
else if ([
object isKindOfClass:[NSDictionary
class]]) {
1281 if ([dict objectForKey:
@"x"] !=
nil ||
1282 [dict objectForKey:
@"y"] !=
nil ||
1283 [dict objectForKey:
@"z"] !=
nil) {
1285 result.
x = [dict oo_doubleForKey:@"x" defaultValue:0.0];
1286 result.
y = [dict oo_doubleForKey:@"y" defaultValue:0.0];
1287 result.
z = [dict oo_doubleForKey:@"z" defaultValue:0.0];
1297 NSDictionary* dict =
nil;
1299 if ([
object isKindOfClass:[NSString
class]]) {
1302 }
else if ([
object isKindOfClass:[NSArray
class]] && [
object count] == 4) {
1303 result.
w = [object oo_floatAtIndex:0];
1304 result.
x = [object oo_floatAtIndex:1];
1305 result.
y = [object oo_floatAtIndex:2];
1306 result.
z = [object oo_floatAtIndex:3];
1307 }
else if ([
object isKindOfClass:[NSDictionary
class]]) {
1310 if ([dict objectForKey:
@"w"] !=
nil ||
1311 [dict objectForKey:
@"x"] !=
nil ||
1312 [dict objectForKey:
@"y"] !=
nil ||
1313 [dict objectForKey:
@"z"] !=
nil) {
1315 result.
w = [dict oo_floatForKey:@"w" defaultValue:0.0f];
1316 result.
x = [dict oo_floatForKey:@"x" defaultValue:0.0f];
1317 result.
y = [dict oo_floatForKey:@"y" defaultValue:0.0f];
1318 result.
z = [dict oo_floatForKey:@"z" defaultValue:0.0f];
1327 return [NSDictionary dictionaryWithObjectsAndKeys:
1328 [NSNumber numberWithFloat:value.x], @"x",
1329 [NSNumber numberWithFloat:value.y], @"y",
1330 [NSNumber numberWithFloat:value.z], @"z",
1336 return [NSDictionary dictionaryWithObjectsAndKeys:
1337 [NSNumber numberWithDouble:value.x], @"x",
1338 [NSNumber numberWithDouble:value.y], @"y",
1339 [NSNumber numberWithDouble:value.z], @"z",
1345 return [NSDictionary dictionaryWithObjectsAndKeys:
1346 [NSNumber numberWithFloat:value.w], @"w",
1347 [NSNumber numberWithFloat:value.x], @"x",
1348 [NSNumber numberWithFloat:value.y], @"y",
1349 [NSNumber numberWithFloat:value.z], @"z",
1356 if ([
object isKindOfClass:[NSArray
class]])
1357 return [NSSet setWithArray:object];
1358 else if ([
object isKindOfClass:[NSSet
class]])
1359 return [[object copy] autorelease];
1361 return defaultValue;
1366 if ([
object isKindOfClass:[NSString
class]])
1368 else if ([
object respondsToSelector:
@selector(stringValue)])
1369 return [object stringValue];
1371 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