2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* OSSerialize.h created by rsulack on Wen 25-Nov-1998 */
27 #ifndef _OS_OSSERIALIZE_H
28 #define _OS_OSSERIALIZE_H
30 #include <libkern/c++/OSObject.h>
37 @abstract A class used by the OS Container classes to serialize their instance data.
38 @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.
41 class OSSerialize
: public OSObject
43 OSDeclareDefaultStructors(OSSerialize
)
46 char *data
; // container for serialized data
47 unsigned int length
; // of serialized data (counting NULL)
48 unsigned int capacity
; // of container
49 unsigned int capacityIncrement
; // of container
52 OSDictionary
*tags
; // tags for all objects seen
54 struct ExpansionData
{ };
57 Reserved for future use. (Internal use only) */
58 ExpansionData
*reserved
;
62 static OSSerialize
*withCapacity(unsigned int capacity
);
64 virtual char *text() const;
66 virtual void clearText(); // using this can be a great speedup
67 // if you are serializing the same object
68 // over and over again
70 // stuff to serialize your object
71 virtual bool previouslySerialized(const OSMetaClassBase
*);
73 virtual bool addXMLStartTag(const OSMetaClassBase
*o
, const char *tagString
);
74 virtual bool addXMLEndTag(const char *tagString
);
76 virtual bool addChar(const char);
77 virtual bool addString(const char *);
79 // stuff you should never have to use (in theory)
81 virtual bool initWithCapacity(unsigned int inCapacity
);
82 virtual unsigned int getLength() const;
83 virtual unsigned int getCapacity() const;
84 virtual unsigned int getCapacityIncrement() const;
85 virtual unsigned int setCapacityIncrement(unsigned increment
);
86 virtual unsigned int ensureCapacity(unsigned int newCapacity
);
89 OSMetaClassDeclareReservedUnused(OSSerialize
, 0);
90 OSMetaClassDeclareReservedUnused(OSSerialize
, 1);
91 OSMetaClassDeclareReservedUnused(OSSerialize
, 2);
92 OSMetaClassDeclareReservedUnused(OSSerialize
, 3);
93 OSMetaClassDeclareReservedUnused(OSSerialize
, 4);
94 OSMetaClassDeclareReservedUnused(OSSerialize
, 5);
95 OSMetaClassDeclareReservedUnused(OSSerialize
, 6);
96 OSMetaClassDeclareReservedUnused(OSSerialize
, 7);
99 typedef bool (*OSSerializerCallback
)(void * target
, void * ref
,
102 class OSSerializer
: public OSObject
104 OSDeclareDefaultStructors(OSSerializer
)
108 OSSerializerCallback callback
;
112 static OSSerializer
* forTarget(void * target
,
113 OSSerializerCallback callback
, void * ref
= 0);
115 virtual bool serialize(OSSerialize
* s
) const;
118 #endif /* _OS_OSSERIALIZE_H */