ObjFW  Diff

Differences From Artifact [ae14e81241]:

To Artifact [4c4b122bc4]:


420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464





465





466















































467
468
469
470
471
472
473
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	if (attributes == nil)
		attributes = [[OFMutableArray alloc] init];

	/* FIXME: Prevent having it twice! */

	[attributes addObject: attr];
}

- (void)addAttributeWithName: (OFString*)name_
		 stringValue: (OFString*)value
{
	OFAutoreleasePool *pool;

	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: nil
						  stringValue: value]];
	[pool release];
}

- (void)addAttributeWithName: (OFString*)name_
		   namespace: (OFString*)ns_
		 stringValue: (OFString*)value
{
	OFAutoreleasePool *pool;

	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: ns_
						  stringValue: value]];
	[pool release];
}






/* TODO: Replace attribute */





/* TODO: Remove attribute */
















































- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns_
{
	if (name == nil || prefix == nil || [prefix isEqual: @""])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];







|
|
|





<
<
<
<
<
<
<
|
|
|
<



















>
>
>
>
>
|
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







420
421
422
423
424
425
426
427
428
429
430
431
432
433
434







435
436
437

438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	if (attributes == nil)
		attributes = [[OFMutableArray alloc] init];

	if ([self attributeForName: attr->name
			 namespace: attr->ns] == nil)
		[attributes addObject: attr];
}

- (void)addAttributeWithName: (OFString*)name_
		 stringValue: (OFString*)value
{







	[self addAttributeWithName: name_
			 namespace: nil
		       stringValue: value];

}

- (void)addAttributeWithName: (OFString*)name_
		   namespace: (OFString*)ns_
		 stringValue: (OFString*)value
{
	OFAutoreleasePool *pool;

	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: ns_
						  stringValue: value]];
	[pool release];
}

- (OFXMLAttribute*)attributeForName: (OFString*)attrname
{
	return [self attributeForName: attrname
			    namespace: nil];
}

- (OFXMLAttribute*)attributeForName: (OFString*)attrname
			  namespace: (OFString*)attrns
{
	OFXMLAttribute **attrs_c = [attributes cArray];
	size_t i, attrs_count = [attributes count];

	if (attrns != nil) {
		for (i = 0; i < attrs_count; i++)
			if ([attrs_c[i]->ns isEqual: attrns] &&
			    [attrs_c[i]->name isEqual: attrname])
				return attrs_c[i];
	} else {
		for (i = 0; i < attrs_count; i++)
			if (attrs_c[i]->ns == nil &&
			    [attrs_c[i]->name isEqual: attrname])
				return attrs_c[i];
	}

	return nil;
}

- (void)removeAttributeForName: (OFString*)attrname
{
	[self removeAttributeForName: attrname
			   namespace: nil];
}

- (void)removeAttributeForName: (OFString*)attrname
		     namespace: (OFString*)attrns
{
	OFXMLAttribute **attrs_c = [attributes cArray];
	size_t i, attrs_count = [attributes count];

	if (attrns != nil) {
		for (i = 0; i < attrs_count; i++) {
			if ([attrs_c[i]->ns isEqual: attrns] &&
			    [attrs_c[i]->name isEqual: attrname]) {
				[attributes removeObjectAtIndex: i];

				return;
			}
		}
	} else {
		for (i = 0; i < attrs_count; i++) {
			if (attrs_c[i]->ns == nil &&
			    [attrs_c[i]->name isEqual: attrname]) {
				[attributes removeObjectAtIndex: i];

				return;
			}
		}
	}
}

- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns_
{
	if (name == nil || prefix == nil || [prefix isEqual: @""])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];