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
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];
		OFXMLElement *secondsElement, *microsecondsElement;
		OFXMLAttribute *secondsAttribute, *microsecondsAttribute;

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

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

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

		seconds = (int64_t)[secondsElement decimalValue];
		microseconds = (uint32_t)[microsecondsElement decimalValue];
		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
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 *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;
	OFString *secondsString, *microsecondsString;

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

	secondsString = [OFString stringWithFormat: @"%" @PRId64, seconds];
	microsecondsString = [OFString stringWithFormat: @"%" @PRId64,
							 microseconds];
	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

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

	[element addChild:
	    [OFXMLElement elementWithName: @"seconds"
	[element retain];
	@try {
		[pool release];
				namespace: OF_SERIALIZATION_NS
			      stringValue: [OFString stringWithFormat:
					       @"%" @PRId64, seconds]]];
	[element addChild:
	} @finally {
		[element autorelease];
	    [OFXMLElement elementWithName: @"microseconds"
				namespace: OF_SERIALIZATION_NS
			      stringValue: [OFString stringWithFormat:
					       @"%" @PRIu32, microseconds]]];

	}
	[pool release];

	return element;
}

- (uint32_t)microsecond
{
	return microseconds;