mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Added encodeDataObject: and decodeDataObject
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3622 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
669ee067b3
commit
df4f203ee5
3 changed files with 60 additions and 0 deletions
|
@ -950,6 +950,39 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
}
|
||||
}
|
||||
|
||||
- (NSData*) decodeDataObject
|
||||
{
|
||||
unsigned l;
|
||||
|
||||
(*dValImp)(self, dValSel, @encode(unsigned int), &l);
|
||||
if (l)
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
(*dValImp)(self, dValSel, @encode(unsigned char), &c);
|
||||
if (c == 0)
|
||||
{
|
||||
void *b;
|
||||
NSData *d;
|
||||
|
||||
b = NSZoneMalloc(zone, l);
|
||||
d = [[NSData allocWithZone: zone] initWithBytesNoCopy: b
|
||||
length: l
|
||||
fromZone: zone];
|
||||
[d autorelease];
|
||||
[self decodeArrayOfObjCType: @encode(unsigned char)
|
||||
count: l
|
||||
at: b];
|
||||
return d;
|
||||
}
|
||||
else
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Decoding data object with unknown type"];
|
||||
}
|
||||
else
|
||||
return [NSData data];
|
||||
}
|
||||
|
||||
/*
|
||||
* The [-decodeObject] method is implemented purely for performance -
|
||||
* It duplicates the code for handling objects in the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue