ftp.nice.ch/pub/next/developer/languages/c/gcc.2.7.2.2.I.b.tar.gz#/lib/gcc-lib/i386-next-nextstep3/2.7.2.2.f.2/include/foundation/NSArchiver.h

This is NSArchiver.h in view mode; [Download] [Up]

/*      NSArchiver.h
	Serializing objects
	Copyright 1994, NeXT Computer Inc.
*/

#import <foundation/NSCoder.h>
#import <foundation/NSData.h>
#import <foundation/NSDictionary.h>
#import <objc/hashtable.h>

/************		Archiving: Writing	****************/

@interface NSArchiver:NSCoder {
    @private
    NSMutableData	*mdata;
    void		*pointerTable; /* pointer -> num*/
    void		*stringTable; /* string -> num*/
    BOOL		noteConditionals; /* when YES, a no-write pass */
    NXHashTable		*ids;	/* Set of all visited IDs */
}

- initForWritingWithMutableData:(NSMutableData *)mdata;
    /* mdata is retained */
    
- (NSMutableData *)archiverData;

- (void)encodeRootObject:rootObject;
    /* Specifies that a data structure might contain backpointers, and writes it as with -encodeObject:.  This method cannot be called recursively.  The implementation works in 2 passes, which implies that write: methods will be performed twice. */

- (void)encodeConditionalObject:object;
    /* Indicates that object is a back pointer, and writes it as with -encodeObject: or writes nil depending on whether object is written by an unconditional -encodeObject: otherwise.  Implies a previous call to -encodeRootObject:. */

- (void)encodeArrayOfObjCType:(const char *)type count:(unsigned)count at:(const void *)array;

+ (NSData *)archivedDataWithRootObject:rootObject;

+ (BOOL)archiveRootObject:rootObject toFile:(NSString *)path;
    /* returns whether successful */

+ (NSString *)classNameEncodedForTrueClassName:(NSString *)trueName;
    /* Returns the name used to archive instances of class trueName */

@end

/************		Archiving: Reading		****************/

@interface NSUnarchiver:NSCoder {
    @private
    id			data;
    unsigned		cursor;
    NSZone		*objectZone;
    unsigned		systemVersion;
    signed char		streamerVersion;
    void		*pointerTable; /* num -> pointer (offset to avoid -1)*/
    void		*stringTable; /* num -> string (offset to avoid -1)*/
    void		*classVersions;	/* className -> version */
    int			lastLabel;
}

- initForReadingWithData:(NSData *)data;

- (void)setObjectZone:(NSZone *)zone;
    /* zone may be NULL */

- (NSZone *)objectZone;

- (BOOL)isAtEnd;
    /* indicates whether or not more data follows. */

- (unsigned)systemVersion;
    /* Returns the version used for writing the stream.
    A version less than 1000 means a pre-OpenStep archive */

- (void)decodeArrayOfObjCType:(const char *)itemType count:(unsigned)count at:(void *)array;
    /* Expects array to be a previously allocated array of count elements of type itemType. */
    /* objects in array are NOT autoreleased: caller must release */

+ unarchiveObjectWithData:(NSData *)data;
    /* object is autoreleased */

+ unarchiveObjectWithFile:(NSString *)path;
    /* Returns nil if file not readable */
    /* object is autoreleased */

+ (void)decodeClassName:(NSString *)inArchiveName asClassName:(NSString *)trueName;
    /* Enables to change archive names into better names on read;
    Example:
    	[NSUnarchiver decodeClassName:@"View" asClassName:@"NSView"]; */

+ (NSString *)classNameDecodedForArchiveClassName:(NSString *)inArchiveName;
    /* Returns the true classname of objects archived as inArchiveName */

@end

/************		Object call back		****************/

@interface NSObject (NSArchiver)

- (Class)classForArchiver;
    /* Allows substitution of the class used in archiving,
    thus providing very specialized behavior for this style of coding
    and general behavior for others.
    default is to call -classForCoder. */
    
- replacementObjectForArchiver:(NSArchiver *)archiver;
    /* Allows argument to propose a substitute when encoding;
    nil means no to encode nothing;
    default is to call -replacementObjectForCoder: */ 

@end

/********	Compatibility with NEXTSTEP 3.0 archiving	**********/

#import <objc/Object.h>

extern void NXWriteNSObject(NXTypedStream *typedStream, NSObject *object);
    /* Writes object onto the typedStream; no sharing is possible across separate NXWriteNSObject */
    
extern NSObject *NXReadNSObject(NXTypedStream *typedStream);
    /* Reads an object written with NXWriteNSObject; returned object is autoreleased */

@interface NSCoder (NSTypedstreamCompatibility)

- (void)encodeNXObject:(Object *)object;
    /* Writes old-style object onto the coder; no shraing is possible across separate -encodeNXObject */
    
- (Object *)decodeNXObject;
    /* recovers object written with -encodeNXObject */
    
@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.