/* indent:4  tabsize:8  font:fixed-width */


#import "Pasteboard-CardSet.h"


@implementation Pasteboard(CardSet)

/*---------------------------------------------------------------------------
|
|    - writeType:(const char *)dataType asObject:(id)anObject
|
|    returns: (id) self
|
|----------------------------------------------------------------------------
|
|    Perform gyrations necessary to archive an object to a stream and write 
|    the stream to the pasteboard
|
\----------------------------------------------------------------------------*/

- writeType:(const char *)dataType asObject:(id)anObject
{
    char *data;
    int length;

    data = NXWriteRootObjectToBuffer(anObject, &length);
    [self writeType:dataType data:data length:length];
    NXFreeObjectBuffer(data, length);
    return self;
}


/*---------------------------------------------------------------------------
|
|    - writeType:(const char *) dataType asObject:(id) anObject
|
|    returns: (id) self
|
|----------------------------------------------------------------------------
|
|    Perform gyrations necessary to convert a pasteboard data type into a 
|    stream and dearchive an object from it
|
\----------------------------------------------------------------------------*/

- readType:(const char *)dataType asObject:(id *)anObjectPtr
{
    char *data;
    int length;

    [self readType:dataType data:&data length:&length];
    *anObjectPtr = NXReadObjectFromBuffer(data, length);
    vm_deallocate(task_self(), (vm_address_t)data, length);
    return self;
}

@end
