mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Use base64 in gnustep property lists
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38953 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3f2fa9ddfe
commit
9aa5d4cd04
2 changed files with 33 additions and 2 deletions
|
@ -1970,12 +1970,18 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
|||
}
|
||||
else if ([obj isKindOfClass: NSDataClass])
|
||||
{
|
||||
if (x == NSPropertyListXMLFormat_v1_0)
|
||||
if (NSPropertyListXMLFormat_v1_0 == x)
|
||||
{
|
||||
[dest appendBytes: "<data>\n" length: 7];
|
||||
encodeBase64(obj, dest);
|
||||
[dest appendBytes: "</data>\n" length: 8];
|
||||
}
|
||||
else if (NSPropertyListGNUstepFormat == x)
|
||||
{
|
||||
[dest appendBytes: "<[" length: 2];
|
||||
encodeBase64(obj, dest);
|
||||
[dest appendBytes: "]>" length: 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned char *src;
|
||||
|
|
|
@ -78,6 +78,21 @@ test_parse_unparse_binary_old(id object)
|
|||
errorDescription: 0];
|
||||
return [u isEqual: object];
|
||||
}
|
||||
static BOOL
|
||||
test_parse_unparse_gnustep(id object)
|
||||
{
|
||||
NSPropertyListFormat format;
|
||||
NSData *d;
|
||||
id u;
|
||||
|
||||
d = [NSPropertyListSerialization dataFromPropertyList: object
|
||||
format: NSPropertyListGNUstepFormat errorDescription: 0];
|
||||
u = [NSPropertyListSerialization propertyListFromData: d
|
||||
mutabilityOption: NSPropertyListImmutable
|
||||
format: &format
|
||||
errorDescription: 0];
|
||||
return [u isEqual: object];
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
|
@ -86,7 +101,7 @@ int main()
|
|||
int i;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
|
@ -106,6 +121,13 @@ int main()
|
|||
func = test_parse_unparse_openstep;
|
||||
NSLog(@"test OpenStep");
|
||||
break;
|
||||
case 4:
|
||||
#if defined(GNUSTEP_BASE_LIBRARY)
|
||||
func = test_parse_unparse_gnustep;
|
||||
NSLog(@"test GNUStep text");
|
||||
#else
|
||||
func = 0;
|
||||
#endif
|
||||
case 5:
|
||||
#if defined(GNUSTEP_BASE_LIBRARY)
|
||||
func = test_parse_unparse_binary_old;
|
||||
|
@ -121,6 +143,9 @@ int main()
|
|||
PASS(func(@"ariosto"),
|
||||
"We can generate a property list from a string");
|
||||
|
||||
PASS(func([@"ariosto" dataUsingEncoding: NSASCIIStringEncoding]),
|
||||
"We can generate a property list from data");
|
||||
|
||||
PASS(func([NSArray array]),
|
||||
"We can generate a property list from an empty array");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue