ObjFW  Diff

Differences From Artifact [914a225e3e]:

To Artifact [884edb1d64]:


246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *secondsElement, *microsecondsElement;

		if (![[element name] isEqual: @"object"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
		    ![[[element attributeForName: @"class"] stringValue]
		    isEqual: [self className]])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		secondsElement = [element elementForName: @"seconds"
					       namespace: OF_SERIALIZATION_NS];
		microsecondsElement = [element
		    elementForName: @"microseconds"
			 namespace: OF_SERIALIZATION_NS];

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

		seconds = (int64_t)[secondsElement decimalValue];
		microseconds = (uint32_t)[microsecondsElement decimalValue];

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








|

|
|
<
<



|
<
|
|
<

|



|
|







246
247
248
249
250
251
252
253
254
255
256


257
258
259
260

261
262

263
264
265
266
267
268
269
270
271
272
273
274
275
276

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLAttribute *secondsAttribute, *microsecondsAttribute;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		secondsAttribute = [element attributeForName: @"seconds"];

		microsecondsAttribute =
		    [element attributeForName: @"microseconds"];


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

		seconds = (int64_t)[secondsAttribute decimalValue];
		microseconds = (uint32_t)[microsecondsAttribute decimalValue];

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

342
343
344
345
346
347
348
349
350

351
352
353
354



355
356
357


358
359

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
- (OFString*)description
{
	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool;
	OFXMLElement *element;


	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];




	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];



	[element addChild:

	    [OFXMLElement elementWithName: @"seconds"
				namespace: OF_SERIALIZATION_NS
			      stringValue: [OFString stringWithFormat:
					       @"%" @PRId64, seconds]]];
	[element addChild:
	    [OFXMLElement elementWithName: @"microseconds"
				namespace: OF_SERIALIZATION_NS
			      stringValue: [OFString stringWithFormat:
					       @"%" @PRIu32, microseconds]]];

	[pool release];

	return element;
}

- (uint32_t)microsecond
{
	return microseconds;







|

>

|


>
>
>
|
|
|
>
>

|
>
|
<
<
|
|
<
<
<
<
|
<







338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363


364
365




366

367
368
369
370
371
372
373
- (OFString*)description
{
	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;
	OFString *secondsString, *microsecondsString;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];

	secondsString = [OFString stringWithFormat: @"%" @PRId64, seconds];
	microsecondsString = [OFString stringWithFormat: @"%" @PRId64,
							 microseconds];

	[element addAttributeWithName: @"seconds"
			  stringValue: secondsString];
	[element addAttributeWithName: @"microseconds"
			  stringValue: microsecondsString];

	[element retain];
	@try {
		[pool release];


	} @finally {
		[element autorelease];




	}


	return element;
}

- (uint32_t)microsecond
{
	return microseconds;