1995-04-03 20:49:14 +00:00
|
|
|
/* Protocol for NSSerialization for GNUStep
|
1995-07-01 19:01:11 +00:00
|
|
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1995-07-01 19:01:11 +00:00
|
|
|
Date: 1995
|
1997-09-01 21:59:51 +00:00
|
|
|
Updated by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
1998-11-19 15:45:00 +00:00
|
|
|
Date: 1998
|
1995-04-03 20:49:14 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-04-03 20:49:14 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1995-04-03 20:49:14 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
1995-04-03 20:49:14 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1995-04-03 20:49:14 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
1995-04-03 20:49:14 +00:00
|
|
|
*/
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __NSSerialization_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSSerialization_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
1995-04-03 20:49:14 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
1999-05-26 12:59:34 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1995-04-15 19:41:39 +00:00
|
|
|
@class NSData, NSMutableData;
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Objects that are not standard property list constituents can adopt this
|
|
|
|
* protocol to allow themselves to be serialized by an [NSSerializer] and
|
|
|
|
* deserialized by an [NSDeserializer]. <em>Note, this mechanism has been
|
|
|
|
* deprecated and you should instead use [NSArchiver] and related facilities
|
|
|
|
* to serialize objects that are not ordinary property lists.</em>
|
|
|
|
*/
|
1995-04-03 20:49:14 +00:00
|
|
|
@protocol NSObjCTypeSerializationCallBack
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Decodes an object of given type from data at position cursor.
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
- (void) deserializeObjectAt: (id*)object
|
|
|
|
ofObjCType: (const char *)type
|
|
|
|
fromData: (NSData*)data
|
|
|
|
atCursor: (unsigned*)cursor;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Encode the given object of given type into data, using a string not a
|
|
|
|
* binary representation.
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
- (void) serializeObjectAt: (id*)object
|
|
|
|
ofObjCType: (const char *)type
|
|
|
|
intoData: (NSMutableData*)data;
|
|
|
|
@end
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* <p><em>This class is deprecated in favor of
|
|
|
|
* [NSPropertyListSerialization].</em></p>
|
|
|
|
*
|
|
|
|
* <p>It provides a means of producing a byte-array (actually string)
|
|
|
|
* representation of a property list (NSArray or NSDictionary plus limited
|
|
|
|
* contents).</p>
|
|
|
|
*/
|
1998-11-19 15:45:00 +00:00
|
|
|
@interface NSSerializer: NSObject
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <p>Serialize given property list (NSArray or NSDictionary plus limited
|
2006-03-08 11:28:59 +00:00
|
|
|
* contents) into byte array.</p>
|
|
|
|
* <p><em>Deprecated in favor of
|
|
|
|
* [NSPropertyListSerialization+dataFromPropertyList:format:errorDescription:].
|
|
|
|
* </em></p>
|
2004-06-22 22:27:39 +00:00
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
+ (NSData*) serializePropertyList: (id)propertyList;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <p>Serialize given property list (NSArray or NSDictionary plus limited
|
2006-03-08 11:28:59 +00:00
|
|
|
* contents) into given mutable byte array.</p>
|
|
|
|
* <p><em>Deprecated in favor of
|
|
|
|
* [NSPropertyListSerialization+dataFromPropertyList:format:errorDescription:].
|
|
|
|
* </em></p>
|
2004-06-22 22:27:39 +00:00
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
+ (void) serializePropertyList: (id)propertyList
|
|
|
|
intoData: (NSMutableData*)d;
|
|
|
|
@end
|
|
|
|
|
2008-06-10 18:20:23 +00:00
|
|
|
#if GS_API_VERSION(GS_API_NONE, 011700)
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
1998-11-20 12:12:08 +00:00
|
|
|
* GNUstep extends serialization by having the option to make the
|
|
|
|
* resulting data more compact by ensuring that repeated strings
|
|
|
|
* are only stored once. If the property-list has a lot of repeated
|
|
|
|
* strings in it, this will be both faster and more space efficient
|
|
|
|
* but it will be slower if the property-list has few repeated
|
1998-12-07 11:39:40 +00:00
|
|
|
* strings. The default is NOT to generate compact versions of the data.
|
1998-11-20 12:12:08 +00:00
|
|
|
*
|
|
|
|
* The [+shouldBeCompact:] method sets default behavior.
|
|
|
|
* The [+serializePropertyList:intoData:compact:] method lets you
|
|
|
|
* override the default behavior.
|
|
|
|
*/
|
|
|
|
@interface NSSerializer (GNUstep)
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify whether to produce compacted format, with repeated strings only
|
|
|
|
* written once.
|
|
|
|
*/
|
1998-11-20 12:12:08 +00:00
|
|
|
+ (void) shouldBeCompact: (BOOL)flag;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* As [NSSerializer+serializePropertyList:intoData:] but specify whether to
|
|
|
|
* produce compacted format.
|
|
|
|
*/
|
1998-11-20 12:12:08 +00:00
|
|
|
+ (void) serializePropertyList: (id)propertyList
|
|
|
|
intoData: (NSMutableData*)d
|
|
|
|
compact: (BOOL)flag;
|
|
|
|
@end
|
|
|
|
#endif
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* <em>This class is deprecated in favor of
|
|
|
|
* [NSPropertyListSerialization].</em> It provides a means of recovering a
|
|
|
|
* property list (NSArray or NSDictionary plus limited contents) from a
|
|
|
|
* byte-array (actually string) representation.
|
|
|
|
*/
|
1998-11-19 15:45:00 +00:00
|
|
|
@interface NSDeserializer: NSObject
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Recover a property list (NSArray or NSDictionary plus limited
|
2006-03-08 11:28:59 +00:00
|
|
|
* contents) from a byte array.
|
|
|
|
* <em>Deprecated in favor of
|
|
|
|
* [NSPropertyListSerialization
|
|
|
|
* +propertyListFromData:mutabilityOption:format:errorDescription:].</em>
|
2004-06-22 22:27:39 +00:00
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
+ (id) deserializePropertyListFromData: (NSData*)data
|
|
|
|
atCursor: (unsigned int*)cursor
|
|
|
|
mutableContainers: (BOOL)flag;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Recover a property list (NSArray or NSDictionary plus limited
|
2006-03-08 11:28:59 +00:00
|
|
|
* contents) from a byte array.
|
|
|
|
* <em>Deprecated in favor of
|
|
|
|
* [NSPropertyListSerialization
|
|
|
|
* +propertyListFromData:mutabilityOption:format:errorDescription:].</em>
|
2004-06-22 22:27:39 +00:00
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
+ (id) deserializePropertyListFromData: (NSData*)data
|
|
|
|
mutableContainers: (BOOL)flag;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Recover a property list (NSArray or NSDictionary plus limited contents)
|
|
|
|
* from a byte array. If the data at cursor has a length greater than
|
|
|
|
* length, a proxy is substituted for the actual property list as long as the
|
|
|
|
* constituent objects of that property list are not accessed.
|
|
|
|
* <em>Deprecated in favor of
|
2006-03-08 11:28:59 +00:00
|
|
|
* [NSPropertyListSerialization
|
|
|
|
* +propertyListFromData:mutabilityOption:format:errorDescription:].</em>
|
2004-06-22 22:27:39 +00:00
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
+ (id) deserializePropertyListLazilyFromData: (NSData*)data
|
1998-11-19 15:45:00 +00:00
|
|
|
atCursor: (unsigned*)cursor
|
|
|
|
length: (unsigned)length
|
|
|
|
mutableContainers: (BOOL)flag;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
1995-04-03 20:49:14 +00:00
|
|
|
@end
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* <p>GNUstep extends deserialization by having the option to make the
|
1999-06-02 09:32:16 +00:00
|
|
|
* resulting data more compact by ensuring that repeated strings
|
|
|
|
* are only stored once. If the property-list has a lot of repeated
|
|
|
|
* strings in it, this will be more space efficient but it will be
|
|
|
|
* slower (though other parts of your code may speed up through more
|
|
|
|
* efficient equality testing of uniqued strings).
|
2004-06-22 22:27:39 +00:00
|
|
|
* The default is NOT to deserialize uniqued strings.</p>
|
1999-06-02 09:32:16 +00:00
|
|
|
*
|
2004-06-22 22:27:39 +00:00
|
|
|
* <p>The [+uniquing:] method turns uniquing on/off.
|
|
|
|
* Uniquing is done using a global [NSCountedSet] - see its documentation
|
|
|
|
* for details.</p>
|
1999-06-02 09:32:16 +00:00
|
|
|
*/
|
|
|
|
@interface NSDeserializer (GNUstep)
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Turns uniquing (collapsing of multiple instances of a single string in the
|
|
|
|
* output to one full copy plus references) on/off.
|
|
|
|
*/
|
1999-06-02 09:32:16 +00:00
|
|
|
+ (void) uniquing: (BOOL)flag;
|
|
|
|
@end
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#endif /* __NSSerialization_h_GNUSTEP_BASE_INCLUDE */
|