1
/* Protocol for NSSerialization for GNUStep
2
Copyright (C) 1995 Free Software Foundation, Inc.
4
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
6
Updated by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
9
This file is part of the GNUstep Base Library.
11
This library is free software; you can redistribute it and/or
12
modify it under the terms of the GNU Library General Public
13
License as published by the Free Software Foundation; either
14
version 2 of the License, or (at your option) any later version.
16
This library is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
Library General Public License for more details.
21
You should have received a copy of the GNU Library General Public
22
License along with this library; if not, write to the Free
23
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
26
#ifndef __NSSerialization_h_GNUSTEP_BASE_INCLUDE
27
#define __NSSerialization_h_GNUSTEP_BASE_INCLUDE
29
#include <Foundation/NSObject.h>
31
@class NSData, NSMutableData;
34
* Objects that are not standard property list constituents can adopt this
35
* protocol to allow themselves to be serialized by an [NSSerializer] and
36
* deserialized by an [NSDeserializer]. <em>Note, this mechanism has been
37
* deprecated and you should instead use [NSArchiver] and related facilities
38
* to serialize objects that are not ordinary property lists.</em>
40
@protocol NSObjCTypeSerializationCallBack
43
* Decodes an object of given type from data at position cursor.
45
- (void) deserializeObjectAt: (id*)object
46
ofObjCType: (const char *)type
47
fromData: (NSData*)data
48
atCursor: (unsigned*)cursor;
51
* Encode the given object of given type into data, using a string not a
52
* binary representation.
54
- (void) serializeObjectAt: (id*)object
55
ofObjCType: (const char *)type
56
intoData: (NSMutableData*)data;
60
* <p><em>This class is deprecated in favor of
61
* [NSPropertyListSerialization].</em></p>
63
* <p>It provides a means of producing a byte-array (actually string)
64
* representation of a property list (NSArray or NSDictionary plus limited
67
@interface NSSerializer: NSObject
70
* <p>Serialize given property list (NSArray or NSDictionary plus limited
71
* contents) into byte array.</p> <p><em>Deprecated in favor of
72
* [NSPropertyListSerialization+dataFromPropertyList:format:errorDescription:].</em></p>
74
+ (NSData*) serializePropertyList: (id)propertyList;
77
* <p>Serialize given property list (NSArray or NSDictionary plus limited
78
* contents) into given mutable byte array.</p> <p><em>Deprecated in favor of
79
* [NSPropertyListSerialization+dataFromPropertyList:format:errorDescription:].</em></p>
82
+ (void) serializePropertyList: (id)propertyList
83
intoData: (NSMutableData*)d;
88
* GNUstep extends serialization by having the option to make the
89
* resulting data more compact by ensuring that repeated strings
90
* are only stored once. If the property-list has a lot of repeated
91
* strings in it, this will be both faster and more space efficient
92
* but it will be slower if the property-list has few repeated
93
* strings. The default is NOT to generate compact versions of the data.
95
* The [+shouldBeCompact:] method sets default behavior.
96
* The [+serializePropertyList:intoData:compact:] method lets you
97
* override the default behavior.
99
@interface NSSerializer (GNUstep)
102
* Specify whether to produce compacted format, with repeated strings only
105
+ (void) shouldBeCompact: (BOOL)flag;
108
* As [NSSerializer+serializePropertyList:intoData:] but specify whether to
109
* produce compacted format.
111
+ (void) serializePropertyList: (id)propertyList
112
intoData: (NSMutableData*)d
118
* <em>This class is deprecated in favor of
119
* [NSPropertyListSerialization].</em> It provides a means of recovering a
120
* property list (NSArray or NSDictionary plus limited contents) from a
121
* byte-array (actually string) representation.
123
@interface NSDeserializer: NSObject
126
* Recover a property list (NSArray or NSDictionary plus limited
127
* contents) from a byte array. <em>Deprecated in favor of
128
* [NSPropertyListSerialization+propertyListFromData:mutabilityOption:format:errorDescription:].</em>
130
+ (id) deserializePropertyListFromData: (NSData*)data
131
atCursor: (unsigned int*)cursor
132
mutableContainers: (BOOL)flag;
135
* Recover a property list (NSArray or NSDictionary plus limited
136
* contents) from a byte array. <em>Deprecated in favor of
137
* [NSPropertyListSerialization+propertyListFromData:mutabilityOption:format:errorDescription:].</em>
139
+ (id) deserializePropertyListFromData: (NSData*)data
140
mutableContainers: (BOOL)flag;
143
* Recover a property list (NSArray or NSDictionary plus limited contents)
144
* from a byte array. If the data at cursor has a length greater than
145
* length, a proxy is substituted for the actual property list as long as the
146
* constituent objects of that property list are not accessed.
147
* <em>Deprecated in favor of
148
* [NSPropertyListSerialization+propertyListFromData:mutabilityOption:format:errorDescription:].</em>
150
+ (id) deserializePropertyListLazilyFromData: (NSData*)data
151
atCursor: (unsigned*)cursor
152
length: (unsigned)length
153
mutableContainers: (BOOL)flag;
159
* <p>GNUstep extends deserialization by having the option to make the
160
* resulting data more compact by ensuring that repeated strings
161
* are only stored once. If the property-list has a lot of repeated
162
* strings in it, this will be more space efficient but it will be
163
* slower (though other parts of your code may speed up through more
164
* efficient equality testing of uniqued strings).
165
* The default is NOT to deserialize uniqued strings.</p>
167
* <p>The [+uniquing:] method turns uniquing on/off.
168
* Uniquing is done using a global [NSCountedSet] - see its documentation
171
@interface NSDeserializer (GNUstep)
173
* Turns uniquing (collapsing of multiple instances of a single string in the
174
* output to one full copy plus references) on/off.
176
+ (void) uniquing: (BOOL)flag;
181
#endif /* __NSSerialization_h_GNUSTEP_BASE_INCLUDE */