2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* OSSerialize.h created by rsulack on Wen 25-Nov-1998 */
25 #ifndef _OS_OSSERIALIZE_H
26 #define _OS_OSSERIALIZE_H
28 #include <libkern/c++/OSObject.h>
35 @abstract A class used by the OS Container classes to serialize their instance data.
36 @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.
39 class OSSerialize
: public OSObject
41 OSDeclareDefaultStructors(OSSerialize
)
44 char *data
; // container for serialized data
45 unsigned int length
; // of serialized data (counting NULL)
46 unsigned int capacity
; // of container
47 unsigned int capacityIncrement
; // of container
50 OSDictionary
*tags
; // tags for all objects seen
52 struct ExpansionData
{ };
55 Reserved for future use. (Internal use only) */
56 ExpansionData
*reserved
;
60 static OSSerialize
*withCapacity(unsigned int capacity
);
62 virtual char *text() const;
64 virtual void clearText(); // using this can be a great speedup
65 // if you are serializing the same object
66 // over and over again
68 // stuff to serialize your object
69 virtual bool previouslySerialized(const OSMetaClassBase
*);
71 virtual bool addXMLStartTag(const OSMetaClassBase
*o
, const char *tagString
);
72 virtual bool addXMLEndTag(const char *tagString
);
74 virtual bool addChar(const char);
75 virtual bool addString(const char *);
77 // stuff you should never have to use (in theory)
79 virtual bool initWithCapacity(unsigned int inCapacity
);
80 virtual unsigned int getLength() const;
81 virtual unsigned int getCapacity() const;
82 virtual unsigned int getCapacityIncrement() const;
83 virtual unsigned int setCapacityIncrement(unsigned increment
);
84 virtual unsigned int ensureCapacity(unsigned int newCapacity
);
87 OSMetaClassDeclareReservedUnused(OSSerialize
, 0);
88 OSMetaClassDeclareReservedUnused(OSSerialize
, 1);
89 OSMetaClassDeclareReservedUnused(OSSerialize
, 2);
90 OSMetaClassDeclareReservedUnused(OSSerialize
, 3);
91 OSMetaClassDeclareReservedUnused(OSSerialize
, 4);
92 OSMetaClassDeclareReservedUnused(OSSerialize
, 5);
93 OSMetaClassDeclareReservedUnused(OSSerialize
, 6);
94 OSMetaClassDeclareReservedUnused(OSSerialize
, 7);
97 typedef bool (*OSSerializerCallback
)(void * target
, void * ref
,
100 class OSSerializer
: public OSObject
102 OSDeclareDefaultStructors(OSSerializer
)
106 OSSerializerCallback callback
;
110 static OSSerializer
* forTarget(void * target
,
111 OSSerializerCallback callback
, void * ref
= 0);
113 virtual bool serialize(OSSerialize
* s
) const;
116 #endif /* _OS_OSSERIALIZE_H */