163
|
1 //
|
|
2 // String.h -- a generic class to simplify manipulation of (char *)'s
|
|
3 // Written by Don Yacktman (c) 1993 by Don Yacktman.
|
|
4 // Version 1.1. All rights reserved.
|
|
5 //
|
|
6 // You may use and copy this class freely as long as you
|
|
7 // comply with the following terms:
|
|
8 // (1) If you use this class in an application which you
|
|
9 // intend to sell commercially, as shareware, or otherwise,
|
|
10 // you may only do so with express written permission
|
|
11 // of the author. Use in applications which will
|
|
12 // be distributed free of charge is encouraged.
|
|
13 // (2) You must include the source code to this object and
|
|
14 // all accompanying documentation with your application,
|
|
15 // or provide it to users if requested, free of charge.
|
|
16 // (3) Do not remove the author's name or any of the
|
|
17 // copyright notices
|
|
18 //
|
|
19
|
|
20 #import <appkit/appkit.h>
|
|
21
|
|
22 @interface String:Object
|
|
23 {
|
|
24 char *buffer;
|
|
25 NXStringOrderTable *orderTable;
|
|
26 int length, _length;
|
|
27 }
|
|
28
|
|
29 // basic allocation, deallocation methods
|
|
30 - init;
|
|
31 - initString:(const char *)aString;
|
|
32 - allocateBuffer:(int)size;
|
|
33 - allocateBuffer:(int)size fromZone:(NXZone *)zone;
|
|
34 - read:(NXTypedStream *)stream;
|
|
35 - write:(NXTypedStream *)stream;
|
|
36 - freeString;
|
|
37 - free;
|
|
38
|
|
39 // strcpy(), strlen() covers
|
|
40 - copyFromZone:(NXZone *)zone; // a -copy message calls this.
|
|
41 - setString:(const char *)aString;
|
|
42 - setString:(const char *)aString fromZone:(NXZone *)zone;
|
|
43 - setStringValue:sender;
|
|
44 - setStringValue:sender fromZone:(NXZone *)zone;
|
|
45 - (const char *)stringValue;
|
|
46 - (int)length;
|
|
47
|
|
48 // strcat(), strncat() covers
|
|
49 - concatenate:sender;
|
|
50 - concatenate:sender n:(int)n;
|
|
51 - concatenate:sender fromZone:(NXZone *)zone;
|
|
52 - concatenate:sender n:(int)n fromZone:(NXZone *)zone;
|
|
53 - cat:(const char *)aString;
|
|
54 - cat:(const char *)aString n:(int)n;
|
|
55 - cat:(const char *)aString fromZone:(NXZone *)zone;
|
|
56 - cat:(const char *)aString n:(int)n fromZone:(NXZone *)zone;
|
|
57
|
|
58 // index(), rindex() covers
|
|
59 - (const char *)rindex:(char)aChar;
|
|
60 - (const char *)index:(char)aChar;
|
|
61
|
|
62 // strcmp(), strncmp(), strcasecmp(), strncasecmp() covers
|
|
63 - setStringOrderTable:(NXStringOrderTable *)table;
|
|
64 - (NXStringOrderTable *)stringOrderTable;
|
|
65 - (BOOL)isEqual:anObject;
|
|
66 - (int)compareTo:sender;
|
|
67 - (int)compareTo:sender n:(int)n;
|
|
68 - (int)compareTo:sender caseSensitive:(BOOL)sense;
|
|
69 - (int)compareTo:sender n:(int)n caseSensitive:(BOOL)sense;
|
|
70 - (int)cmp:(const char *)aString;
|
|
71 - (int)cmp:(const char *)aString n:(int)n;
|
|
72 - (int)casecmp:(const char *)aString;
|
|
73 - (int)casecmp:(const char *)aString n:(int)n;
|
|
74 - (const char *)strstr:(const char *)subString;
|
|
75
|
|
76 // like BASIC's left$(), right$(), and mid$(); all return a new instance.
|
|
77 - left:(int)count;
|
|
78 - right:(int)count;
|
|
79 - midFrom:(int)start to:(int)end;
|
|
80 - midFrom:(int)start length:(int)len;
|
|
81 - left:(int)count fromZone:(NXZone *)zone;
|
|
82 - right:(int)count fromZone:(NXZone *)zone;
|
|
83 - midFrom:(int)start to:(int)end fromZone:(NXZone *)zone;
|
|
84 - midFrom:(int)start length:(int)len fromZone:(NXZone *)zone;
|
|
85 - subStringRight:subString;
|
|
86 - subStringLeft:subString;
|
|
87
|
|
88 // private methods: do not use these!
|
|
89 - _unhookBuffer;
|
|
90
|
|
91
|
|
92 @end
|