2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* OSSerialize.h created by rsulack on Wen 25-Nov-1998 */
32 #ifndef _OS_OSSERIALIZE_H
33 #define _OS_OSSERIALIZE_H
35 #include <libkern/c++/OSObject.h>
42 @abstract A class used by the OS Container classes to serialize their instance data.
43 @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.
46 class OSSerialize
: public OSObject
48 OSDeclareDefaultStructors(OSSerialize
)
51 char *data
; // container for serialized data
52 unsigned int length
; // of serialized data (counting NULL)
53 unsigned int capacity
; // of container
54 unsigned int capacityIncrement
; // of container
57 OSDictionary
*tags
; // tags for all objects seen
59 struct ExpansionData
{ };
62 Reserved for future use. (Internal use only) */
63 ExpansionData
*reserved
;
67 static OSSerialize
*withCapacity(unsigned int capacity
);
69 virtual char *text() const;
71 virtual void clearText(); // using this can be a great speedup
72 // if you are serializing the same object
73 // over and over again
75 // stuff to serialize your object
76 virtual bool previouslySerialized(const OSMetaClassBase
*);
78 virtual bool addXMLStartTag(const OSMetaClassBase
*o
, const char *tagString
);
79 virtual bool addXMLEndTag(const char *tagString
);
81 virtual bool addChar(const char);
82 virtual bool addString(const char *);
84 // stuff you should never have to use (in theory)
86 virtual bool initWithCapacity(unsigned int inCapacity
);
87 virtual unsigned int getLength() const;
88 virtual unsigned int getCapacity() const;
89 virtual unsigned int getCapacityIncrement() const;
90 virtual unsigned int setCapacityIncrement(unsigned increment
);
91 virtual unsigned int ensureCapacity(unsigned int newCapacity
);
94 OSMetaClassDeclareReservedUnused(OSSerialize
, 0);
95 OSMetaClassDeclareReservedUnused(OSSerialize
, 1);
96 OSMetaClassDeclareReservedUnused(OSSerialize
, 2);
97 OSMetaClassDeclareReservedUnused(OSSerialize
, 3);
98 OSMetaClassDeclareReservedUnused(OSSerialize
, 4);
99 OSMetaClassDeclareReservedUnused(OSSerialize
, 5);
100 OSMetaClassDeclareReservedUnused(OSSerialize
, 6);
101 OSMetaClassDeclareReservedUnused(OSSerialize
, 7);
104 typedef bool (*OSSerializerCallback
)(void * target
, void * ref
,
107 class OSSerializer
: public OSObject
109 OSDeclareDefaultStructors(OSSerializer
)
113 OSSerializerCallback callback
;
117 static OSSerializer
* forTarget(void * target
,
118 OSSerializerCallback callback
, void * ref
= 0);
120 virtual bool serialize(OSSerialize
* s
) const;
123 #endif /* _OS_OSSERIALIZE_H */