ADDED src/OFString+Cube.h Index: src/OFString+Cube.h ================================================================== --- /dev/null +++ src/OFString+Cube.h @@ -0,0 +1,8 @@ +#import + +@interface +OFString (Cube) +@property (readonly, nonatomic) int cube_intValue; + +- (int)cube_intValueWithBase:(unsigned char)base; +@end ADDED src/OFString+Cube.mm Index: src/OFString+Cube.mm ================================================================== --- /dev/null +++ src/OFString+Cube.mm @@ -0,0 +1,32 @@ +#import "OFString+Cube.h" + +#include "cube.h" + +@implementation +OFString (Cube) +- (int)cube_intValue +{ + @try { + return self.intValue; + } @catch (OFInvalidFormatException *e) { + conoutf(@"invalid value: %@", self); + return 0; + } @catch (OFOutOfRangeException *e) { + conoutf(@"invalid value: %@", self); + return 0; + } +} + +- (int)cube_intValueWithBase:(unsigned char)base +{ + @try { + return [self intValueWithBase:base]; + } @catch (OFInvalidFormatException *e) { + conoutf(@"invalid value: %@", self); + return 0; + } @catch (OFOutOfRangeException *e) { + conoutf(@"invalid value: %@", self); + return 0; + } +} +@end