ObjFW  Diff

Differences From Artifact [61f052da6e]:

To Artifact [8ca104aaaa]:

  • File src/OFXMLElement.m — part of check-in [24ecf55297] at 2009-06-29 12:33:59 on branch trunk — Changes to OFDictionary, OFIterator and OFList - see details.

    OFDictionary:
    * More optimized way to internally store the data.
    * Faster resizing of dictionaries (no rehashing anymore).

    OFIterator:
    * Return a key/object pair rather than first the key and then the
    object.

    OFList:
    * Support for list objects with a different size so you can have your
    own list object structs. (user: js, size: 5161) [annotate] [blame] [check-ins using]


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

74

75
76

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

98
99
100
101
102
103
104

105
106
107
108
109
110
111

- (OFString*)string
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	char *str_c;
	size_t len, i, j;
	OFString *ret, *tmp;
	OFIterator *iter;

	len = [name length] + 4;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	*str_c = '<';
	memcpy(str_c + 1, [name cString], [name length]);
	i = [name length] + 1;

	/* Attributes */

	iter = [attrs iterator];

	for (;;) {
		OFString *key, *val;


		key = [iter nextObject];
		val = [iter nextObject];

		if (key == nil || val == nil)
			break;

		tmp = [val stringByXMLEscaping];

		len += [key length] + [tmp length] + 4;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
			[self freeMemory: str_c];
			@throw e;
		}

		str_c[i++] = ' ';
		memcpy(str_c + i, [key cString], [key length]);
		i += [key length];

		str_c[i++] = '=';
		str_c[i++] = '\'';
		memcpy(str_c + i, [tmp cString], [tmp length]);
		i += [tmp length];
		str_c[i++] = '\'';

		[pool releaseObjects];

	}

	/* Childen */
	if (stringval != nil || children != nil) {
		if (stringval != nil)
			tmp = [stringval stringByXMLEscaping];
		else if (children != nil) {







<










>
|
>
|
<
>

|
<

|
|

|

|
|
|
|
|
|
|
|

|
|
|
>
|
|
|
|
|

|
>







56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76

77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

- (OFString*)string
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	char *str_c;
	size_t len, i, j;
	OFString *ret, *tmp;


	len = [name length] + 4;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	*str_c = '<';
	memcpy(str_c + 1, [name cString], [name length]);
	i = [name length] + 1;

	/* Attributes */
	if (attrs != nil) {
		OFIterator *iter = [attrs iterator];

		for (;;) {

			of_iterator_pair_t pair;

			pair = [iter nextKeyObjectPair];


			if (pair.key == nil || pair.object == nil)
				break;

			tmp = [pair.object stringByXMLEscaping];

			len += [pair.key length] + [tmp length] + 4;
			@try {
				str_c = [self resizeMemory: str_c
						    toSize: len];
			} @catch (OFException *e) {
				[self freeMemory: str_c];
				@throw e;
			}

			str_c[i++] = ' ';
			memcpy(str_c + i, [pair.key cString],
			    [pair.key length]);
			i += [pair.key length];
			str_c[i++] = '=';
			str_c[i++] = '\'';
			memcpy(str_c + i, [tmp cString], [tmp length]);
			i += [tmp length];
			str_c[i++] = '\'';

			[pool releaseObjects];
		}
	}

	/* Childen */
	if (stringval != nil || children != nil) {
		if (stringval != nil)
			tmp = [stringval stringByXMLEscaping];
		else if (children != nil) {