2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* OSSerialize.h created by rsulack on Wen 25-Nov-1998 */
30 #ifndef _OS_OSSERIALIZE_H
31 #define _OS_OSSERIALIZE_H
33 #include <libkern/c++/OSObject.h>
40 @abstract A class used by the OS Container classes to serialize their instance data.
41 @discussion This class is for the most part internal to the OS Container classes and should not be used directly. Each class inherits a serialize() method from OSObject which is used to actually serialize an object.
44 class OSSerialize
: public OSObject
46 OSDeclareDefaultStructors(OSSerialize
)
49 char *data
; // container for serialized data
50 unsigned int length
; // of serialized data (counting NULL)
51 unsigned int capacity
; // of container
52 unsigned int capacityIncrement
; // of container
55 OSDictionary
*tags
; // tags for all objects seen
57 struct ExpansionData
{ };
60 Reserved for future use. (Internal use only) */
61 ExpansionData
*reserved
;
65 static OSSerialize
*withCapacity(unsigned int capacity
);
67 virtual char *text() const;
69 virtual void clearText(); // using this can be a great speedup
70 // if you are serializing the same object
71 // over and over again
73 // stuff to serialize your object
74 virtual bool previouslySerialized(const OSMetaClassBase
*);
76 virtual bool addXMLStartTag(const OSMetaClassBase
*o
, const char *tagString
);
77 virtual bool addXMLEndTag(const char *tagString
);
79 virtual bool addChar(const char);
80 virtual bool addString(const char *);
82 // stuff you should never have to use (in theory)
84 virtual bool initWithCapacity(unsigned int inCapacity
);
85 virtual unsigned int getLength() const;
86 virtual unsigned int getCapacity() const;
87 virtual unsigned int getCapacityIncrement() const;
88 virtual unsigned int setCapacityIncrement(unsigned increment
);
89 virtual unsigned int ensureCapacity(unsigned int newCapacity
);
92 OSMetaClassDeclareReservedUnused(OSSerialize
, 0);
93 OSMetaClassDeclareReservedUnused(OSSerialize
, 1);
94 OSMetaClassDeclareReservedUnused(OSSerialize
, 2);
95 OSMetaClassDeclareReservedUnused(OSSerialize
, 3);
96 OSMetaClassDeclareReservedUnused(OSSerialize
, 4);
97 OSMetaClassDeclareReservedUnused(OSSerialize
, 5);
98 OSMetaClassDeclareReservedUnused(OSSerialize
, 6);
99 OSMetaClassDeclareReservedUnused(OSSerialize
, 7);
102 typedef bool (*OSSerializerCallback
)(void * target
, void * ref
,
105 class OSSerializer
: public OSObject
107 OSDeclareDefaultStructors(OSSerializer
)
111 OSSerializerCallback callback
;
115 static OSSerializer
* forTarget(void * target
,
116 OSSerializerCallback callback
, void * ref
= 0);
118 virtual bool serialize(OSSerialize
* s
) const;
121 #endif /* _OS_OSSERIALIZE_H */