constant strings
parent
3b3a3061d9
commit
46cc4dd583
@ -1,27 +1,29 @@
|
|||||||
#ifndef YSSTRING_H
|
#ifndef YSSTRING_H
|
||||||
#define YSSTRING_H
|
#define YSSTRING_H
|
||||||
|
|
||||||
#import <YSObject.h>
|
#import "YSObject.h"
|
||||||
#import <YSRange.h>
|
|
||||||
|
@interface YSConstantString : YSObject {
|
||||||
#include <stdio.h>
|
char *c_string;
|
||||||
|
unsigned int len;
|
||||||
@implementation YSString : YSObject <YSCopying, YSMutableCopying>
|
}
|
||||||
+(instancetype) string;
|
|
||||||
+(instancetype) stringWithCharacters: (const unichar*) chars
|
-(const char *) cString;
|
||||||
length: (YSUInteger) length;
|
-(unsigned int) length;
|
||||||
+(instancetype) stringWithCString: (const char *) byteString
|
-(void) dealloc;
|
||||||
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;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
/*
|
||||||
|
@interface YSString : YSObject {
|
||||||
|
char *c_string;
|
||||||
|
unsigned int len;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(char *) cString;
|
||||||
|
-(unsigned int length);
|
||||||
|
|
||||||
|
@end
|
||||||
|
*/
|
||||||
|
|
||||||
#endif
|
#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