/usr/include/GNUstep/Foundation/NSKeyedArchiver.h is in libgnustep-base-dev 1.24.0-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | /** Interface for NSKeyedArchiver for GNUStep
Copyright (C) 2004 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
Date: January 2004
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser 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 Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
AutogsdocSource: NSKeyedArchiver.m
AutogsdocSource: NSKeyedUnarchiver.m
*/
#ifndef __NSKeyedArchiver_h_GNUSTEP_BASE_INCLUDE
#define __NSKeyedArchiver_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
#import <Foundation/NSCoder.h>
#import <Foundation/NSMapTable.h>
#import <Foundation/NSPropertyList.h>
@class NSMutableDictionary, NSMutableData, NSData, NSString;
/**
* Implements <em>keyed</em> archiving of object graphs. This archiver
* should be used instead of [NSArchiver] for new implementations. Classes
* implementing [(NSCoding)] should check the [NSCoder-allowsKeyedCoding]
* method and if the response is YES, encode/decode their fields using the
* <code>...forKey:</code> [NSCoder] methods, which provide for more robust
* forwards and backwards compatibility.
*/
@interface NSKeyedArchiver : NSCoder
{
#if GS_EXPOSE(NSKeyedArchiver)
@private
NSMutableData *_data; /* Data to write into. */
id _delegate; /* Delegate controls operation. */
NSMapTable *_clsMap; /* Map classes to names. */
#ifndef _IN_NSKEYEDARCHIVER_M
#define GSIMapTable void*
#endif
GSIMapTable _cIdMap; /* Conditionally coded. */
GSIMapTable _uIdMap; /* Unconditionally coded. */
GSIMapTable _repMap; /* Mappings for objects. */
#ifndef _IN_NSKEYEDARCHIVER_M
#undef GSIMapTable
#endif
unsigned _keyNum; /* Counter for keys in object. */
NSMutableDictionary *_enc; /* Object being encoded. */
NSMutableArray *_obj; /* Array of objects. */
NSPropertyListFormat _format;
#endif
#if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/
@private id _internal GS_UNUSED_IVAR;
#endif
}
/**
* Encodes anObject and returns the resulting data object.
*/
+ (NSData*) archivedDataWithRootObject: (id)anObject;
/**
* Encodes anObject and writes the resulting data ti aPath.
*/
+ (BOOL) archiveRootObject: (id)anObject toFile: (NSString*)aPath;
/**
* Returns the class name with which the NSKeyedArchiver class will encode
* instances of aClass, or nil if no name mapping has been set using the
* +setClassName:forClass: method.
*/
+ (NSString*) classNameForClass: (Class)aClass;
/**
* Sets the class name with which the NSKeyedArchiver class will encode
* instances of aClass. This mapping is used only if no class name
* mapping has been set for the individual instance of NSKeyedArchiver
* being used.<br />
* The value of aString must be the name of an existing class.<br />
* If the value of aString is nil, any mapping for aClass is removed.
*/
+ (void) setClassName: (NSString*)aString forClass: (Class)aClass;
/**
* Returns any mapping for the name of aClass which was previously set
* for the receiver using the -setClassName:forClass: method.<br />
* Returns nil if no such mapping exists, even if one has been set
* using the class method +setClassName:forClass:
*/
- (NSString*) classNameForClass: (Class)aClass;
/**
* Returns the delegate set for the receiver, or nil of none is set.
*/
- (id) delegate;
/**
* Encodes aBool and associates the encoded value with aKey.
*/
- (void) encodeBool: (BOOL)aBool forKey: (NSString*)aKey;
/**
* Encodes the data of the specified length and pointed to by aPointer,
* and associates the encoded value with aKey.
*/
- (void) encodeBytes: (const uint8_t*)aPointer
length: (NSUInteger)length
forKey: (NSString*)aKey;
/**
* Encodes anObject and associates the encoded value with aKey, but only
* if anObject has already been encoded using -encodeObject:forKey:
*/
- (void) encodeConditionalObject: (id)anObject forKey: (NSString*)aKey;
/**
* Encodes aDouble and associates the encoded value with aKey.
*/
- (void) encodeDouble: (double)aDouble forKey: (NSString*)aKey;
/**
* Encodes aFloat and associates the encoded value with aKey.
*/
- (void) encodeFloat: (float)aFloat forKey: (NSString*)aKey;
/**
* Encodes anInteger and associates the encoded value with aKey.
*/
- (void) encodeInt: (int)anInteger forKey: (NSString*)aKey;
/**
* Encodes anInteger and associates the encoded value with aKey.
*/
- (void) encodeInt32: (int32_t)anInteger forKey: (NSString*)aKey;
/**
* Encodes anInteger and associates the encoded value with aKey.
*/
- (void) encodeInt64: (int64_t)anInteger forKey: (NSString*)aKey;
/**
* Encodes anObject and associates the encoded value with aKey.
*/
- (void) encodeObject: (id)anObject forKey: (NSString*)aKey;
/**
* Ends the encoding process and causes the encoded archive to be placed
* in the mutable data object supplied when the receiver was initialised.<br />
* This method must be called at the end of encoding, and nothing may be
* encoded after this method is called.
*/
- (void) finishEncoding;
/**
* Initialise the receiver to encode an archive into the supplied
* data object.
*/
- (id) initForWritingWithMutableData: (NSMutableData*)data;
/**
* Returns the output format of the archived data ... this should default
* to the MacOS-X binary format, but we don't support that yet, so the
* -setOutputFormat: method should be used to set a supported format.
*/
- (NSPropertyListFormat) outputFormat;
/**
* Sets the name with which instances of aClass are encoded.<br />
* The value of aString must be the name of an existing class.
*/
- (void) setClassName: (NSString*)aString forClass: (Class)aClass;
/**
* Sets the receivers delegate. The delegate should conform to the
* NSObject(NSKeyedArchiverDelegate) informal protocol.<br />
* NB. the delegate is not retained, so you must ensure that it is not
* deallocated before the archiver has finished with it.
*/
- (void) setDelegate: (id)anObject;
/**
* Specifies the output format of the archived data ... this should default
* to the MacOS-X binary format, but we don't support that yet, so the
* -setOutputFormat: method should be used to set a supported format.
*/
- (void) setOutputFormat: (NSPropertyListFormat)format;
@end
/**
* Implements <em>keyed</em> unarchiving of object graphs. The keyed archiver
* should be used instead of [NSArchiver] for new implementations. Classes
* implementing [(NSCoding)] should check the [NSCoder-allowsKeyedCoding]
* method and if the response is YES, encode/decode their fields using the
* <code>...forKey:</code> [NSCoder] methods, which provide for more robust
* forwards and backwards compatibility.
*/
@interface NSKeyedUnarchiver : NSCoder
{
#if GS_EXPOSE(NSKeyedUnarchiver)
@private
NSDictionary *_archive;
id _delegate; /* Delegate controls operation. */
NSMapTable *_clsMap; /* Map classes to names. */
NSArray *_objects; /* All encoded objects. */
NSDictionary *_keyMap; /* Local object name table. */
unsigned _cursor; /* Position in object. */
NSString *_archiverClass;
NSString *_version;
#ifndef _IN_NSKEYEDUNARCHIVER_M
#define GSIArray void*
#endif
GSIArray _objMap; /* Decoded objects. */
#ifndef _IN_NSKEYEDUNARCHIVER_M
#undef GSIArray
#endif
NSZone *_zone; /* Zone for allocating objs. */
#endif
#if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/
@private id _internal GS_UNUSED_IVAR;
#endif
}
/**
* Returns class substituted for class name specified by aString when
* encountered in the archive being decoded from, or nil if there is no
* specific translation mapping. Each instance also maintains a translation
* map, which is searched first for a match during decoding.
*/
+ (Class) classForClassName: (NSString*)aString;
/**
* Sets class substituted for class name specified by aString when
* encountered in the archive being decoded from, or nil if there is no
* specific translation mapping. Each instance also maintains a translation
* map, which is searched first for a match during decoding.
*/
+ (void) setClass: (Class)aClass forClassName: (NSString*)aString;
/**
* Decodes from byte array in data and returns resulting root object.
*/
+ (id) unarchiveObjectWithData: (NSData*)data;
/**
* Decodes from file contents at aPath and returns resulting root object.
*/
+ (id) unarchiveObjectWithFile: (NSString*)aPath;
/**
* Returns class substituted for class name specified by aString when
* encountered in the archive being decoded from, or nil if there is no
* specific translation mapping. The class as a whole also maintains a
* translation map, which is searched on decoding if no match found here.
*/
- (Class) classForClassName: (NSString*)aString;
/**
* Sets class substituted for class name specified by aString when
* encountered in the archive being decoded from, or nil if there is no
* specific translation mapping. Each instance also maintains a translation
* map, which is searched first for a match during decoding.
*/
- (BOOL) containsValueForKey: (NSString*)aKey;
/**
* Sets class substituted for class name specified by aString when
* encountered in the archive being decoded from, or nil if there is no
* specific translation mapping. Each instance also maintains a translation
* map, which is searched first for a match during decoding.
*/
- (void) setClass: (Class)aClass forClassName: (NSString*)aString;
/**
* Returns a boolean value associated with aKey. This value must previously
* have been encoded using -encodeBool:forKey:
*/
- (BOOL) decodeBoolForKey: (NSString*)aKey;
/**
* Returns a pointer to a byte array associated with aKey.<br />
* Returns the length of the data in aLength.<br />
* This value must previously have been encoded using
* -encodeBytes:length:forKey:
*/
- (const uint8_t*) decodeBytesForKey: (NSString*)aKey
returnedLength: (NSUInteger*)length;
/**
* Returns a double value associated with aKey. This value must previously
* have been encoded using -encodeDouble:forKey: or -encodeFloat:forKey:
*/
- (double) decodeDoubleForKey: (NSString*)aKey;
/**
* Returns a float value associated with aKey. This value must previously
* have been encoded using -encodeFloat:forKey: or -encodeDouble:forKey:<br />
* Precision may be lost (or an exception raised if the value will not fit
* in a float) if the value was encoded using -encodeDouble:forKey:,
*/
- (float) decodeFloatForKey: (NSString*)aKey;
/**
* Returns an integer value associated with aKey. This value must previously
* have been encoded using -encodeInt:forKey:, -encodeInt32:forKey:, or
* -encodeInt64:forKey:.<br />
* An exception will be raised if the value does not fit in an integer.
*/
- (int) decodeIntForKey: (NSString*)aKey;
/**
* Returns a 32-bit integer value associated with aKey. This value must
* previously have been encoded using -encodeInt:forKey:,
* -encodeInt32:forKey:, or -encodeInt64:forKey:.<br />
* An exception will be raised if the value does not fit in a 32-bit integer.
*/
- (int32_t) decodeInt32ForKey: (NSString*)aKey;
/**
* Returns a 64-bit integer value associated with aKey. This value must
* previously have been encoded using -encodeInt:forKey:,
* -encodeInt32:forKey:, or -encodeInt64:forKey:.
*/
- (int64_t) decodeInt64ForKey: (NSString*)aKey;
/**
* Returns an object value associated with aKey. This value must
* previously have been encoded using -encodeObject:forKey: or
* -encodeConditionalObject:forKey:
*/
- (id) decodeObjectForKey: (NSString*)aKey;
/**
* Returns the delegate of the unarchiver.
*/
- (id) delegate;
/**
* Tells receiver that you are done retrieving from archive, so the delegate
* should be allowed to perform close-up operations.
*/
- (void) finishDecoding;
/**
* Prepare to read data from key archive (created by [NSKeyedArchiver]).
* Be sure to call -finishDecoding when done.
*/
- (id) initForReadingWithData: (NSData*)data;
/**
* Sets the receivers delegate. The delegate should conform to the
* NSObject(NSKeyedUnarchiverDelegate) informal protocol.<br />
* NB. the delegate is not retained, so you must ensure that it is not
* deallocated before the unarchiver has finished with it.
*/
- (void) setDelegate: (id)delegate;
@end
/**
* Internal methods. Do not use.
*/
@interface NSKeyedArchiver (Internal)
- (void) _encodeArrayOfObjects: (NSArray*)anArray forKey: (NSString*)aKey;
- (void) _encodePropertyList: (id)anObject forKey: (NSString*)aKey;
@end
/**
* Internal methods. Do not use.
*/
@interface NSKeyedUnarchiver (Internal)
- (id) _decodeArrayOfObjectsForKey: (NSString*)aKey;
- (id) _decodePropertyListForKey: (NSString*)aKey;
@end
/* Exceptions */
GS_EXPORT NSString * const NSInvalidArchiveOperationException;
GS_EXPORT NSString * const NSInvalidUnarchiveOperationException;
/**
* Informal protocol implemented by delegates of [NSKeyedArchiver].
*/
@interface NSObject (NSKeyedArchiverDelegate)
/**
* Sent when encoding of anObject has completed <em>except</em> in the case
* of conditional encoding.
*/
- (void) archiver: (NSKeyedArchiver*)anArchiver didEncodeObject: (id)anObject;
/**
* Sent when anObject is about to be encoded (or conditionally encoded)
* and provides the receiver with an opportunity to change the actual
* object stored into the archive by returning a different value (otherwise
* it should return anObject).<br />
* The method is not called for encoding of nil or for encoding of any
* object for which has already been called.<br />
* The method is called <em>after</em> the -replacementObjectForKeyedArchiver:
* method.
*/
- (id) archiver: (NSKeyedArchiver*)anArchiver willEncodeObject: (id)anObject;
/**
* Sent when the encoding process is complete.
*/
- (void) archiverDidFinish: (NSKeyedArchiver*)anArchiver;
/**
* Sent when the encoding process is about to finish.
*/
- (void) archiverWillFinish: (NSKeyedArchiver*)anArchiver;
/**
* Sent whenever object replacement occurs during encoding, either by the
* -replacementObjectForKeyedArchiver: method or because the delegate has
* returned a changed value using the -archiver:willEncodeObject: method.
*/
- (void) archiver: (NSKeyedArchiver*)anArchiver
willReplaceObject: (id)anObject
withObject: (id)newObject;
@end
/**
* Informal protocol implemented by delegates of [NSKeyedUnarchiver].
*/
@interface NSObject (NSKeyedUnarchiverDelegate)
/**
* Sent if the named class is not available during decoding.<br />
* The value of aName is the class name being decoded (after any name mapping
* has been applied).<br />
* The classNames array contains the original name of the class encoded
* in the archive, and is followed by each of its superclasses in turn.<br />
* The delegate may either return a class object for the unarchiver to use
* to continue decoding, or may return nil to abort the decoding process.
*/
- (Class) unarchiver: (NSKeyedUnarchiver*)anUnarchiver
cannotDecodeObjectOfClassName: (NSString*)aName
originalClasses: (NSArray*)classNames;
/**
* Sent when anObject is decoded. The receiver may return either anObject
* or some other object (including nil). If a value other than anObject is
* returned, it is used to replace anObject.
*/
- (id) unarchiver: (NSKeyedUnarchiver*)anUnarchiver
didDecodeObject: (id)anObject;
/**
* Sent when unarchiving is about to complete.
*/
- (void) unarchiverDidFinish: (NSKeyedUnarchiver*)anUnarchiver;
/**
* Sent when unarchiving has been completed.
*/
- (void) unarchiverWillFinish: (NSKeyedUnarchiver*)anUnarchiver;
/**
* Sent whenever object replacement occurs during decoding, eg by the
* -replacementObjectForKeyedArchiver: method.
*/
- (void) unarchiver: (NSKeyedUnarchiver*)anUnarchiver
willReplaceObject: (id)anObject
withObject: (id)newObject;
@end
/**
* Methods by which a class may control its archiving by the [NSKeyedArchiver].
*/
@interface NSObject (NSKeyedArchiverObjectSubstitution)
/**
* This message is sent to objects being encoded, to allow them to choose
* to be encoded a different class. If this returns nil it is treated as
* if it returned the class of the object.<br />
* After this method is applied, any class name mapping set in the archiver
* is applied to its result.<br />
* The default implementation returns the result of the -classForArchiver
* method.
*/
- (Class) classForKeyedArchiver;
/**
* This message is sent to objects being encoded, to allow them to choose
* to be encoded a different object by returning the alternative object.<br />
* The default implementation returns the result of calling
* the -replacementObjectForArchiver: method with a nil argument.<br />
* This is called only if no mapping has been set up in the archiver already.
*/
- (id) replacementObjectForKeyedArchiver: (NSKeyedArchiver*)archiver;
@end
/**
* Methods by which a class may control its unarchiving by the
* [NSKeyedArchiver].
*/
@interface NSObject (NSKeyedUnarchiverObjectSubstitution)
/**
* Sent during unarchiving to permit classes to substitute a different
* class for decoded instances of themselves.<br />
* Default implementation returns the receiver.<br />
* Overrides the mappings set up within the receiver.
*/
+ (Class) classForKeyedUnarchiver;
@end
/**
* Methods for encoding/decoding points, rectangles, and sizes.
*/
@interface NSCoder (NSGeometryKeyedCoding)
/**
* Encodes an <code>NSPoint</code> object.
*/
- (void) encodePoint: (NSPoint)aPoint forKey: (NSString*)aKey;
/**
* Encodes an <code>NSRect</code> object.
*/
- (void) encodeRect: (NSRect)aRect forKey: (NSString*)aKey;
/**
* Encodes an <code>NSSize</code> object.
*/
- (void) encodeSize: (NSSize)aSize forKey: (NSString*)aKey;
/**
* Decodes an <code>NSPoint</code> object.
*/
- (NSPoint) decodePointForKey: (NSString*)aKey;
/**
* Decodes an <code>NSRect</code> object.
*/
- (NSRect) decodeRectForKey: (NSString*)aKey;
/**
* Decodes an <code>NSSize</code> object.
*/
- (NSSize) decodeSizeForKey: (NSString*)aKey;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* __NSKeyedArchiver_h_GNUSTEP_BASE_INCLUDE */
|