Tidy xml output format.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18466 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-01-24 06:51:18 +00:00
parent 325da251d2
commit fb301fc9f3
2 changed files with 136 additions and 146 deletions

View file

@ -3,6 +3,7 @@
* Source/NSKeyedArchiver.m:
* Source/NSKeyedUnarchiver.m:
Added NSPoint, NSRect, and NSSize coding methods.
* Source/NSMSoperamulti_test.m: Sort dictionary items in xml output
2004-01-23 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -1552,7 +1552,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
{
[dest appendBytes: "<real>" length: 6];
XString([obj stringValue], dest);
[dest appendBytes: "</real>" length: 7];
[dest appendBytes: "</real>\n" length: 8];
}
else if (x == NSPropertyListGNUStepFormat)
{
@ -1721,6 +1721,15 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
{
const char *iBaseString;
const char *iSizeString;
SEL objSel = @selector(objectForKey:);
IMP myObj = [obj methodForSelector: objSel];
unsigned i;
NSArray *keyArray = [obj allKeys];
unsigned numKeys = [keyArray count];
NSString *plists[numKeys];
NSString *keys[numKeys];
BOOL canCompare = YES;
Class lastClass = 0;
unsigned level = lev;
if (level*step < sizeof(indentStrings)/sizeof(id))
@ -1743,40 +1752,6 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
= indentStrings[sizeof(indentStrings)/sizeof(id)-1];
}
if (x == NSPropertyListXMLFormat_v1_0)
{
NSEnumerator *e;
id key;
[dest appendBytes: "<dict>\n" length: 7];
e = [obj keyEnumerator];
while ((key = [e nextObject]))
{
id val;
val = [obj objectForKey: key];
[dest appendBytes: iSizeString length: strlen(iSizeString)];
[dest appendBytes: "<key>" length: 5];
XString(key, dest);
[dest appendBytes: "</key>\n" length: 7];
[dest appendBytes: iSizeString length: strlen(iSizeString)];
OAppend(val, loc, level, step, x, dest);
}
[dest appendBytes: iBaseString length: strlen(iBaseString)];
[dest appendBytes: "</dict>\n" length: 8];
}
else
{
SEL objSel = @selector(objectForKey:);
IMP myObj = [obj methodForSelector: objSel];
unsigned i;
NSArray *keyArray = [obj allKeys];
unsigned numKeys = [keyArray count];
NSString *plists[numKeys];
NSString *keys[numKeys];
BOOL canCompare = YES;
Class lastClass = 0;
[keyArray getObjects: keys];
for (i = 0; i < numKeys; i++)
@ -1878,7 +1853,22 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
plists[i] = (*myObj)(obj, objSel, keys[i]);
}
if (loc == nil)
if (x == NSPropertyListXMLFormat_v1_0)
{
[dest appendBytes: "<dict>\n" length: 7];
for (i = 0; i < numKeys; i++)
{
[dest appendBytes: iSizeString length: strlen(iSizeString)];
[dest appendBytes: "<key>" length: 5];
XString(keys[i], dest);
[dest appendBytes: "</key>\n" length: 7];
[dest appendBytes: iSizeString length: strlen(iSizeString)];
OAppend(plists[i], loc, level, step, x, dest);
}
[dest appendBytes: iBaseString length: strlen(iBaseString)];
[dest appendBytes: "</dict>\n" length: 8];
}
else if (loc == nil)
{
[dest appendBytes: "{" length: 1];
for (i = 0; i < numKeys; i++)
@ -1905,7 +1895,6 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
[dest appendBytes: "}" length: 1];
}
}
}
else
{
if (x == NSPropertyListXMLFormat_v1_0)