Add files forgotten in last commit
FossilOrigin-Name: e208417f95180ec74e3c5376d6f502f3cdb0a356c6541458e8864a3fefa5cd80
This commit is contained in:
parent
38747afbb5
commit
4aed51a95d
2 changed files with 40 additions and 0 deletions
8
src/OFString+Cube.h
Normal file
8
src/OFString+Cube.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
@interface
|
||||||
|
OFString (Cube)
|
||||||
|
@property (readonly, nonatomic) int cube_intValue;
|
||||||
|
|
||||||
|
- (int)cube_intValueWithBase:(unsigned char)base;
|
||||||
|
@end
|
32
src/OFString+Cube.mm
Normal file
32
src/OFString+Cube.mm
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue