Use (id <String>) instead of (String*)

Have String protocol include NSString protcol.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@240 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1995-04-03 03:22:10 +00:00
parent 5c19b6d637
commit fbf9b77c20
2 changed files with 84 additions and 66 deletions

View file

@ -29,9 +29,10 @@
Perhaps I'll just get rid of the GNU String objects and just Perhaps I'll just get rid of the GNU String objects and just
transfer this functionality into NSSTring and friends. */ transfer this functionality into NSSTring and friends. */
#include <objects/objc-gnu2next.h> #include <objects/stdobjects.h>
#include <objects/IndexedCollection.h> #include <objects/IndexedCollection.h>
#include <objects/ValueHolding.h> #include <objects/ValueHolding.h>
#include <foundation/NSString.h>
#include <stdarg.h> #include <stdarg.h>
typedef unsigned short Character; typedef unsigned short Character;
@ -46,42 +47,42 @@ typedef unsigned short Character;
/* Think about changing these names to avoid conflicts with OpenStep? */ /* Think about changing these names to avoid conflicts with OpenStep? */
@protocol String <ValueGetting> @protocol String <ValueGetting, NSString>
// INITIALIZING NEWLY ALLOCATED STRINGS. DON'T FORGET TO RELEASE THEM!; // INITIALIZING NEWLY ALLOCATED STRINGS. DON'T FORGET TO RELEASE THEM!;
- init; - init;
- initWithString: (String*)aString; - initWithString: (id <String>)aString;
- initWithString: (String*)aString range: (IndexRange)aRange; - initWithString: (id <String>)aString range: (IndexRange)aRange;
- initWithFormat: (String*)aFormatString, ...; - initWithFormat: (id <String>)aFormatString, ...;
- initWithFormat: (String*)aFormatString arguments: (va_list)arg; - initWithFormat: (id <String>)aFormatString arguments: (va_list)arg;
- initWithCString: (const char*)aCharPtr; - initWithCString: (const char*)aCharPtr;
- initWithCString: (const char*)aCharPtr range: (IndexRange)aRange; - initWithCString: (const char*)aCharPtr range: (IndexRange)aRange;
//- initWithStream: (Stream*)aStream; //- initWithStream: (Stream*)aStream;
//- initWithStream: (Stream*)aStream length: (unsigned)aLength; //- initWithStream: (Stream*)aStream length: (unsigned)aLength;
// GETTING NEW, AUTORELEASED STRING OBJECTS, NO NEED TO RELEASE THESE; // GETTING NEW, AUTORELEASED STRING OBJECTS, NO NEED TO RELEASE THESE;
+ (String*) stringWithString: (String*)aString; + stringWithString: (id <String>)aString;
+ (String*) stringWithString: (String*)aString range: (IndexRange)aRange; + stringWithString: (id <String>)aString range: (IndexRange)aRange;
+ (String*) stringWithFormat: (String*)aFormatString, ...; + stringWithFormat: (id <String>)aFormatString, ...;
+ (String*) stringWithFormat: (String*)aFormatString arguments: (va_list)arg; + stringWithFormat: (id <String>)aFormatString arguments: (va_list)arg;
+ (String*) stringWithCString: (const char*)aCharPtr; + stringWithCString: (const char*)aCharPtr;
+ (String*) stringWithCString: (const char*)aCharPtr range: (IndexRange)aRange; + stringWithCString: (const char*)aCharPtr range: (IndexRange)aRange;
- (String*) stringByAppendingFormat: (String*)aString, ...; - stringByAppendingFormat: (id <String>)aString, ...;
- (String*) stringByAppendingFormat: (String*)aString arguments: (va_list)arg; - stringByAppendingFormat: (id <String>)aString arguments: (va_list)arg;
- (String*) stringByPrependingFormat: (String*)aString, ...; - stringByPrependingFormat: (id <String>)aString, ...;
- (String*) stringByPrependingFormat: (String*)aString arguments: (va_list)arg; - stringByPrependingFormat: (id <String>)aString arguments: (va_list)arg;
- (String*) stringByAppendingString: (String*)aString; - stringByAppendingString: (id <String>)aString;
- (String*) stringByPrependingString: (String*)aString; - stringByPrependingString: (id <String>)aString;
//- (String*) substringWithRange: (IndexRange)aRange; //- substringWithRange: (IndexRange)aRange;
//- (String*) substringWithLength: (unsigned)l; //- substringWithLength: (unsigned)l;
//- (String*) substringAfterIndex: (unsigned)i; //- substringAfterIndex: (unsigned)i;
//- (id <IndexedCollecting>) substringsSeparatedByString: (String*)separator; //- (id <IndexedCollecting>) substringsSeparatedByString: (id <String>)sep;
//- (String*) capitalizedString; //- capitalizedString;
//- (String*) lowercaseString; //- lowercaseString;
//- (String*) uppercaseString; //- uppercaseString;
- mutableCopy; - mutableCopy;
- copy; - copy;
@ -93,7 +94,7 @@ typedef unsigned short Character;
- (unsigned) hash; - (unsigned) hash;
- (int) compare: anObject; - (int) compare: anObject;
- copy; - copy;
- (unsigned) indexOfString: (String*)aString; - (unsigned) indexOfString: (id <String>)aString;
- (unsigned) indexOfChar: (char)aChar; - (unsigned) indexOfChar: (char)aChar;
- (unsigned) indexOfLastChar: (char)aChar; - (unsigned) indexOfLastChar: (char)aChar;
//- (unsigned) indexOfCharacter: (Character)aChar; //- (unsigned) indexOfCharacter: (Character)aChar;
@ -118,24 +119,32 @@ typedef unsigned short Character;
@protocol MutableString <ValueSetting> @protocol MutableString <ValueSetting>
+ (MutableString*) stringWithCapacity: (unsigned)capacity; + stringWithCapacity: (unsigned)capacity;
- initWithCapacity: (unsigned)capacity; - initWithCapacity: (unsigned)capacity;
/* This from IndexedCollecting: - removeRange: (IndexRange)range; */ /* This from IndexedCollecting: - removeRange: (IndexRange)range; */
- (void) insertString: (String*)string atIndex: (unsigned)index; - (void) insertString: (id <String>)string atIndex: (unsigned)index;
- (void) setString: (String*)string; - (void) setString: (id <String>)string;
- (void) appendString: (String*)string; - (void) appendString: (id <String>)string;
- (void) replaceRange: (IndexRange)range withString: (String*)string; - (void) replaceRange: (IndexRange)range withString: (id <String>)string;
@end @end
/* Abstract string classes */ /* Abstract string classes */
@interface String : IndexedCollection <String> @interface String : IndexedCollection
@end @end
@interface MutableString : String <MutableString> /* 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>
@end @end
/* Some concrete string classes */ /* Some concrete string classes */

View file

@ -29,9 +29,10 @@
Perhaps I'll just get rid of the GNU String objects and just Perhaps I'll just get rid of the GNU String objects and just
transfer this functionality into NSSTring and friends. */ transfer this functionality into NSSTring and friends. */
#include <objects/objc-gnu2next.h> #include <objects/stdobjects.h>
#include <objects/IndexedCollection.h> #include <objects/IndexedCollection.h>
#include <objects/ValueHolding.h> #include <objects/ValueHolding.h>
#include <foundation/NSString.h>
#include <stdarg.h> #include <stdarg.h>
typedef unsigned short Character; typedef unsigned short Character;
@ -46,42 +47,42 @@ typedef unsigned short Character;
/* Think about changing these names to avoid conflicts with OpenStep? */ /* Think about changing these names to avoid conflicts with OpenStep? */
@protocol String <ValueGetting> @protocol String <ValueGetting, NSString>
// INITIALIZING NEWLY ALLOCATED STRINGS. DON'T FORGET TO RELEASE THEM!; // INITIALIZING NEWLY ALLOCATED STRINGS. DON'T FORGET TO RELEASE THEM!;
- init; - init;
- initWithString: (String*)aString; - initWithString: (id <String>)aString;
- initWithString: (String*)aString range: (IndexRange)aRange; - initWithString: (id <String>)aString range: (IndexRange)aRange;
- initWithFormat: (String*)aFormatString, ...; - initWithFormat: (id <String>)aFormatString, ...;
- initWithFormat: (String*)aFormatString arguments: (va_list)arg; - initWithFormat: (id <String>)aFormatString arguments: (va_list)arg;
- initWithCString: (const char*)aCharPtr; - initWithCString: (const char*)aCharPtr;
- initWithCString: (const char*)aCharPtr range: (IndexRange)aRange; - initWithCString: (const char*)aCharPtr range: (IndexRange)aRange;
//- initWithStream: (Stream*)aStream; //- initWithStream: (Stream*)aStream;
//- initWithStream: (Stream*)aStream length: (unsigned)aLength; //- initWithStream: (Stream*)aStream length: (unsigned)aLength;
// GETTING NEW, AUTORELEASED STRING OBJECTS, NO NEED TO RELEASE THESE; // GETTING NEW, AUTORELEASED STRING OBJECTS, NO NEED TO RELEASE THESE;
+ (String*) stringWithString: (String*)aString; + stringWithString: (id <String>)aString;
+ (String*) stringWithString: (String*)aString range: (IndexRange)aRange; + stringWithString: (id <String>)aString range: (IndexRange)aRange;
+ (String*) stringWithFormat: (String*)aFormatString, ...; + stringWithFormat: (id <String>)aFormatString, ...;
+ (String*) stringWithFormat: (String*)aFormatString arguments: (va_list)arg; + stringWithFormat: (id <String>)aFormatString arguments: (va_list)arg;
+ (String*) stringWithCString: (const char*)aCharPtr; + stringWithCString: (const char*)aCharPtr;
+ (String*) stringWithCString: (const char*)aCharPtr range: (IndexRange)aRange; + stringWithCString: (const char*)aCharPtr range: (IndexRange)aRange;
- (String*) stringByAppendingFormat: (String*)aString, ...; - stringByAppendingFormat: (id <String>)aString, ...;
- (String*) stringByAppendingFormat: (String*)aString arguments: (va_list)arg; - stringByAppendingFormat: (id <String>)aString arguments: (va_list)arg;
- (String*) stringByPrependingFormat: (String*)aString, ...; - stringByPrependingFormat: (id <String>)aString, ...;
- (String*) stringByPrependingFormat: (String*)aString arguments: (va_list)arg; - stringByPrependingFormat: (id <String>)aString arguments: (va_list)arg;
- (String*) stringByAppendingString: (String*)aString; - stringByAppendingString: (id <String>)aString;
- (String*) stringByPrependingString: (String*)aString; - stringByPrependingString: (id <String>)aString;
//- (String*) substringWithRange: (IndexRange)aRange; //- substringWithRange: (IndexRange)aRange;
//- (String*) substringWithLength: (unsigned)l; //- substringWithLength: (unsigned)l;
//- (String*) substringAfterIndex: (unsigned)i; //- substringAfterIndex: (unsigned)i;
//- (id <IndexedCollecting>) substringsSeparatedByString: (String*)separator; //- (id <IndexedCollecting>) substringsSeparatedByString: (id <String>)sep;
//- (String*) capitalizedString; //- capitalizedString;
//- (String*) lowercaseString; //- lowercaseString;
//- (String*) uppercaseString; //- uppercaseString;
- mutableCopy; - mutableCopy;
- copy; - copy;
@ -93,7 +94,7 @@ typedef unsigned short Character;
- (unsigned) hash; - (unsigned) hash;
- (int) compare: anObject; - (int) compare: anObject;
- copy; - copy;
- (unsigned) indexOfString: (String*)aString; - (unsigned) indexOfString: (id <String>)aString;
- (unsigned) indexOfChar: (char)aChar; - (unsigned) indexOfChar: (char)aChar;
- (unsigned) indexOfLastChar: (char)aChar; - (unsigned) indexOfLastChar: (char)aChar;
//- (unsigned) indexOfCharacter: (Character)aChar; //- (unsigned) indexOfCharacter: (Character)aChar;
@ -118,24 +119,32 @@ typedef unsigned short Character;
@protocol MutableString <ValueSetting> @protocol MutableString <ValueSetting>
+ (MutableString*) stringWithCapacity: (unsigned)capacity; + stringWithCapacity: (unsigned)capacity;
- initWithCapacity: (unsigned)capacity; - initWithCapacity: (unsigned)capacity;
/* This from IndexedCollecting: - removeRange: (IndexRange)range; */ /* This from IndexedCollecting: - removeRange: (IndexRange)range; */
- (void) insertString: (String*)string atIndex: (unsigned)index; - (void) insertString: (id <String>)string atIndex: (unsigned)index;
- (void) setString: (String*)string; - (void) setString: (id <String>)string;
- (void) appendString: (String*)string; - (void) appendString: (id <String>)string;
- (void) replaceRange: (IndexRange)range withString: (String*)string; - (void) replaceRange: (IndexRange)range withString: (id <String>)string;
@end @end
/* Abstract string classes */ /* Abstract string classes */
@interface String : IndexedCollection <String> @interface String : IndexedCollection
@end @end
@interface MutableString : String <MutableString> /* 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>
@end @end
/* Some concrete string classes */ /* Some concrete string classes */