
/*
	Parse data as a property list
	Original Source: <http://cocoa.karelia.com/Foundation_Categories/NSData/Parse_data_as_a_pro.m>
	(See copyright notice at <http://cocoa.karelia.com>)
*/

/* Load up some data as a property list.  Similar to [NSDictionary dictionaryWithContentsOfFile:path] but uses text as the input.  Based on snippet of code courtesy of Ken Dyke; See "What is the easiest way to get an XML Plist into an NSDictionary?" on macosx-dev@omnigroup.com */

- (id)propertyListFromXMLWithOptions:(CFPropertyListMutabilityOptions)options
{
	CFPropertyListRef pList;
	CFStringRef errorString = nil;

	pList = CFPropertyListCreateFromXMLData(NULL, (CFDataRef)self, options, &errorString);
	if(errorString) {
NSLog(@"Error loading from Property List:%@",(NSString*)errorString);
		CFRelease(errorString);
	}
	return [(id)pList autorelease];
}

/*"	Return a property list from the data.  Functions similarly to #{[NSDictionary dictionaryWithContentsOfFile:path]}.
"*/

- (id)propertyListFromXML
{
	return [self propertyListFromXMLWithOptions:kCFPropertyListImmutable];
}

/*"	Return a mutable property list from the data.
"*/

- (id)mutablePropertyListFromXML
{
	return [self propertyListFromXMLWithOptions:kCFPropertyListMutableContainersAndLeaves];
}

