constant strings
parent
3b3a3061d9
commit
46cc4dd583
@ -1,27 +1,29 @@
|
||||
#ifndef YSSTRING_H
|
||||
#define YSSTRING_H
|
||||
|
||||
#import <YSObject.h>
|
||||
#import <YSRange.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@implementation YSString : YSObject <YSCopying, YSMutableCopying>
|
||||
+(instancetype) string;
|
||||
+(instancetype) stringWithCharacters: (const unichar*) chars
|
||||
length: (YSUInteger) length;
|
||||
+(instancetype) stringWithCString: (const char *) byteString
|
||||
length: (YSUInteger) length;
|
||||
+(instancetype) stringWithCString: (const char *) byteString;
|
||||
//+(instancetype) stringWithFormat: (YSString *)format, ...
|
||||
+(instancetype) stringWithContentsOfFile: (YSString *) path;
|
||||
-(instancetype) init;
|
||||
-(YSUInteger) length;
|
||||
-(unichar) characterAtIndex: (YSUInteger) index;
|
||||
-(void) getCharacters: (unichar *) buffer;
|
||||
-(void) getCharacters: (unichar *) buffer
|
||||
range: (YSRange) aRange;
|
||||
#import "YSObject.h"
|
||||
|
||||
@interface YSConstantString : YSObject {
|
||||
char *c_string;
|
||||
unsigned int len;
|
||||
}
|
||||
|
||||
-(const char *) cString;
|
||||
-(unsigned int) length;
|
||||
-(void) dealloc;
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
@interface YSString : YSObject {
|
||||
char *c_string;
|
||||
unsigned int len;
|
||||
}
|
||||
|
||||
-(char *) cString;
|
||||
-(unsigned int length);
|
||||
|
||||
@end
|
||||
*/
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,18 @@
|
||||
#import "YSString.h"
|
||||
|
||||
@implementation YSConstantString
|
||||
-(const char *) cString {
|
||||
return (c_string);
|
||||
}
|
||||
|
||||
-(unsigned int) length {
|
||||
return len;
|
||||
}
|
||||
|
||||
//free(): invalid pointer
|
||||
-(void) dealloc {
|
||||
//[super dealloc];
|
||||
free(c_string);
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in New Issue