Mercurial > projects > orange
comparison orange/serialization/archives/XMLArchive.d @ 30:9d1a8023bb89 experimental
Added IDs to every serialized value.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 21 Nov 2010 17:12:24 +0100 |
parents | c422ff6477dd |
children | c68d29967c9f |
comparison
equal
deleted
inserted
replaced
29:c422ff6477dd | 30:9d1a8023bb89 |
---|---|
271 private void internalArchiveEnum (T) (T value, string type, string key, Id id) | 271 private void internalArchiveEnum (T) (T value, string type, string key, Id id) |
272 { | 272 { |
273 lastElement.element(Tags.enumTag, toData(value)) | 273 lastElement.element(Tags.enumTag, toData(value)) |
274 .attribute(Attributes.typeAttribute, toData(type)) | 274 .attribute(Attributes.typeAttribute, toData(type)) |
275 .attribute(Attributes.baseTypeAttribute, toData(T.stringof)) | 275 .attribute(Attributes.baseTypeAttribute, toData(T.stringof)) |
276 .attribute(Attributes.keyAttribute, toData(key)); | 276 .attribute(Attributes.keyAttribute, toData(key)) |
277 .attribute(Attributes.idAttribute, toData(id)); | |
277 } | 278 } |
278 | 279 |
279 void archiveBaseClass (string type, string key, Id id) | 280 void archiveBaseClass (string type, string key, Id id) |
280 { | 281 { |
281 restore(lastElement) in { | 282 restore(lastElement) in { |
282 lastElement = lastElement.element(Tags.baseTag) | 283 lastElement = lastElement.element(Tags.baseTag) |
283 .attribute(Attributes.typeAttribute, toData(type)) | 284 .attribute(Attributes.typeAttribute, toData(type)) |
284 .attribute(Attributes.keyAttribute, toData(key)); | 285 .attribute(Attributes.keyAttribute, toData(key)) |
286 .attribute(Attributes.idAttribute, toData(id)); | |
285 }; | 287 }; |
286 } | 288 } |
287 | 289 |
288 void archiveNull (string type, string key) | 290 void archiveNull (string type, string key) |
289 { | 291 { |
322 | 324 |
323 void archivePointer (Id pointerId, Id pointeeId) | 325 void archivePointer (Id pointerId, Id pointeeId) |
324 { | 326 { |
325 if (auto pointerNode = getArchivedPointer(pointerId)) | 327 if (auto pointerNode = getArchivedPointer(pointerId)) |
326 { | 328 { |
327 pointerNode.parent.element(Tags.referenceTag, toData(pointeeId)). | 329 pointerNode.parent.element(Tags.pointerTag) |
328 attribute(Attributes.keyAttribute, toData(pointerNode.key)); | 330 .attribute(Attributes.keyAttribute, toData(pointerNode.key)) |
331 .attribute(Attributes.idAttribute, toData(pointerId)) | |
332 .element(Tags.referenceTag, toData(pointeeId)); | |
329 } | 333 } |
330 } | 334 } |
331 | 335 |
332 void archiveReference (string key, Id id) | 336 void archiveReference (string key, Id id) |
333 { | 337 { |
352 void archiveStruct (string type, string key, Id id, void delegate () dg) | 356 void archiveStruct (string type, string key, Id id, void delegate () dg) |
353 { | 357 { |
354 restore(lastElement) in { | 358 restore(lastElement) in { |
355 lastElement = lastElement.element(Tags.structTag) | 359 lastElement = lastElement.element(Tags.structTag) |
356 .attribute(Attributes.typeAttribute, toData(type)) | 360 .attribute(Attributes.typeAttribute, toData(type)) |
357 .attribute(Attributes.keyAttribute, toData(key)); | 361 .attribute(Attributes.keyAttribute, toData(key)) |
362 .attribute(Attributes.idAttribute, toData(id)); | |
358 | 363 |
359 dg(); | 364 dg(); |
360 }; | 365 }; |
361 } | 366 } |
362 | 367 |
363 void archiveTypedef (string type, string key, Id id, void delegate () dg) | 368 void archiveTypedef (string type, string key, Id id, void delegate () dg) |
364 { | 369 { |
365 restore(lastElement) in { | 370 restore(lastElement) in { |
366 lastElement = lastElement.element(Tags.typedefTag) | 371 lastElement = lastElement.element(Tags.typedefTag) |
367 .attribute(Attributes.typeAttribute, toData(type)) | 372 .attribute(Attributes.typeAttribute, toData(type)) |
368 .attribute(Attributes.keyAttribute, toData(key)); | 373 .attribute(Attributes.keyAttribute, toData(key)) |
374 .attribute(Attributes.idAttribute, toData(id)); | |
369 | 375 |
370 dg(); | 376 dg(); |
371 }; | 377 }; |
372 } | 378 } |
373 | 379 |
396 }; | 402 }; |
397 } | 403 } |
398 | 404 |
399 void archive (bool value, string key, Id id) | 405 void archive (bool value, string key, Id id) |
400 { | 406 { |
401 archivePrimitive(value, key); | 407 archivePrimitive(value, key, id); |
402 } | 408 } |
403 | 409 |
404 void archive (byte value, string key, Id id) | 410 void archive (byte value, string key, Id id) |
405 { | 411 { |
406 archivePrimitive(value, key); | 412 archivePrimitive(value, key, id); |
407 } | 413 } |
408 | 414 |
409 // currently not suppported by to!() | 415 //currently not suppported by to!() |
410 /*void archive (cdouble value, string key, Id id) | 416 /*void archive (cdouble value, string key, Id id) |
411 { | 417 { |
412 archivePrimitive(value, key); | 418 archivePrimitive(value, key, id); |
413 }*/ | 419 }*/ |
414 | 420 |
415 //currently not implemented but a reserved keyword | 421 //currently not implemented but a reserved keyword |
416 /*void archive (cent value, string key, Id id) | 422 /*void archive (cent value, string key, Id id) |
417 { | 423 { |
418 archivePrimitive(value, key); | 424 archivePrimitive(value, key, id); |
419 }*/ | 425 }*/ |
420 | 426 |
421 //currently not suppported by to!() | 427 //currently not suppported by to!() |
422 /*void archive (cfloat value, string key, Id id) | 428 /*void archive (cfloat value, string key, Id id) |
423 { | 429 { |
424 archivePrimitive(value, key); | 430 archivePrimitive(value, key, id); |
425 }*/ | 431 }*/ |
426 | 432 |
427 void archive (char value, string key, Id id) | 433 void archive (char value, string key, Id id) |
428 { | 434 { |
429 archivePrimitive(value, key); | 435 archivePrimitive(value, key, id); |
430 } | 436 } |
431 | 437 |
432 //currently not suppported by to!() | 438 //currently not suppported by to!() |
433 /*void archive (creal value, string key, Id id) | 439 /*void archive (creal value, string key, Id id) |
434 { | 440 { |
435 archivePrimitive(value, key); | 441 archivePrimitive(value, key, id); |
436 }*/ | 442 }*/ |
437 | 443 |
438 void archive (dchar value, string key, Id id) | 444 void archive (dchar value, string key, Id id) |
439 { | 445 { |
440 archivePrimitive(value, key); | 446 archivePrimitive(value, key, id); |
441 } | 447 } |
442 | 448 |
443 void archive (double value, string key, Id id) | 449 void archive (double value, string key, Id id) |
444 { | 450 { |
445 archivePrimitive(value, key); | 451 archivePrimitive(value, key, id); |
446 } | 452 } |
447 | 453 |
448 void archive (float value, string key, Id id) | 454 void archive (float value, string key, Id id) |
449 { | 455 { |
450 archivePrimitive(value, key); | 456 archivePrimitive(value, key, id); |
451 } | 457 } |
452 | 458 |
453 //currently not suppported by to!() | 459 //currently not suppported by to!() |
454 /*void archive (idouble value, string key, Id id) | 460 /*void archive (idouble value, string key, Id id) |
455 { | 461 { |
456 archivePrimitive(value, key); | 462 archivePrimitive(value, key, id); |
457 }*/ | 463 }*/ |
458 | 464 |
459 //currently not suppported by to!() | 465 //currently not suppported by to!() |
460 /*void archive (ifloat value, string key, Id id) | 466 /*void archive (ifloat value, string key, Id id) |
461 { | 467 { |
462 archivePrimitive(value, key); | 468 archivePrimitive(value, key, id); |
463 }*/ | 469 }*/ |
464 | 470 |
465 void archive (int value, string key, Id id) | 471 void archive (int value, string key, Id id) |
466 { | 472 { |
467 archivePrimitive(value, key); | 473 archivePrimitive(value, key, id); |
468 } | 474 } |
469 | 475 |
470 //currently not suppported by to!() | 476 //currently not suppported by to!() |
471 /*void archive (ireal value, string key, Id id) | 477 /*void archive (ireal value, string key, Id id) |
472 { | 478 { |
473 archivePrimitive(value, key); | 479 archivePrimitive(value, key, id); |
474 }*/ | 480 }*/ |
475 | 481 |
476 void archive (long value, string key, Id id) | 482 void archive (long value, string key, Id id) |
477 { | 483 { |
478 archivePrimitive(value, key); | 484 archivePrimitive(value, key, id); |
479 } | 485 } |
480 | 486 |
481 void archive (real value, string key, Id id) | 487 void archive (real value, string key, Id id) |
482 { | 488 { |
483 archivePrimitive(value, key); | 489 archivePrimitive(value, key, id); |
484 } | 490 } |
485 | 491 |
486 void archive (short value, string key, Id id) | 492 void archive (short value, string key, Id id) |
487 { | 493 { |
488 archivePrimitive(value, key); | 494 archivePrimitive(value, key, id); |
489 } | 495 } |
490 | 496 |
491 void archive (ubyte value, string key, Id id) | 497 void archive (ubyte value, string key, Id id) |
492 { | 498 { |
493 archivePrimitive(value, key); | 499 archivePrimitive(value, key, id); |
494 } | 500 } |
495 | 501 |
496 //currently not implemented but a reserved keyword | 502 //currently not implemented but a reserved keyword |
497 /*void archive (ucent value, string key, Id id) | 503 /*void archive (ucent value, string key, Id id) |
498 { | 504 { |
499 archivePrimitive(value, key); | 505 archivePrimitive(value, key, id); |
500 }*/ | 506 }*/ |
501 | 507 |
502 void archive (uint value, string key, Id id) | 508 void archive (uint value, string key, Id id) |
503 { | 509 { |
504 archivePrimitive(value, key); | 510 archivePrimitive(value, key, id); |
505 } | 511 } |
506 | 512 |
507 void archive (ulong value, string key, Id id) | 513 void archive (ulong value, string key, Id id) |
508 { | 514 { |
509 archivePrimitive(value, key); | 515 archivePrimitive(value, key, id); |
510 } | 516 } |
511 | 517 |
512 void archive (ushort value, string key, Id id) | 518 void archive (ushort value, string key, Id id) |
513 { | 519 { |
514 archivePrimitive(value, key); | 520 archivePrimitive(value, key, id); |
515 } | 521 } |
516 | 522 |
517 void archive (wchar value, string key, Id id) | 523 void archive (wchar value, string key, Id id) |
518 { | 524 { |
519 archivePrimitive(value, key); | 525 archivePrimitive(value, key, id); |
520 } | 526 } |
521 | 527 |
522 private void archivePrimitive (T) (T value, string key) | 528 private void archivePrimitive (T) (T value, string key, Id id) |
523 { | 529 { |
524 lastElement.element(toData(T.stringof), toData(value)) | 530 lastElement.element(toData(T.stringof), toData(value)) |
525 .attribute(Attributes.keyAttribute, toData(key)); | 531 .attribute(Attributes.keyAttribute, toData(key)) |
532 .attribute(Attributes.idAttribute, toData(id)); | |
526 } | 533 } |
527 | 534 |
528 Id unarchiveArray (string key, void delegate (size_t) dg) | 535 Id unarchiveArray (string key, void delegate (size_t) dg) |
529 { | 536 { |
530 return restore!(Id)(lastElement) in { | 537 return restore!(Id)(lastElement) in { |