mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
* Headers/Foundation/NSXMLElement.h: Change _attributes to be
a NSMutableDictionary instead of an NSMutableArray. * Source/NSXMLElement.m: Change implementation of some methods to use an NSMutableDictionary instead of arrays. Initialize ivars in initializer. * Source/NSXMLPrivate.h: Remove redundant method. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34394 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6f2aee3252
commit
3014907a3a
4 changed files with 25 additions and 42 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2012-01-02 22:26-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
|
* Headers/Foundation/NSXMLElement.h: Change _attributes to be
|
||||||
|
a NSMutableDictionary instead of an NSMutableArray.
|
||||||
|
* Source/NSXMLElement.m: Change implementation of some methods
|
||||||
|
to use an NSMutableDictionary instead of arrays. Initialize
|
||||||
|
ivars in initializer.
|
||||||
|
* Source/NSXMLPrivate.h: Remove redundant method.
|
||||||
|
|
||||||
2012-01-02 Fred Kiefer <FredKiefer@gmx.de>
|
2012-01-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/GSSocketStream.m (-initWithInput:output:): Attempt to
|
* Source/GSSocketStream.m (-initWithInput:output:): Attempt to
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@class NSDictionary, NSEnumerator, NSMutableArray, NSMutableDictionary;
|
||||||
@class NSDictionary, NSEnumerator, NSMutableArray;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an XML element.<br />
|
* Represents an XML element.<br />
|
||||||
|
@ -42,14 +41,12 @@ extern "C" {
|
||||||
{
|
{
|
||||||
#if GS_EXPOSE(NSXMLElement)
|
#if GS_EXPOSE(NSXMLElement)
|
||||||
@protected
|
@protected
|
||||||
// NSString *_name;
|
NSMutableDictionary *_attributes;
|
||||||
NSMutableArray *_attributes;
|
|
||||||
NSMutableArray *_namespaces;
|
NSMutableArray *_namespaces;
|
||||||
NSMutableArray *_children;
|
NSMutableArray *_children;
|
||||||
BOOL _childrenHaveMutated;
|
BOOL _childrenHaveMutated;
|
||||||
NSString *_URI;
|
NSString *_URI;
|
||||||
NSInteger _prefixIndex;
|
NSInteger _prefixIndex;
|
||||||
NSString *_value;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,13 +48,20 @@
|
||||||
if ((self = [super initWithKind:NSXMLElementKind]) != nil)
|
if ((self = [super initWithKind:NSXMLElementKind]) != nil)
|
||||||
{
|
{
|
||||||
ASSIGN(_name, name);
|
ASSIGN(_name, name);
|
||||||
|
_attributes = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||||
|
_namespaces = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
|
_children = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
|
_URI = nil;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithName: (NSString*)name stringValue: (NSString*)string
|
- (id) initWithName: (NSString*)name stringValue: (NSString*)string
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
if([self initWithName: name URI: nil] != nil)
|
||||||
|
{
|
||||||
|
[self setObjectValue: string];
|
||||||
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,24 +85,13 @@
|
||||||
|
|
||||||
- (void) addAttribute: (NSXMLNode*)attribute
|
- (void) addAttribute: (NSXMLNode*)attribute
|
||||||
{
|
{
|
||||||
[_attributes addObject: attribute];
|
[_attributes setObject: attribute
|
||||||
|
forKey: [attribute name]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeAttributeForName: (NSString*)name
|
- (void) removeAttributeForName: (NSString*)name
|
||||||
{
|
{
|
||||||
NSEnumerator *en = [_attributes objectEnumerator];
|
[_attributes removeObjectForKey: name];
|
||||||
NSXMLNode *node = nil;
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
while ((node = [en nextObject]) != nil)
|
|
||||||
{
|
|
||||||
NSString *nodeName = [node name];
|
|
||||||
if ([nodeName isEqualToString: name])
|
|
||||||
{
|
|
||||||
[_attributes removeObjectAtIndex: index];
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAttributes: (NSArray*)attributes
|
- (void) setAttributes: (NSArray*)attributes
|
||||||
|
@ -111,35 +107,17 @@
|
||||||
|
|
||||||
- (void) setAttributesAsDictionary: (NSDictionary*)attributes
|
- (void) setAttributesAsDictionary: (NSDictionary*)attributes
|
||||||
{
|
{
|
||||||
NSEnumerator *ken = [attributes keyEnumerator];
|
ASSIGN(_attributes, [attributes mutableCopy]);
|
||||||
id key = nil;
|
|
||||||
while ((key = [ken nextObject]) != nil)
|
|
||||||
{
|
|
||||||
id value = [attributes objectForKey: key];
|
|
||||||
NSXMLNode *node = [NSXMLNode attributeWithName: key
|
|
||||||
stringValue: value];
|
|
||||||
[self addAttribute: node];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*) attributes
|
- (NSArray*) attributes
|
||||||
{
|
{
|
||||||
return _attributes;
|
return [_attributes allValues];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSXMLNode*) attributeForName: (NSString*)name
|
- (NSXMLNode*) attributeForName: (NSString*)name
|
||||||
{
|
{
|
||||||
NSEnumerator *enumerator = [[self attributes] objectEnumerator];
|
return [_attributes objectForKey: name];
|
||||||
NSXMLNode *attribute;
|
|
||||||
|
|
||||||
while ((attribute = [enumerator nextObject]) != nil)
|
|
||||||
{
|
|
||||||
if ([name isEqualToString: [attribute name]] == YES)
|
|
||||||
{
|
|
||||||
return attribute;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSXMLNode*) attributeForLocalName: (NSString*)localName
|
- (NSXMLNode*) attributeForLocalName: (NSString*)localName
|
||||||
|
|
|
@ -76,6 +76,5 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface NSXMLNode (Private)
|
@interface NSXMLNode (Private)
|
||||||
- (void) setName: (NSString *)name;
|
|
||||||
- (void) setParent: (NSXMLNode *)node;
|
- (void) setParent: (NSXMLNode *)node;
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue