1995-03-11 20:49:02 +00:00
|
|
|
/* Some preliminary ideas about what a String class might look like.
|
|
|
|
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
|
|
|
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
|
|
|
|
|
1995-03-23 03:43:52 +00:00
|
|
|
/* 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. */
|
|
|
|
|
1995-04-03 03:22:10 +00:00
|
|
|
#include <objects/stdobjects.h>
|
1995-03-11 20:49:02 +00:00
|
|
|
#include <objects/IndexedCollection.h>
|
|
|
|
#include <objects/ValueHolding.h>
|
1995-04-03 03:22:10 +00:00
|
|
|
#include <foundation/NSString.h>
|
1995-03-11 20:49:02 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
1995-03-23 03:43:52 +00:00
|
|
|
/* Think about changing these names to avoid conflicts with OpenStep? */
|
|
|
|
|
1995-04-03 03:22:10 +00:00
|
|
|
@protocol String <ValueGetting, NSString>
|
1995-03-11 20:49:02 +00:00
|
|
|
|
|
|
|
// INITIALIZING NEWLY ALLOCATED STRINGS. DON'T FORGET TO RELEASE THEM!;
|
|
|
|
- init;
|
1995-04-03 03:22:10 +00:00
|
|
|
- initWithString: (id <String>)aString;
|
|
|
|
- initWithString: (id <String>)aString range: (IndexRange)aRange;
|
|
|
|
- initWithFormat: (id <String>)aFormatString, ...;
|
|
|
|
- initWithFormat: (id <String>)aFormatString arguments: (va_list)arg;
|
1995-03-12 15:45:31 +00:00
|
|
|
- initWithCString: (const char*)aCharPtr;
|
1995-03-12 19:25:28 +00:00
|
|
|
- initWithCString: (const char*)aCharPtr range: (IndexRange)aRange;
|
|
|
|
//- initWithStream: (Stream*)aStream;
|
|
|
|
//- initWithStream: (Stream*)aStream length: (unsigned)aLength;
|
1995-03-11 20:49:02 +00:00
|
|
|
|
|
|
|
// GETTING NEW, AUTORELEASED STRING OBJECTS, NO NEED TO RELEASE THESE;
|
1995-04-03 03:22:10 +00:00
|
|
|
+ stringWithString: (id <String>)aString;
|
|
|
|
+ stringWithString: (id <String>)aString range: (IndexRange)aRange;
|
|
|
|
+ stringWithFormat: (id <String>)aFormatString, ...;
|
|
|
|
+ stringWithFormat: (id <String>)aFormatString arguments: (va_list)arg;
|
|
|
|
+ stringWithCString: (const char*)aCharPtr;
|
|
|
|
+ stringWithCString: (const char*)aCharPtr range: (IndexRange)aRange;
|
|
|
|
|
|
|
|
- stringByAppendingFormat: (id <String>)aString, ...;
|
|
|
|
- stringByAppendingFormat: (id <String>)aString arguments: (va_list)arg;
|
|
|
|
- stringByPrependingFormat: (id <String>)aString, ...;
|
|
|
|
- stringByPrependingFormat: (id <String>)aString arguments: (va_list)arg;
|
|
|
|
- stringByAppendingString: (id <String>)aString;
|
|
|
|
- stringByPrependingString: (id <String>)aString;
|
|
|
|
|
|
|
|
//- substringWithRange: (IndexRange)aRange;
|
|
|
|
//- substringWithLength: (unsigned)l;
|
|
|
|
//- substringAfterIndex: (unsigned)i;
|
|
|
|
//- (id <IndexedCollecting>) substringsSeparatedByString: (id <String>)sep;
|
|
|
|
|
|
|
|
//- capitalizedString;
|
|
|
|
//- lowercaseString;
|
|
|
|
//- uppercaseString;
|
1995-03-11 20:49:02 +00:00
|
|
|
|
1995-03-12 21:49:46 +00:00
|
|
|
- mutableCopy;
|
|
|
|
- copy;
|
|
|
|
|
1995-03-12 19:25:28 +00:00
|
|
|
// QUERYING
|
|
|
|
- (unsigned) length;
|
|
|
|
- (IndexRange) range;
|
1995-03-11 20:49:02 +00:00
|
|
|
- (BOOL) isEqual: anObject;
|
|
|
|
- (unsigned) hash;
|
|
|
|
- (int) compare: anObject;
|
|
|
|
- copy;
|
1995-04-03 03:22:10 +00:00
|
|
|
- (unsigned) indexOfString: (id <String>)aString;
|
1995-03-11 20:49:02 +00:00
|
|
|
- (unsigned) indexOfChar: (char)aChar;
|
|
|
|
- (unsigned) indexOfLastChar: (char)aChar;
|
1995-03-12 19:25:28 +00:00
|
|
|
//- (unsigned) indexOfCharacter: (Character)aChar;
|
|
|
|
//- (unsigned) indexOfLastCharacter: (Character)aChar;
|
1995-03-11 20:49:02 +00:00
|
|
|
|
1995-03-12 21:49:46 +00:00
|
|
|
// GETTING C CHARS;
|
|
|
|
- (char) charAtIndex: (unsigned)index;
|
|
|
|
- (const char *) cString;
|
|
|
|
- (unsigned) cStringLength;
|
|
|
|
- (void) getCString: (char*)buffer;
|
|
|
|
- (void) getCString: (char*)buffer range: (IndexRange)aRange;
|
|
|
|
|
1995-03-11 20:49:02 +00:00
|
|
|
// FOR FILE NAMES (don't use the name "path", gnu will not use it for this);
|
1995-03-12 19:25:28 +00:00
|
|
|
//- (IndexRange) fileRange;
|
|
|
|
//- (IndexRange) directoriesRange;
|
|
|
|
//- (IndexRange) extensionRange;
|
|
|
|
//- (IndexRange) fileWithoutExtensionRange;
|
|
|
|
//- (BOOL) isAbsolute;
|
|
|
|
//- (BOOL) isRelative;
|
1995-03-11 20:49:02 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
1995-03-12 22:24:45 +00:00
|
|
|
@protocol MutableString <ValueSetting>
|
1995-03-11 20:49:02 +00:00
|
|
|
|
1995-04-03 03:22:10 +00:00
|
|
|
+ stringWithCapacity: (unsigned)capacity;
|
1995-03-11 20:49:02 +00:00
|
|
|
- initWithCapacity: (unsigned)capacity;
|
|
|
|
|
1995-03-12 15:45:31 +00:00
|
|
|
/* This from IndexedCollecting: - removeRange: (IndexRange)range; */
|
1995-04-03 03:22:10 +00:00
|
|
|
- (void) insertString: (id <String>)string atIndex: (unsigned)index;
|
1995-03-11 20:49:02 +00:00
|
|
|
|
1995-04-03 03:22:10 +00:00
|
|
|
- (void) setString: (id <String>)string;
|
|
|
|
- (void) appendString: (id <String>)string;
|
|
|
|
- (void) replaceRange: (IndexRange)range withString: (id <String>)string;
|
1995-03-11 20:49:02 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
1995-03-12 15:45:31 +00:00
|
|
|
/* Abstract string classes */
|
|
|
|
|
1995-04-03 03:22:10 +00:00
|
|
|
@interface String : IndexedCollection
|
1995-03-11 20:49:02 +00:00
|
|
|
@end
|
|
|
|
|
1995-04-03 03:22:10 +00:00
|
|
|
/* To prevent complaints about protocol conformance. */
|
|
|
|
@interface String (StringProtocol) <String>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface MutableString : String
|
|
|
|
@end
|
|
|
|
|
|
|
|
/* To prevent complaints about protocol conformance. */
|
|
|
|
@interface MutableString (MutableStringProtocol) <MutableString>
|
1995-03-11 20:49:02 +00:00
|
|
|
@end
|
|
|
|
|
1995-03-12 15:45:31 +00:00
|
|
|
/* Some concrete string classes */
|
|
|
|
|
|
|
|
@interface CString : String
|
1995-03-11 20:49:02 +00:00
|
|
|
{
|
|
|
|
char * _contents_chars;
|
|
|
|
int _count;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
1995-03-12 15:45:31 +00:00
|
|
|
@interface MutableCString : MutableString
|
1995-03-11 20:49:02 +00:00
|
|
|
{
|
1995-03-12 22:24:45 +00:00
|
|
|
char *_contents_chars;
|
1995-03-12 15:45:31 +00:00
|
|
|
int _count;
|
1995-03-11 20:49:02 +00:00
|
|
|
int _capacity;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
1995-03-12 15:45:31 +00:00
|
|
|
@interface ConstantString : CString
|
1995-03-11 20:49:02 +00:00
|
|
|
@end
|
|
|
|
|
1995-04-03 00:05:02 +00:00
|
|
|
#if 0 /* Moved to foundation/NSString.h */
|
1995-03-12 15:45:31 +00:00
|
|
|
/* The compiler makes @""-strings into NXConstantString's */
|
1995-03-11 20:49:02 +00:00
|
|
|
@interface NXConstantString : ConstantString
|
|
|
|
@end
|
1995-04-03 00:05:02 +00:00
|
|
|
#endif /* 0 */
|
1995-03-11 20:49:02 +00:00
|
|
|
|
|
|
|
#endif /* __String_h_OBJECTS_INCLUDE */
|