00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 #if !defined(TEXT_OL_GUARD)
00044 #define TEXT_OL_GUARD
00045 
00046 #include <ObjectiveLib/ObjectBase.h>
00047 #if defined(OL_HAVE_INTTYPES_H)
00048 #include <inttypes.h>
00049 #else
00050 #include <stdint.h>
00051 #endif
00052 
00073 typedef uint16_t olchar;
00074 
00078 struct _OLTextReference;
00079 
00100 @interface OLText :
00101 #if defined(OL_NO_OPENSTEP)
00102     Object <OLStreamable>
00103 #else
00104     NSObject <OLStreamable, NSCopying, NSCoding>
00105 #endif
00106 {
00107 @protected
00111     struct _OLTextReference* reference;
00112 }
00113 
00118 #if defined(OL_NO_OPENSTEP)
00119 + (id) initialize;
00120 #else
00121 + (void) initialize;
00122 #endif
00123 
00140 + (id) textWithBytes: (const uint8_t*)bytes count: (unsigned)num encoding: (const char*)enc;
00141 
00152 + (id) textWithCString: (const char*)chs;
00153 
00154 #if !defined(OL_NO_OPENSTEP)
00155 
00162 + (id) textWithNSString: (NSString*)str;
00163 #endif
00164 
00174 + (id) textWithText: (OLText*)text;
00175 
00179 
00180 
00186 - (id) init;
00187 
00202 - (id) initWithBytes: (const uint8_t*)bytes count: (unsigned)num encoding: (const char*)enc;
00203 
00212 - (id) initWithChars: (const olchar*)chs count: (unsigned)num;
00213 
00214 #if !defined(OL_NO_OPENSTEP)
00215 
00224 - (id) initWithCoder: (NSCoder*)decoder;
00225 #endif
00226 
00227 #if defined(OL_NO_OPENSTEP)
00228 - (id) initWithConstantString: (OLConstantString*)str;
00229 #endif
00230 
00239 - (id) initWithCString: (const char*)chs;
00240 
00241 #if !defined(OL_NO_OPENSTEP)
00242 - (id) initWithNSString: (NSString*)str;
00243 #endif
00244 
00254 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00255 
00263 - (id) initWithText: (OLText*)text;
00264 
00278 - (id) initWithText: (OLText*)text offset: (unsigned)roff count: (unsigned)num;
00279 
00284 #if defined(OL_NO_OPENSTEP)
00285 - (id) free;
00286 #else
00287 - (void) dealloc;
00288 #endif
00289 
00290 
00300 - (olchar) at: (unsigned)index;
00301 
00317 - (uint8_t*) bytesWithEncoding: (const char*)enc returnedCount: (unsigned*)rc;
00318 
00328 - (int) compare: (id)other;
00329 
00330 #if defined(OL_NO_OPENSTEP)
00331 
00337 - (id) copy;
00338 #else
00339 
00347 - (id) copyWithZone: (NSZone*)zone;
00348 #endif
00349 
00357 - (const char*) cString;
00358 
00364 - (BOOL) empty;
00365 
00366 #if !defined(OL_NO_OPENSTEP)
00367 
00375 - (void) encodeWithCoder: (NSCoder*)encoder;
00376 #endif
00377 
00389 - (unsigned) findChar: (olchar)ch fromOffset: (unsigned)offset;
00390 
00403 - (unsigned) findFirstNotOf: (OLText*)text fromOffset: (unsigned)offset;
00404 
00417 - (unsigned) findFirstOf: (OLText*)text fromOffset: (unsigned)offset;
00418 
00433 - (unsigned) findLastNotOf: (OLText*)text fromOffset: (unsigned)offset;
00434 
00449 - (unsigned) findLastOf: (OLText*)text fromOffset: (unsigned)offset;
00450 
00463 - (unsigned) findText: (OLText*)text fromOffset: (unsigned)offset;
00464 
00475 - (void) getCharacters: (olchar*)buffer fromOffset: (unsigned)offset count: (unsigned)num;
00476 
00482 - (unsigned) hash;
00483 
00491 - (BOOL) isEqual: (id)object;
00492 
00498 - (unsigned) length;
00499 
00505 - (unsigned) maxSize;
00506 
00521 - (uint8_t*) nullTerminatedBytesWithEncoding: (const char*)enc;
00522 
00535 - (unsigned) rfindChar: (olchar)ch fromOffset: (unsigned)offset;
00536 
00542 - (unsigned) size;
00543 
00555 - (OLText*) substrFromOffset: (unsigned)offset count: (unsigned)num;
00556 
00557 #if !defined(OL_NO_OPENSTEP)
00558 
00564 - (NSString*) toNSString;
00565 #endif
00566 
00574 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00575 
00576 @end
00577 
00599 @interface OLTextBuffer :
00600 #if defined(OL_NO_OPENSTEP)
00601     Object
00602 #else
00603     NSObject <NSCopying>
00604 #endif
00605 {
00606 @protected
00610     olchar*     begin;
00611 
00615     unsigned    size;
00616 
00620     unsigned    capacity;
00621 }
00622 
00630 + (id) textBuffer;
00631 
00640 + (id) textBufferWithText: (OLText*)text;
00641 
00645 
00646 
00653 - (id) init;
00654 
00662 - (id) initWithCapacity: (unsigned)cap;
00663 
00670 - (id) initWithText: (OLText*)text;
00671 
00675 #if defined(OL_NO_OPENSTEP)
00676 - (id) free;
00677 #else
00678 - (void) dealloc;
00679 #endif
00680 
00681 
00688 - (OLTextBuffer*) appendChar: (olchar)ch;
00689 
00700 - (OLTextBuffer*) appendChars: (const olchar*)chars fromOffset: (unsigned)offset count: (unsigned)num;
00701 
00709 - (OLTextBuffer*) appendText: (OLText*)text;
00710 
00718 - (OLTextBuffer*) appendTextBuffer: (OLTextBuffer*)buffer;
00719 
00730 - (OLTextBuffer*) assignAt: (unsigned)index character: (olchar)ch;
00731 
00741 - (olchar) at: (unsigned)index;
00742 
00748 - (unsigned) capacity;
00749 
00753 - (void) clear;
00754 
00763 - (int) compare: (id)other;
00764 
00765 #if defined(OL_NO_OPENSTEP)
00766 
00771 - (id) copy;
00772 #else
00773 
00779 - (id) copyWithZone: (NSZone*)zone;
00780 #endif
00781 
00787 - (BOOL) empty;
00788 
00799 - (OLTextBuffer*) eraseAt: (unsigned)index;
00800 
00811 - (OLTextBuffer*) eraseFromOffset: (unsigned)offset count: (unsigned)num;
00812 
00824 - (unsigned) findChar: (olchar)ch fromOffset: (unsigned)offset;
00825 
00838 - (unsigned) findFirstNotOf: (OLText*)text fromOffset: (unsigned)offset;
00839 
00852 - (unsigned) findFirstOf: (OLText*)text fromOffset: (unsigned)offset;
00853 
00868 - (unsigned) findLastNotOf: (OLText*)text fromOffset: (unsigned)offset;
00869 
00884 - (unsigned) findLastOf: (OLText*)text fromOffset: (unsigned)offset;
00885 
00898 - (unsigned) findText: (OLText*)text fromOffset: (unsigned)offset;
00899 
00910 - (void) getCharacters: (olchar*)buffer fromOffset: (unsigned)offset count: (unsigned)num;
00911 
00923 - (OLTextBuffer*) insertChar: (olchar)ch atOffset: (unsigned)offset;
00924 
00936 - (OLTextBuffer*) insertChars: (const olchar*)chars atOffset: (unsigned)offset count: (unsigned)num;
00937 
00949 - (OLTextBuffer*) insertText: (OLText*)text atOffset: (unsigned)offset;
00950 
00958 - (BOOL) isEqual: (id)object;
00959 
00966 - (unsigned) length;
00967 
00980 - (OLTextBuffer*) replaceFromOffset: (unsigned)offset count: (unsigned)num withText: (OLText*)text;
00981 
00988 - (void) reserve: (unsigned)cap;
00989 
01001 - (OLTextBuffer*) resize: (unsigned)newLength filledWith: (olchar)ch;
01002 
01008 - (OLTextBuffer*) reverse;
01009 
01022 - (unsigned) rfindChar: (olchar)ch fromOffset: (unsigned)offset;
01023 
01030 - (unsigned) size;
01031 
01044 - (OLText*) substrFromOffset: (unsigned)offset count: (unsigned)num;
01045 
01054 - (OLText*) text;
01055 
01056 @end
01057 
01058 #if defined(OL_NO_OPENSTEP)
01059 
01071 @interface OLConstantString : Object
01072 {
01076     char*       c_string;
01077 
01081     unsigned    len;
01082 }
01083 
01084 #if defined(__NEXT_RUNTIME__)
01085 
01090 + (id) class;
01091 
01096 + (void) load;
01097 #endif
01098 
01102 - (id) free;
01103 
01104 #if defined(__NEXT_RUNTIME__)
01105 
01110 - (id) class;
01111 #endif
01112 
01122 - (int) compare: (id)other;
01123 
01129 - (id) copy;
01130 
01136 - (const char*) cString;
01137 
01143 - (unsigned) hash;
01144 
01152 - (BOOL) isEqual: (id)other;
01153 
01159 - (unsigned) length;
01160 
01161 @end
01162 
01163 #if defined(__NEXT_RUNTIME__)
01164 
01167 extern struct objc_class _OLConstantStringClassReference;
01168 #endif
01169 
01170 #endif
01171 
01172 #endif