Oolite
Loading...
Searching...
No Matches
OOSystemDescriptionEntry(OOPrivate) Category Reference

Instance Methods

(id) - validateProperty:withValue:

Detailed Description

Definition at line 530 of file OOSystemDescriptionManager.m.

Method Documentation

◆ validateProperty:withValue:

- (id) validateProperty: (NSString *) property
withValue: (id) value 

Extends class OOSystemDescriptionEntry.

Definition at line 580 of file OOSystemDescriptionManager.m.

580 :(NSString*)property withValue:(id)value
581{
582 if ([property isEqualToString:@"coordinates"]) {
583 // must be a string with two numbers in it
584 // TODO: convert two element arrays
585 if (![value isKindOfClass:[NSString class]]) {
586 OOLog(@"system.description.error", @"'%@' is not a valid format for coordinates", value);
587 return nil;
588 }
589 NSArray* tokens = ScanTokensFromString((NSString*)value);
590 if ([tokens count] != 2) {
591 OOLog(@"system.description.error", @"'%@' is not a valid format for coordinates (must have exactly two numbers)", value);
592 return nil;
593 }
594 } else if ([property isEqualToString:@"radius"] || [property isEqualToString:@"government"]) {
595 // read in a context which expects a string, but it's a string representation of a number
596 if (![value isKindOfClass:[NSString class]]) {
597 if ([value isKindOfClass:[NSNumber class]]) {
598 return [value stringValue];
599 } else {
600 OOLog(@"system.description.error", @"'%@' is not a valid value for '%@' (string required)", value, property);
601 return nil;
602 }
603 }
604 } else if ([property isEqualToString:@"inhabitant"] || [property isEqualToString:@"inhabitants"] || [property isEqualToString:@"name"]) {
605 // read in a context which expects a string
606 if (![value isKindOfClass:[NSString class]]) {
607 OOLog(@"system.description.error", @"'%@' is not a valid value for '%@' (string required)", value, property);
608 return nil;
609 }
610 }
611
612 return value;
613}
#define OOLog(class, format,...)
Definition OOLogging.h:84
unsigned count
return nil
NSMutableArray * ScanTokensFromString(NSString *values)

References count, nil, OOLog, and ScanTokensFromString().

Referenced by OOSystemDescriptionEntry::setProperty:forLayer:toValue:.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following file: