#include <libkern/c++/OSSerialize.h>

libkern/c++/OSSerialize.h Kernel.framework

OSSerialize.h created by rsulack on Wen 25-Nov-1998
4 typedefs · 2 classs · 1 function

typedefOSSerializerPtr

typedef OSSerializer* OSSerializerPtr

typedefOSSerializePtr

typedef OSSerialize* OSSerializePtr

functionOSUnserializeBinary

OSObjectPtr OSUnserializeBinary(const void *buffer, size_t bufferSize)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/c++/OSSerializeBinary.cpp
Recreates a graph of libkern collection and container objects (OSDictionary, OSArray, OSSet, OSString, OSSymbol, OSData, OSNumber, OSBoolean) from the binary serialization format produced by OSSerialize::binaryWithCapacity. The buffer must be 4-byte aligned and begin with kOSSerializeBinarySignature (or the indexed-binary signature byte); object and stack counts are bounded to guard against malformed input. Returns the root object, retained for the caller, or NULL on malformed data. Overloads report a parse error message through an OSString** or OSSharedPtr<OSString>& errorString, set to NULL on success. The OSSerialize.h variant taking const void* omits error reporting.

classOSSerialize

: public OSObject
static OSPtr<OSSerialize> withCapacity(unsigned int capacity)static
@function withCapacity @abstract Creates and initializes an empty OSSerialize object. @param capacity The initial size of the XML buffer. @result A new instance of OSSerialize with a retain count of 1; <code>NULL</code> on failure. @discussion The serializer will grow as needed to accommodate more data.
static OSPtr<OSSerialize> binaryWithCapacity(
	unsigned int inCapacity,
	Editor editor = NULL,
	void * reference = NULL
)
static
void setIndexed(bool index)
virtual char * text() constvirtual
@function text @abstract Returns the XML text serialized so far. @result The nul-terminated XML data serialized so far.
virtual void clearText()virtual
@function clearText @abstract Resets the OSSerialize object. @discussion This function is a useful optimization if you are serializing the same object repeatedly.
virtual bool previouslySerialized(const OSMetaClassBase * object)virtual
@function previouslySerialized @abstract Checks whether the object has already been serialized into the XML stream, emitting a reference if it has. @param object The object to check. @result <code>true</code> if <code>object</code> has already been serialized by this OSSerialize object and a reference to it is successfully added to the XML stream, <code>false</code> otherwise. @discussion This function both reduces the size of generated XML by emitting shorter references to existing objects with the same value (particularly for OSString, OSSymbol, and OSData), and also preserves instance references so that the user-space I/O Kit library can reconstruct an identical graph of object relationships. All classes that override <code>@link //apple_ref/cpp/instm/OSObject/serialize/virtualbool/(OSSerialize*) OSObject::serialize@/link</code>. should call this function before doing any actual serialization; if it returns <code>true</code>, the <code>serialize</code> implementation can immediately return <code>true</code>.
virtual bool addXMLStartTag(const OSMetaClassBase * object, const char * tagString)virtual
@function addXMLStartTag @abstract Appends an XML start tag to the XML stream. @param object The object being serialized. @param tagString The name of the XML tag to emit; for example, "string". @result <code>true</code> if an XML start tag for <code>tagString</code> is successfully added to the XML stream, <code>false</code> otherwise. @discussion This function emits the named tag, enclosed within a pair of angle brackets. A class that implements serialization should call this function with the name of the XML tag that best represents the serialized contents of the object. A limited number of tags are supported by the user-space I/O Kit library: <ul> <li>array</li> <li>dict</li> <li>integer</li> <li>key</li> <li>set</li> <li>string</li> </ul> A call to this function must be balanced with one to <code>@link addXMLEndTag addXMLEndTag@/link</code> using the same <code>tagString</code>.
virtual bool addXMLEndTag(const char * tagString)virtual
@function addXMLEndTag @abstract Appends an XML end tag to the XML stream. @param tagString The name of the XML tag to emit; for example, "string". @result <code>true</code> if an XML end tag for <code>tagString</code> is successfully added to the XML stream, <code>false</code> otherwise. @discussion This function emits the named tag, preceded by a slash character to indicate the closing of an entity, all enclosed within a pair of angle brackets. A call to this function must balance an earlier call to <code>@link addXMLStartTag addXMLStartTag@/link</code> using the same <code>tagString</code>.
virtual bool addChar(const char aChar)virtual
@function addChar @abstract Appends a single character to the XML stream. @param aChar The character to append to the XML stream. @result <code>true</code> if <code>char</code> is successfully added to the XML stream, <code>false</code> otherwise.
virtual bool addString(const char * cString)virtual
@function addString @abstract Appends a C string to the XML stream. @param cString The C string to append to the XML stream. @result <code>true</code> if <code>cString</code> is successfully added to the XML stream, <code>false</code> otherwise.
virtual bool initWithCapacity(unsigned int inCapacity)virtual
virtual unsigned int getLength() constvirtual
virtual unsigned int getCapacity() constvirtual
virtual unsigned int getCapacityIncrement() constvirtual
virtual unsigned int setCapacityIncrement(unsigned increment)virtual
virtual unsigned int ensureCapacity(unsigned int newCapacity)virtual
APPLE_KEXT_OVERRIDE
virtual void free()
virtual

typedefOSSerializerCallback

typedef bool (*)(void *, void *, OSSerialize *) OSSerializerCallback;

typedefOSSerializerBlock

typedef bool (^OSSerializerBlock)(OSSerialize * serializer)

classOSSerializer

: public OSObject
void *target
void *ref
OSSerializerCallbackcallback
static OSPtr<OSSerializer> forTarget(
	void * target,
	OSSerializerCallback callback,
	void * ref = NULL
)
static
static OSPtr<OSSerializer> withBlock(OSSerializerBlock callback)static
APPLE_KEXT_OVERRIDE
virtual void free(void)
virtual
APPLE_KEXT_OVERRIDE
virtual bool serialize(OSSerialize * serializer) const
virtual