~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to Headers/Foundation/NSSerialization.h

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Protocol for NSSerialization for GNUStep
 
2
   Copyright (C) 1995 Free Software Foundation, Inc.
 
3
 
 
4
   Written by:  Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
 
5
   Date: 1995
 
6
   Updated by:  Richard Frith-Macdonald <richard@brainstorm.co.uk>
 
7
   Date: 1998
 
8
   
 
9
   This file is part of the GNUstep Base Library.
 
10
 
 
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.
 
15
   
 
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.
 
20
   
 
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.
 
24
   */ 
 
25
 
 
26
#ifndef __NSSerialization_h_GNUSTEP_BASE_INCLUDE
 
27
#define __NSSerialization_h_GNUSTEP_BASE_INCLUDE
 
28
 
 
29
#include <Foundation/NSObject.h>
 
30
 
 
31
@class NSData, NSMutableData;
 
32
 
 
33
/**
 
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>
 
39
 */
 
40
@protocol NSObjCTypeSerializationCallBack
 
41
 
 
42
/**
 
43
 *  Decodes an object of given type from data at position cursor.
 
44
 */
 
45
- (void) deserializeObjectAt: (id*)object
 
46
                  ofObjCType: (const char *)type
 
47
                    fromData: (NSData*)data
 
48
                    atCursor: (unsigned*)cursor;
 
49
 
 
50
/**
 
51
 *  Encode the given object of given type into data, using a string not a
 
52
 *  binary representation.
 
53
 */
 
54
- (void) serializeObjectAt: (id*)object
 
55
                ofObjCType: (const char *)type
 
56
                  intoData: (NSMutableData*)data;
 
57
@end
 
58
 
 
59
/**
 
60
 *  <p><em>This class is deprecated in favor of
 
61
 *  [NSPropertyListSerialization].</em></p>
 
62
 *
 
63
 *  <p>It provides a means of producing a byte-array (actually string)
 
64
 *  representation of a property list (NSArray or NSDictionary plus limited
 
65
 *  contents).</p>
 
66
 */
 
67
@interface NSSerializer: NSObject
 
68
 
 
69
/**
 
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>
 
73
 */
 
74
+ (NSData*) serializePropertyList: (id)propertyList;
 
75
 
 
76
/**
 
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>
 
80
 
 
81
 */
 
82
+ (void) serializePropertyList: (id)propertyList
 
83
                      intoData: (NSMutableData*)d;
 
84
@end
 
85
 
 
86
#ifndef NO_GNUSTEP
 
87
/**
 
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.
 
94
 *
 
95
 *      The [+shouldBeCompact:] method sets default behavior.
 
96
 *      The [+serializePropertyList:intoData:compact:] method lets you
 
97
 *      override the default behavior.
 
98
 */
 
99
@interface NSSerializer (GNUstep)
 
100
 
 
101
/**
 
102
 *  Specify whether to produce compacted format, with repeated strings only
 
103
 *  written once.
 
104
 */
 
105
+ (void) shouldBeCompact: (BOOL)flag;
 
106
 
 
107
/**
 
108
 *  As [NSSerializer+serializePropertyList:intoData:] but specify whether to
 
109
 *  produce compacted format.
 
110
 */
 
111
+ (void) serializePropertyList: (id)propertyList
 
112
                      intoData: (NSMutableData*)d
 
113
                       compact: (BOOL)flag;
 
114
@end
 
115
#endif
 
116
 
 
117
/**
 
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.
 
122
 */
 
123
@interface NSDeserializer: NSObject
 
124
 
 
125
/**
 
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>
 
129
 */
 
130
+ (id) deserializePropertyListFromData: (NSData*)data
 
131
                              atCursor: (unsigned int*)cursor
 
132
                     mutableContainers: (BOOL)flag;
 
133
 
 
134
/**
 
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>
 
138
 */
 
139
+ (id) deserializePropertyListFromData: (NSData*)data
 
140
                     mutableContainers: (BOOL)flag;
 
141
 
 
142
/**
 
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>
 
149
 */
 
150
+ (id) deserializePropertyListLazilyFromData: (NSData*)data
 
151
                                    atCursor: (unsigned*)cursor
 
152
                                      length: (unsigned)length
 
153
                           mutableContainers: (BOOL)flag;
 
154
 
 
155
@end
 
156
 
 
157
#ifndef NO_GNUSTEP
 
158
/**
 
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>
 
166
 *
 
167
 *      <p>The [+uniquing:] method turns uniquing on/off.
 
168
 *      Uniquing is done using a global [NSCountedSet] - see its documentation
 
169
 *      for details.</p>
 
170
 */
 
171
@interface NSDeserializer (GNUstep)
 
172
/**
 
173
 * Turns uniquing (collapsing of multiple instances of a single string in the
 
174
 * output to one full copy plus references) on/off.
 
175
 */
 
176
+ (void) uniquing: (BOOL)flag;
 
177
@end
 
178
 
 
179
#endif
 
180
 
 
181
#endif /* __NSSerialization_h_GNUSTEP_BASE_INCLUDE */