Framework | Carbon/Carbon.h |
Declared in | HIArchive.h |
HIArchive provides a convenient and standardized mechanism for flattening data objects so they can be stored in memory or on disk. Applications can use these archives whenever they need to package complex data. For example, you can use archives to:
Store document data
Transfer data using pasteboards, drag-and-drop, streams, or Apple events
Store localization strings and user interface elements in the same package
HIArchive encodes archives in the binary property list format. You can convert archives to a text XML format using the plutil
property list tool accessible from Terminal. HIArchive is comparable to (and uses the same underlying mechanism as) the Cocoa NSKeyedArchiver/Unarchiver classes.
For details about using HIArchive, see HIArchive Programming Guide.
HIArchive is available in Mac OS X version 10.4 and later.
HIArchiveCreateForEncoding
HIArchiveEncodeBoolean
HIArchiveEncodeNumber
HIArchiveEncodeCFType
HIArchiveCopyEncodedData
Retrieves a CFType object from an archive.
OSStatus HIArchiveCopyDecodedCFType ( HIArchiveRef inDecoder, CFStringRef inKey, CFTypeRef *outCFType );
The archive holding the CFType object to retrieve.
A Core Foundation string key identifying the CFType object to retrieve.
On return, outCFType
points
to the retrieved CFType object.
A result code.
You also use this function for retrieving HIObjects and objects subclassed from HIObject.
HIArchive.h
Compresses an archive for storage.
OSStatus HIArchiveCopyEncodedData ( HIArchiveRef inEncoder, CFDataRef *outData );
The archive to compress.
On return, outData
points
to the compressed archive.
A result code.
When you have finished adding data to an archive, calling HIArchiveCopyEncodedData
compresses
the data and returns it to you as a CFData object. You can use the
returned data reference to store or transfer the data as you choose,
for example writing it to a file or copying it to a pasteboard.
After compression, you can release the original HIArchive
reference by calling CFRelease
.
HIArchive.h
Creates an HIArchive object to retrieve objects.
OSStatus HIArchiveCreateForDecoding ( CFDataRef inData, OptionBits inOptions, HIArchiveRef *outDecoder );
A CFData reference pointing to archived data.
This archive was originally written to a data stream using HIArchiveCopyEncodedData
.
This data reference does not have to be the one originally returned
by HIArchiveCopyEncodedData
,
but it must contain a copy of the same data.
Any decoding options. Currently the only option
is kHIArchiveDecodeSuperclassForUnregisteredObjects
.
On return, outDecoder
points
to the newly created HIArchive object.
A result code.
You use this function when you want to retrieve data from an existing HIArchive.
HIArchive.h
Creates an HIArchive object to store objects.
OSStatus HIArchiveCreateForEncoding ( HIArchiveRef *outEncoder );
On return, outEncoder
points
to the newly created HIArchive object.
A result code.
Before you can archive any objects, you must create an HIArchive object in which to store them.
HIArchive.h
Retrieves a Boolean value from an archive.
OSStatus HIArchiveDecodeBoolean ( HIArchiveRef inDecoder, CFStringRef inKey, Boolean *outBoolean );
The archive holding the Boolean value.
A Core Foundation string key identifying the Boolean to retrieve.
On return, outBoolean
points
to the retrieved Boolean value.
A result code.
This function is a convenience wrapper that calls HIArchiveCopyDecodedCFType
to
obtain a CFBoolean value.
HIArchive.h
Retrieves a number from an archive.
OSStatus HIArchiveDecodeNumber ( HIArchiveRef inDecoder, CFStringRef inKey, CFNumberType inNumberType, void *outNumberValue );
The archive holding the number to retrieve.
A Core Foundation string key identifying the number to retrieve.
A CFNumber type identifying the type of number
value to be retrieved. For example, kCFNumberSInt32Type
.
See CFNumber Reference in Core Foundation Reference Documentation
for additional possible values.
Before calling, outNumberValue
must
point to a number variable of the type and size you specified in inNumberType
.
On return, outNumberValue
points
to the retrieved number.
A result code.
This function is a convenience wrapper that calls HIArchiveCopyDecodedCFType
to
obtain a CFNumber value.
HIArchive.h
Stores a Boolean value in an archive.
OSStatus HIArchiveEncodeBoolean ( HIArchiveRef inEncoder, CFStringRef inKey, Boolean inBoolean );
The archive to store the Boolean value.
A Core Foundation string key identifying the Boolean value.
The Boolean value.
A result code.
This function is a convenience wrapper that calls HIArchiveEncodeCFType
with
a CFBoolean value.
HIArchive.h
Stores a CFType object in an archive.
OSStatus HIArchiveEncodeCFType ( HIArchiveRef inEncoder, CFStringRef inKey, CFTypeRef inCFType );
The archive to store the CFType object.
A Core Foundation string key identifying the CFType object.
The CFType object to store in the archive.
A result code.
You can only encode base CFType objects that correspond to
archivable NSFoundation objects. For example, type CFStringRef
is
supported, but type HIShapeRef
is
not.
You also use this function for storing HIObjects and objects subclassed from HIObject. Currently only the following HIObject subclass types support archiving:
HIObjectRef
HIViewRef
WindowRef
ControlRef
MenuRef
HIArchive.h
Stores a number in an archive.
OSStatus HIArchiveEncodeNumber ( HIArchiveRef inEncoder, CFStringRef inKey, CFNumberType inNumberType, const void *inNumberValue );
The archive to store the number.
A Core Foundation string key identifying the number.
A CFNumber type identifying the type of number
value to be stored, for example, kCFNumberSInt32Type
.
See CFNumber Reference in Core Foundation Reference Documentation
for additional possible values.
A pointer to the number value.
A result code.
This function is a convenience wrapper that calls HIArchiveEncodeCFType
with
a CFNumber value.
HIArchive.h
Obtains the CFType ID for HIArchive objects.
CFTypeID HIArchiveGetTypeID ( void );
The Core Foundation type ID for the HIArchive object type.
HIArchive.h
Defines an uncompressed archive object.
typedef struct OpaqueHIArchiveRef* HIArchiveRef;
The structure pointed to by this reference is opaque. HIArchiveRef
is
a CFType, and therefore responds to CFRetain
and CFRelease
calls.
HIArchive.h
Defines options available when calling HIArchiveCreateForDecoding
.
enum { kHIArchiveDecodeSuperclassForUnregisteredObjects = (1 << 0) };
kHIArchiveDecodeSuperclassForUnregisteredObjects
If the class of the HIObject you are attempting
to decode is not a registered subclass, this option allows HIArchiveCopyDecodedCFType
to
instantiate the object as its superclass, if it exists. For example,
if your application has not yet registered com.myCorp.mycustomView
before
attempting to unarchive an instance of that HIView, HIArchive instantiates
the data as class com.apple.hiview
.
Only data written to the superclass is decoded; any data unique
to the unregistered subclass is ignored. Specifying this option also
signals the HIObject to load its custom archive data so you can
access it by calling HIObjectCopyCustomArchiveData
.
This option can be useful when creating an archive editor that doesn’t implement all the objects contained in a client archive.
Available in Mac OS X v10.4 and later.
Declared in HIArchive.h
.
Result Code | Value | Description |
---|---|---|
noErr |
0 | No error. Available in Mac OS X v10.0 and later. |
hiArchiveTypeMismatchErr |
-6780 | The encoding or decoding archive was passed into a noncorresponding function. (For example, an archive created for encoding was passed into a decoding function.) Available in Mac OS X v10.4 and later. |
hiArchiveKeyNotAvailableErr |
-6781 | The requested key does not exist in the specified archive. Available in Mac OS X v10.4 and later. |
hiArchiveEncodingCompleteErr |
-6782 |
Available in Mac OS X v10.4 and later. |
hiArchiveHIObjectIgnoresArchivingErr |
-6783 | The HIObject you wanted to encode does not support the HIArchive protocol. Available in Mac OS X v10.4 and later. |
© 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-08-11)