Overview
Comment: | Add version to serialization and add serialization to more classes. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ace6f683f7bbe2ca7b5c2741ee600fda |
User & Date: | js on 2011-05-12 18:27:57 |
Other Links: | manifest | tags |
Context
2011-05-12
| ||
18:45 | Add -[localYear] to OFDate. check-in: 0a61ada030 user: js tags: trunk | |
18:27 | Add version to serialization and add serialization to more classes. check-in: ace6f683f7 user: js tags: trunk | |
13:14 |
Fix namespace handling in OFXMLElement. Won't be backported to 0.5 as this might break stuff. check-in: 3ab7ef17f6 user: js tags: trunk | |
Changes
Modified SERIALIZATION from [ce29dc838b] to [0e6d0b7c8b].
︙ | ︙ | |||
150 151 152 153 154 155 156 | (double)2.5 6.) Extension Type The extension type allows adding new objects to ObjFW serialization. The extension type has a parameter class= which specifies the class which should | > | | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | (double)2.5 6.) Extension Type The extension type allows adding new objects to ObjFW serialization. The extension type has a parameter class= which specifies the class which should handle deserialization and a version= parameter which specifies the version of the class serialization as a single integer. The extension type starts with a [ and ends with a ]. Inside those brackets can be arbitray basic types, which should be passed unmodified to the class for deserialization. If an implementation can't deserialize an extension type, it is required to error out. Other languages are allowed to parse extension types of classes which are in ObjFW, like OFXMLElement, but are by no means required to do so. Other languages may also add their own extension types, but are required to add the foreign= parameter and set it to their name, so other implementations don't try to deserialize it, but error out instead. Other implementations are allowed to serialize to ObjFW objects if they know them. For example, it might be desirable |
︙ | ︙ |
Modified src/OFDate.h from [501c2125ce] to [86c0fe3263].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" @class OFString; /** * \brief A class for storing, accessing and comparing dates. */ | > | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFSerialization.h" @class OFString; /** * \brief A class for storing, accessing and comparing dates. */ @interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization> { int64_t seconds; uint32_t microseconds; } /** * \brief Creates a new OFDate with the current date and time. |
︙ | ︙ |
Modified src/OFDate.m from [97a4e4b983] to [fed9345cd2].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <limits.h> #include <time.h> #include <sys/time.h> #import "OFDate.h" #import "OFString.h" #import "OFAutoreleasePool.h" #ifdef OF_THREADS # import "OFThread.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" | > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <limits.h> #include <time.h> #include <sys/time.h> #import "OFDate.h" #import "OFString.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OFAutoreleasePool.h" #ifdef OF_THREADS # import "OFThread.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ | |||
257 258 259 260 261 262 263 | } - copy { return [self retain]; } | | | | > > > > > > > > > > > > > > > > > > > | 259 260 261 262 263 264 265 266 267 268 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 | } - copy { return [self retain]; } - (of_comparison_result_t)compare: (id)object { OFDate *otherDate; if (![object isKindOfClass: [OFDate class]]) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; otherDate = (OFDate*)object; if (seconds < otherDate->seconds) return OF_ORDERED_ASCENDING; if (seconds > otherDate->seconds) return OF_ORDERED_DESCENDING; if (microseconds < otherDate->microseconds) return OF_ORDERED_ASCENDING; if (microseconds > otherDate->microseconds) return OF_ORDERED_DESCENDING; return OF_ORDERED_SAME; } - (OFString*)description { return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"]; } - (OFString*)stringBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFDictionary *dictionary = [OFDictionary dictionaryWithKeysAndObjects: @"seconds", [OFNumber numberWithInt64: seconds], @"microseconds", [OFNumber numberWithUInt32: microseconds], nil]; OFString *ret = [[OFString alloc] initWithFormat: @"(class=OFDate,version=0)<%@>", [dictionary stringBySerializing]]; @try { [pool release]; } @finally { [ret autorelease]; } return ret; } - (uint32_t)microsecond { return microseconds; } - (uint8_t)second |
︙ | ︙ |
Modified src/OFURL.m from [e8aceda7df] to [267c53672b].
︙ | ︙ | |||
530 531 532 533 534 535 536 | return [self string]; } - (OFString*)stringBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *ret = [[OFString alloc] | | | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | return [self string]; } - (OFString*)stringBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *ret = [[OFString alloc] initWithFormat: @"(class=OFURL,version=0)<%@>", [[self string] stringBySerializing]]; @try { [pool release]; } @finally { [ret autorelease]; } return ret; } @end |
Modified src/OFXMLAttribute.h from [dc66324635] to [a80691a45f].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" @class OFString; /** * \brief A representation of an attribute of an XML element as an object. */ | > | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFSerialization.h" @class OFString; /** * \brief A representation of an attribute of an XML element as an object. */ @interface OFXMLAttribute: OFObject <OFSerialization> { @public OFString *name; OFString *ns; OFString *stringValue; } |
︙ | ︙ |
Modified src/OFXMLAttribute.m from [1771d20c62] to [a0cfce89af].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * file. */ #include "config.h" #import "OFXMLAttribute.h" #import "OFString.h" #import "OFAutoreleasePool.h" @implementation OFXMLAttribute + attributeWithName: (OFString*)name namespace: (OFString*)ns stringValue: (OFString*)value { | > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #import "OFXMLAttribute.h" #import "OFString.h" #import "OFDictionary.h" #import "OFAutoreleasePool.h" @implementation OFXMLAttribute + attributeWithName: (OFString*)name namespace: (OFString*)ns stringValue: (OFString*)value { |
︙ | ︙ | |||
67 68 69 70 71 72 73 74 | return [[ns copy] autorelease]; } - (OFString*)stringValue { return [[stringValue copy] autorelease]; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | return [[ns copy] autorelease]; } - (OFString*)stringValue { return [[stringValue copy] autorelease]; } - (OFString*)stringBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMutableDictionary *dictionary = [OFMutableDictionary dictionary]; OFString *ret; if (name != nil) [dictionary setObject: name forKey: @"name"]; if (ns != nil) [dictionary setObject: ns forKey: @"namespace"]; if (stringValue != nil) [dictionary setObject: stringValue forKey: @"stringValue"]; dictionary->isa = [OFDictionary class]; ret = [[OFString alloc] initWithFormat: @"(class=OFXMLElement,version=0)<%@>", [dictionary stringBySerializing]]; @try { [pool release]; } @finally { [ret autorelease]; } return ret; } @end |
Modified src/OFXMLElement.m from [3e52b82e87] to [dfde4a28b8].
︙ | ︙ | |||
567 568 569 570 571 572 573 | { return [self XMLString]; } - (OFString*)stringBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | { return [self XMLString]; } - (OFString*)stringBySerializing { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMutableDictionary *dictionary = [OFMutableDictionary dictionary]; OFString *ret; if (name != nil) [dictionary setObject: name forKey: @"name"]; if (ns != nil) [dictionary setObject: ns forKey: @"namespace"]; if (defaultNamespace != nil) [dictionary setObject: defaultNamespace forKey: @"defaultNamespace"]; if (attributes != nil) [dictionary setObject: attributes forKey: @"attributes"]; if (namespaces != nil) [dictionary setObject: namespaces forKey: @"namespaces"]; if (children != nil) [dictionary setObject: children forKey: @"children"]; if (characters != nil) [dictionary setObject: characters forKey: @"characters"]; if (CDATA != nil) [dictionary setObject: CDATA forKey: @"CDATA"]; if (comment != nil) [dictionary setObject: comment forKey: @"comment"]; dictionary->isa = [OFDictionary class]; ret = [[OFString alloc] initWithFormat: @"(class=OFXMLElement,version=0)<%@>", [dictionary stringBySerializing]]; @try { [pool release]; } @finally { [ret autorelease]; } |
︙ | ︙ |