ObjFW  Check-in [7d5e2ebb80]

Overview
Comment:Add +[elementWithFile:] to OFXMLElement.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7d5e2ebb80edddb71ba9d0c42d3e6f5c6b486c8301b0dc17ec6ac8917df4744b
User & Date: js on 2011-07-28 21:31:29
Other Links: manifest | tags
Context
2011-07-28
22:21
Don't create and release a pool in -[enumerateObjectsUsingBlock:]. check-in: 3b0699b790 user: js tags: trunk
21:31
Add +[elementWithFile:] to OFXMLElement. check-in: 7d5e2ebb80 user: js tags: trunk
20:50
Don't create and release a pool in -[enumerateObjectsUsingBlock:]. check-in: bfb7745f95 user: js tags: trunk
Changes

Modified src/OFXMLElement.h from [b36f7c7043] to [c82cae4634].

119
120
121
122
123
124
125









126
127
128
129
130
131
132
 * Parses the string and returns an OFXMLElement for it.
 *
 * \param string The string to parse
 * \return A new autoreleased OFXMLElement with the contents of the string
 */
+ elementWithXMLString: (OFString*)string;










/**
 * Initializes an already allocated OFXMLElement with the specified element
 * name.
 *
 * \param name The name for the element
 * \return An initialized OFXMLElement with the specified element name
 */







>
>
>
>
>
>
>
>
>







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
 * Parses the string and returns an OFXMLElement for it.
 *
 * \param string The string to parse
 * \return A new autoreleased OFXMLElement with the contents of the string
 */
+ elementWithXMLString: (OFString*)string;

/**
 * Parses the specified file and returns an OFXMLElement for it.
 *
 * \param path The path to the file
 * \return A new autoreleased OFXMLElement with the contents of the specified
 *	   file
 */
+ elementWithFile: (OFString*)path;

/**
 * Initializes an already allocated OFXMLElement with the specified element
 * name.
 *
 * \param name The name for the element
 * \return An initialized OFXMLElement with the specified element name
 */
211
212
213
214
215
216
217









218
219
220
221
222
223
224
 * Parses the string and initializes an already allocated OFXMLElement with it.
 *
 * \param string The string to parse
 * \return An initialized OFXMLElement with the contents of the string
 */
- initWithXMLString: (OFString*)string;










/**
 * \return The name of the element
 */
- (OFString*)name;

/**
 * \return The namespace of the element







>
>
>
>
>
>
>
>
>







220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
 * Parses the string and initializes an already allocated OFXMLElement with it.
 *
 * \param string The string to parse
 * \return An initialized OFXMLElement with the contents of the string
 */
- initWithXMLString: (OFString*)string;

/**
 * Parses the specified file and initializes an already allocated OFXMLElement
 * with it.
 *
 * \param path The path to the file
 * \return An initialized OFXMLElement with the contents of the specified file
 */
- initWithFile: (OFString*)path;

/**
 * \return The name of the element
 */
- (OFString*)name;

/**
 * \return The namespace of the element

Modified src/OFXMLElement.m from [62ec69347f] to [c0f22f99a1].

121
122
123
124
125
126
127





128
129
130
131
132
133
134
	return [[[self alloc] initWithElement: element] autorelease];
}

+ elementWithXMLString: (OFString*)string
{
	return [[[self alloc] initWithXMLString: string] autorelease];
}






- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];







>
>
>
>
>







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	return [[[self alloc] initWithElement: element] autorelease];
}

+ elementWithXMLString: (OFString*)string
{
	return [[[self alloc] initWithXMLString: string] autorelease];
}

+ elementWithFile: (OFString*)path
{
	return [[[self alloc] initWithFile: path] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
264
265
266
267
268
269
270







































271
272
273
274
275
276
277
	delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
	    autorelease];

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseString: string];








































	if (![parser finishedParsing])
		@throw [OFMalformedXMLException newWithClass: c
						      parser: parser];

	self = [delegate->element retain];








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
	delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
	    autorelease];

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseString: string];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException newWithClass: c
						      parser: parser];

	self = [delegate->element retain];

	@try {
		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithFile: (OFString*)path
{
	OFAutoreleasePool *pool;
	OFXMLParser *parser;
	OFXMLElementBuilder *builder;
	OFXMLElement_OFXMLElementBuilderDelegate *delegate;
	Class c;

	c = isa;
	[self release];

	pool = [[OFAutoreleasePool alloc] init];

	parser = [OFXMLParser parser];
	builder = [OFXMLElementBuilder elementBuilder];
	delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
	    autorelease];

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseFile: path];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException newWithClass: c
						      parser: parser];

	self = [delegate->element retain];