Overview
Comment: | New way for handling and storing XML attributes. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6f001b801649eb77a8e34783b49d7946 |
User & Date: | js on 2009-08-12 16:55:16 |
Other Links: | manifest | tags |
Context
2009-08-14
| ||
01:01 | Treat \n and \r as whitespaces in whitespace removing methods. check-in: a5aed6da30 user: js tags: trunk | |
2009-08-12
| ||
16:55 | New way for handling and storing XML attributes. check-in: 6f001b8016 user: js tags: trunk | |
15:37 | Rename +[name] and -[name] to +[className] and -[className]. check-in: ce8d36d5c4 user: js tags: trunk | |
Changes
Modified src/OFXMLElement.h from [1247541a3e] to [cc70c8e478].
︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | #import "OFObject.h" #import "OFString.h" #import "OFDictionary.h" #import "OFArray.h" extern int _OFXMLElement_reference; /** * The OFXMLAttribute represents an attribute of an XML element as an object. */ @interface OFXMLAttribute: OFObject { OFString *prefix; OFString *name; OFString *ns; OFString *value; } /** * \param name The name of the attribute * \param prefix The prefix of the attribute * \param ns The namespace of the attribute * \param value The string value of the attribute * \return A new autoreleased OFXMLAttribute with the specified parameters */ + attributeWithName: (OFString*)name prefix: (OFString*)prefix namespace: (OFString*)ns stringValue: (OFString*)value; /** * Initializes an already allocated OFXMLAttribute. * * \param name The name of the attribute * \param prefix The prefix of the attribute * \param ns The namespace of the attribute * \param value The string value of the attribute * \return An initialized OFXMLAttribute with the specified parameters */ - initWithName: (OFString*)name prefix: (OFString*)prefix namespace: (OFString*)ns stringValue: (OFString*)value; /** * \return The name of the attribute as an autoreleased OFString */ - (OFString*)name; /** * \return The prefix of the attribute as an autoreleased OFString */ - (OFString*)prefix; /** * \return The namespace of the attribute as an autoreleased OFString */ - (OFString*)namespace; /** * \return The string value of the attribute as an autoreleased OFString */ - (OFString*)stringValue; @end /** * The OFXMLElement represents an XML element as an object which can be * modified and converted back to XML again. */ @interface OFXMLElement: OFObject { OFString *name; |
︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | + + + + + + + | /** * \return A new autoreleased OFString representing the OFXMLElement as an * XML string */ - (OFString*)string; /** * Adds the specified attribute. * * \param attr The attribute to add */ - addAttribute: (OFXMLAttribute*)attr; /** * Adds the specified attribute with the specified value. * * \param name The name of the attribute * \param value The value of the attribute */ - addAttributeWithName: (OFString*)name |
︙ |
Modified src/OFXMLElement.m from [f1c60b4b45] to [12bad844a7].
︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #include <string.h> #import "OFXMLElement.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" int _OFXMLElement_reference; @implementation OFXMLAttribute + attributeWithName: (OFString*)name_ prefix: (OFString*)prefix_ namespace: (OFString*)ns_ stringValue: (OFString*)value_ { return [[[self alloc] initWithName: name_ prefix: prefix_ namespace: ns_ stringValue: value_] autorelease]; } - initWithName: (OFString*)name_ prefix: (OFString*)prefix_ namespace: (OFString*)ns_ stringValue: (OFString*)value_ { self = [super init]; name = [name_ copy]; prefix = [prefix_ copy]; ns = [ns_ copy]; value = [value_ copy]; return self; } - (void)dealloc { [name release]; [prefix release]; [ns release]; [value release]; [super dealloc]; } - (OFString*)name { return [[name copy] autorelease]; } - (OFString*)prefix { return [[prefix copy] autorelease]; } - (OFString*)namespace { return [[ns copy] autorelease]; } - (OFString*)stringValue { return [[value copy] autorelease]; } @end @implementation OFXMLElement + elementWithName: (OFString*)name_ { return [[[self alloc] initWithName: name_] autorelease]; } |
︙ | |||
60 61 62 63 64 65 66 | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | - + + - - + + - - - + - - + - - - - + + - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + - + - | return self; } - (OFString*)string { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; char *str_c; |
︙ | |||
161 162 163 164 165 166 167 | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | - + - - + + - - + + + + + + + + + + + + + + + + + + | } @finally { [self freeMemory: str_c]; } return ret; } |
︙ |
Modified src/OFXMLParser.h from [badfb4ea20] to [4198601055].
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | - - + | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" #import "OFString.h" |
︙ | |||
52 53 54 55 56 57 58 | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | - + + | OF_XMLPARSER_EXPECT_CLOSE, OF_XMLPARSER_EXPECT_SPACE_OR_CLOSE } state; OFString *cache; OFString *name; OFString *prefix; OFString *ns; |
︙ |
Modified src/OFXMLParser.m from [c9bc88e2c8] to [eb5533890d].
︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | + | [cache release]; [name release]; [prefix release]; [ns release]; [attrs release]; [attr_name release]; [attr_prefix release]; [previous release]; [super dealloc]; } - (id)delegate { |
︙ | |||
180 181 182 183 184 185 186 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | - - - - - - + - + + + + | [cache appendCString: buf + last withLength: len]; cache_c = [cache cString]; cache_len = [cache length]; if ((tmp = memchr(cache_c, ':', cache_len)) != NULL) { |
︙ | |||
244 245 246 247 248 249 250 | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - - - - - - + - + + + + | [cache appendCString: buf + last withLength: len]; cache_c = [cache cString]; cache_len = [cache length]; if ((tmp = memchr(cache_c, ':', cache_len)) != NULL) { |
︙ | |||
333 334 335 336 337 338 339 340 341 342 343 344 | 330 331 332 333 334 335 336 337 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 | + + + + + + + + + + + + + + + + - + + + + | i--; } break; /* Looking for attribute name */ case OF_XMLPARSER_IN_ATTR_NAME: if (buf[i] == '=') { const char *cache_c, *tmp; size_t cache_len; len = i - last; if (len > 0) [cache appendCString: buf + last withLength: len]; cache_c = [cache cString]; cache_len = [cache length]; if ((tmp = memchr(cache_c, ':', cache_len)) != NULL ) { attr_name = [[OFString alloc] initWithCString: tmp + 1 length: cache_len - (tmp - cache_c) - 1]; attr_prefix = [[OFString alloc] initWithCString: cache_c length: tmp - cache_c]; } else { |
︙ | |||
368 369 370 371 372 373 374 | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | - + - - - + + + + + + + + | len = i - last; if (len > 0) [cache appendCString: buf + last withLength: len]; if (attrs == nil) |
︙ |
Modified tests/OFXMLParser/OFXMLParser.m from [82a296dd2e] to [7476e2d4e0].
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | - + + + + - - + + - + - - - + + + + + - + - - - - + + + + - | @end @implementation ParserDelegate - (BOOL)xmlParser: (OFXMLParser*)parser didStartTagWithName: (OFString*)name prefix: (OFString*)prefix namespace: (OFString*)ns |
︙ | |||
78 79 80 81 82 83 84 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | - - + + + | return nil; } @end int main() { |
︙ |