/* Some preliminary ideas about what a String class might look like. Copyright (C) 1993,1994 Free Software Foundation, Inc. Written by: R. Andrew McCallum Date: May 1993 This file is part of the GNU Objective C Class Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __String_h_OBJECTS_INCLUDE #define __String_h_OBJECTS_INCLUDE /* xxx These method names need to be fixed because we will get type conflicts with GNUSTEP. Perhaps I'll just get rid of the GNU String objects and just transfer this functionality into NSSTring and friends. */ #include #include #include #include #include typedef unsigned short Character; @class String; @class ConstantString; @class MutableString; /* Like in SmallTalk, the String class is a subclass of Collection---a collection of characters. So, all the collection methods are available. Nice. */ /* Think about changing these names to avoid conflicts with OpenStep? */ @protocol String // INITIALIZING NEWLY ALLOCATED STRINGS. DON'T FORGET TO RELEASE THEM!; - init; - initWithString: (id )aString; - initWithString: (id )aString range: (IndexRange)aRange; - initWithFormat: (id )aFormatString, ...; - initWithFormat: (id )aFormatString arguments: (va_list)arg; - initWithCString: (const char*)aCharPtr; - initWithCString: (const char*)aCharPtr range: (IndexRange)aRange; //- initWithStream: (Stream*)aStream; //- initWithStream: (Stream*)aStream length: (unsigned)aLength; // GETTING NEW, AUTORELEASED STRING OBJECTS, NO NEED TO RELEASE THESE; + stringWithString: (id )aString; + stringWithString: (id )aString range: (IndexRange)aRange; + stringWithFormat: (id )aFormatString, ...; + stringWithFormat: (id )aFormatString arguments: (va_list)arg; + stringWithCString: (const char*)aCharPtr; + stringWithCString: (const char*)aCharPtr range: (IndexRange)aRange; - stringByAppendingFormat: (id )aString, ...; - stringByAppendingFormat: (id )aString arguments: (va_list)arg; - stringByPrependingFormat: (id )aString, ...; - stringByPrependingFormat: (id )aString arguments: (va_list)arg; - stringByAppendingString: (id )aString; - stringByPrependingString: (id )aString; //- substringWithRange: (IndexRange)aRange; //- substringWithLength: (unsigned)l; //- substringAfterIndex: (unsigned)i; //- (id ) substringsSeparatedByString: (id )sep; //- capitalizedString; //- lowercaseString; //- uppercaseString; - mutableCopy; - copy; // QUERYING - (unsigned) length; - (IndexRange) range; - (BOOL) isEqual: anObject; - (unsigned) hash; - (int) compare: anObject; - copy; - (unsigned) indexOfString: (id )aString; - (unsigned) indexOfChar: (char)aChar; - (unsigned) indexOfLastChar: (char)aChar; //- (unsigned) indexOfCharacter: (Character)aChar; //- (unsigned) indexOfLastCharacter: (Character)aChar; // GETTING C CHARS; - (char) charAtIndex: (unsigned)index; - (const char *) cString; - (unsigned) cStringLength; - (void) getCString: (char*)buffer; - (void) getCString: (char*)buffer range: (IndexRange)aRange; // FOR FILE NAMES (don't use the name "path", gnu will not use it for this); //- (IndexRange) fileRange; //- (IndexRange) directoriesRange; //- (IndexRange) extensionRange; //- (IndexRange) fileWithoutExtensionRange; //- (BOOL) isAbsolute; //- (BOOL) isRelative; @end @protocol MutableString + stringWithCapacity: (unsigned)capacity; - initWithCapacity: (unsigned)capacity; /* This from IndexedCollecting: - removeRange: (IndexRange)range; */ - (void) insertString: (id )string atIndex: (unsigned)index; - (void) setString: (id )string; - (void) appendString: (id )string; - (void) replaceRange: (IndexRange)range withString: (id )string; @end /* Abstract string classes */ @interface String : IndexedCollection @end /* To prevent complaints about protocol conformance. */ @interface String (StringProtocol) @end @interface MutableString : String @end /* To prevent complaints about protocol conformance. */ @interface MutableString (MutableStringProtocol) @end /* Some concrete string classes */ @interface CString : String { char * _contents_chars; int _count; } @end @interface MutableCString : MutableString { char *_contents_chars; int _count; int _capacity; } @end @interface ConstantString : CString @end #if 0 /* Moved to foundation/NSString.h */ /* The compiler makes @""-strings into NXConstantString's */ @interface NXConstantString : ConstantString @end #endif /* 0 */ #endif /* __String_h_OBJECTS_INCLUDE */