mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
cleaned up some more things
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34507 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8772885b71
commit
a9e3ce01aa
3 changed files with 42 additions and 10 deletions
|
@ -59,7 +59,10 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
|
||||||
|
|
||||||
- (NSString*) characterEncoding
|
- (NSString*) characterEncoding
|
||||||
{
|
{
|
||||||
return [NSString stringWithUTF8String: (const char *)MY_DOC->encoding];
|
if (MY_DOC->encoding)
|
||||||
|
return [NSString stringWithUTF8String: (const char *)MY_DOC->encoding];
|
||||||
|
else
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSXMLDocumentContentKind) documentContentKind
|
- (NSXMLDocumentContentKind) documentContentKind
|
||||||
|
@ -108,7 +111,10 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
|
||||||
/* Create holder for internal instance variables so that we'll have
|
/* Create holder for internal instance variables so that we'll have
|
||||||
* all our ivars available rather than just those of the superclass.
|
* all our ivars available rather than just those of the superclass.
|
||||||
*/
|
*/
|
||||||
GS_CREATE_INTERNAL(NSXMLDocument)
|
xmlChar *version = (xmlChar *)"1.0";
|
||||||
|
GS_CREATE_INTERNAL(NSXMLDocument);
|
||||||
|
internal->node = xmlNewDoc(version);
|
||||||
|
MY_DOC->_private = (void *)self;
|
||||||
}
|
}
|
||||||
return [super initWithKind: kind options: theOptions];
|
return [super initWithKind: kind options: theOptions];
|
||||||
}
|
}
|
||||||
|
@ -226,7 +232,7 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
|
||||||
{
|
{
|
||||||
if ([version isEqualToString: @"1.0"] || [version isEqualToString: @"1.1"])
|
if ([version isEqualToString: @"1.0"] || [version isEqualToString: @"1.1"])
|
||||||
{
|
{
|
||||||
MY_DOC->version = [version UTF8String];
|
MY_DOC->version = XMLStringCopy(version);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -237,7 +243,10 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
|
||||||
|
|
||||||
- (NSString*) version
|
- (NSString*) version
|
||||||
{
|
{
|
||||||
return [NSString stringWithUTF8String: MY_DOC->version];
|
if (MY_DOC->version)
|
||||||
|
return StringFromXMLStringPtr(MY_DOC->version);
|
||||||
|
else
|
||||||
|
return @"1.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
|
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
|
||||||
|
|
|
@ -43,6 +43,7 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
|
||||||
|
|
||||||
- (void) _setNode: (void *)_anode
|
- (void) _setNode: (void *)_anode
|
||||||
{
|
{
|
||||||
|
((xmlNodePtr)_anode)->_private = self;
|
||||||
internal->node = _anode;
|
internal->node = _anode;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -234,12 +235,15 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
|
||||||
- (id) copyWithZone: (NSZone*)zone
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
id c = [[self class] allocWithZone: zone];
|
id c = [[self class] allocWithZone: zone];
|
||||||
|
xmlNodePtr newNode = xmlCopyNode([self _node], 1); // make a deep copy
|
||||||
|
|
||||||
c = [c initWithKind: internal->kind options: internal->options];
|
c = [c initWithKind: internal->kind options: internal->options];
|
||||||
[c setName: [self name]];
|
[c _setNode:newNode];
|
||||||
[c setURI: [self URI]];
|
|
||||||
[c setObjectValue: [self objectValue]];
|
// [c setName: [self name]];
|
||||||
[c setStringValue: [self stringValue]];
|
// [c setURI: [self URI]];
|
||||||
|
// [c setObjectValue: [self objectValue]];
|
||||||
|
// [c setStringValue: [self stringValue]];
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,29 @@
|
||||||
|
|
||||||
inline static unsigned char *XMLStringCopy(NSString *source)
|
inline static unsigned char *XMLStringCopy(NSString *source)
|
||||||
{
|
{
|
||||||
|
char *xmlstr;
|
||||||
unsigned int len = [source maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
|
unsigned int len = [source maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
|
||||||
unsigned char *xmlstr = malloc(len);
|
if (len == 0)
|
||||||
|
return NULL;
|
||||||
|
xmlstr = malloc(len);
|
||||||
[source getCString:xmlstr maxLength:len encoding:NSUTF8StringEncoding];
|
[source getCString:xmlstr maxLength:len encoding:NSUTF8StringEncoding];
|
||||||
return xmlstr;
|
return (unsigned char *)xmlstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static NSString*
|
||||||
|
StringFromXMLStringPtr(const unsigned char *bytes)
|
||||||
|
{
|
||||||
|
NSString *str;
|
||||||
|
unsigned int length;
|
||||||
|
|
||||||
|
if (bytes == NULL)
|
||||||
|
return @"";
|
||||||
|
|
||||||
|
length = strlen((char *)bytes);
|
||||||
|
str = [[NSString alloc] initWithBytes: bytes
|
||||||
|
length: length
|
||||||
|
encoding: NSUTF8StringEncoding];
|
||||||
|
return AUTORELEASE(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static NSString*
|
inline static NSString*
|
||||||
|
|
Loading…
Reference in a new issue