Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOSystemDescriptionEntry(OOPrivate) Category Reference

Instance Methods

(id) - validateProperty:withValue:
 

Detailed Description

Definition at line 635 of file OOSystemDescriptionManager.m.

Method Documentation

◆ validateProperty:withValue:

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

Extends class OOSystemDescriptionEntry.

Definition at line 58 of file OOSystemDescriptionManager.m.

696 :(NSString *)property withValue:(id)value
697{
698 if ([property isEqualToString:@"coordinates"])
699 {
700 // must be a string with two numbers in it
701 // TODO: convert two element arrays
702 if (![value isKindOfClass:[NSString class]])
703 {
704 OOLog(@"system.description.error",@"'%@' is not a valid format for coordinates",value);
705 return nil;
706 }
707 NSArray *tokens = ScanTokensFromString((NSString *)value);
708 if ([tokens count] != 2)
709 {
710 OOLog(@"system.description.error",@"'%@' is not a valid format for coordinates (must have exactly two numbers)",value);
711 return nil;
712 }
713 }
714 else if ([property isEqualToString:@"radius"] || [property isEqualToString:@"government"])
715 {
716 // read in a context which expects a string, but it's a string representation of a number
717 if (![value isKindOfClass:[NSString class]])
718 {
719 if ([value isKindOfClass:[NSNumber class]])
720 {
721 return [value stringValue];
722 }
723 else
724 {
725 OOLog(@"system.description.error",@"'%@' is not a valid value for '%@' (string required)",value,property);
726 return nil;
727 }
728 }
729 }
730 else if ([property isEqualToString:@"inhabitant"] || [property isEqualToString:@"inhabitants"] || [property isEqualToString:@"name"] )
731 {
732 // read in a context which expects a string
733 if (![value isKindOfClass:[NSString class]])
734 {
735 OOLog(@"system.description.error",@"'%@' is not a valid value for '%@' (string required)",value,property);
736 return nil;
737 }
738 }
739
740 return value;
741}
#define OOLog(class, format,...)
Definition OOLogging.h:88
unsigned count
return nil
NSMutableArray * ScanTokensFromString(NSString *values)

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