PageRenderTime 31ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/FSKit/Source/Common/enunciate/prod/reservation.m

http://fskit.googlecode.com/
Objective C | 2536 lines | 1368 code | 340 blank | 828 comment | 226 complexity | 7066d686f659256214dee0a9adbfdf3e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #import <reservation.h>
  2. /**
  3. * Enunciate-specific C functions.
  4. */
  5. #ifndef ENUNCIATE_C_UTILITIES
  6. #define ENUNCIATE_C_UTILITIES
  7. /*******************xml utilities************************************/
  8. static int xmlTextReaderAdvanceToNextStartOrEndElement(xmlTextReaderPtr reader) {
  9. int status = xmlTextReaderRead(reader);
  10. while (status && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT && xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) {
  11. status = xmlTextReaderRead(reader);
  12. }
  13. return status;
  14. }
  15. static int xmlTextReaderSkipElement(xmlTextReaderPtr reader) {
  16. int status = xmlTextReaderNext(reader);
  17. while (status && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT && xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) {
  18. status = xmlTextReaderRead(reader);
  19. }
  20. return status;
  21. }
  22. static xmlChar *xmlTextReaderReadEntireNodeValue(xmlTextReaderPtr reader) {
  23. xmlChar *buffer = calloc(1, sizeof(xmlChar));
  24. const xmlChar *snippet;
  25. int status;
  26. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ATTRIBUTE) {
  27. return xmlTextReaderValue(reader);
  28. }
  29. else if (xmlTextReaderIsEmptyElement(reader) == 0) {
  30. status = xmlTextReaderRead(reader);
  31. while (status && (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT || xmlTextReaderNodeType(reader) == XML_READER_TYPE_CDATA || xmlTextReaderNodeType(reader) == XML_READER_TYPE_ENTITY_REFERENCE)) {
  32. snippet = xmlTextReaderConstValue(reader);
  33. buffer = realloc(buffer, (xmlStrlen(buffer) + xmlStrlen(snippet) + 1) * sizeof(xmlChar));
  34. xmlStrcat(buffer, snippet);
  35. status = xmlTextReaderRead(reader);
  36. }
  37. }
  38. return buffer;
  39. }
  40. /*******************base 64 utilities************************************/
  41. /*
  42. * Base64 Translation Table as described in RFC1113.
  43. *
  44. * This code was graciously ripped from http://base64.sourceforge.net
  45. */
  46. static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  47. /*
  48. * Base64 Translation Table to decode (created by author)
  49. *
  50. * This code was graciously ripped from http://base64.sourceforge.net
  51. */
  52. static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
  53. /*
  54. * encode 3 8-bit binary bytes as 4 '6-bit' characters
  55. *
  56. * This code was graciously ripped from http://base64.sourceforge.net
  57. *
  58. * @param in the block to encode
  59. * @param out the block to encode to
  60. * @param len the length of the 'in' block.
  61. */
  62. static void _encode_base64_block(unsigned char in[3], unsigned char out[4], int len) {
  63. out[0] = cb64[ in[0] >> 2 ];
  64. out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
  65. out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
  66. out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
  67. }
  68. /*
  69. * decode 4 '6-bit' characters into 3 8-bit binary bytes
  70. *
  71. * This code was graciously ripped from http://base64.sourceforge.net
  72. */
  73. static void _decode_base64_block( unsigned char in[4], unsigned char out[3] )
  74. {
  75. out[ 0 ] = (unsigned char ) (in[0] << 2 | in[1] >> 4);
  76. out[ 1 ] = (unsigned char ) (in[1] << 4 | in[2] >> 2);
  77. out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | in[3]);
  78. }
  79. /*
  80. * base64 encode a stream adding padding and line breaks as per spec.
  81. *
  82. * This code was graciously ripped from http://base64.sourceforge.net
  83. *
  84. * @param instream The stream to encode.
  85. * @param insize The size of the stream to encode.
  86. * @return The encoded string.
  87. */
  88. xmlChar *_encode_base64(unsigned char *instream, int insize) {
  89. unsigned char in[3];
  90. unsigned char out[4];
  91. xmlChar *encoded;
  92. int i, in_index = 0, out_index = 0, blocklen;
  93. if (insize == 0) {
  94. return BAD_CAST "\0";
  95. }
  96. encoded = calloc(((insize / 3) * 4) + 10, sizeof(xmlChar));
  97. while (in_index <= insize) {
  98. blocklen = 0;
  99. for (i = 0; i < 3; i++) {
  100. in[i] = instream[in_index++];
  101. if (in_index <= insize) {
  102. blocklen++;
  103. }
  104. else {
  105. in[i] = 0;
  106. }
  107. }
  108. if (blocklen) {
  109. _encode_base64_block(in, out, blocklen);
  110. for( i = 0; i < 4; i++ ) {
  111. encoded[out_index++] = out[i];
  112. }
  113. }
  114. }
  115. return encoded;
  116. }
  117. /*
  118. * Decode a base64 encoded stream discarding padding, line breaks and noise
  119. *
  120. * This code was graciously ripped from http://base64.sourceforge.net
  121. *
  122. * @param invalue The string to decode.
  123. * @param outsize Holder for the length of the returned data.
  124. * @return The decoded data.
  125. */
  126. unsigned char *_decode_base64( const xmlChar *invalue, int *outsize ) {
  127. xmlChar in[4];
  128. unsigned char out[3], v;
  129. int i, in_index = 0, out_index = 0, blocklen;
  130. unsigned char *outstream;
  131. if (invalue == NULL) {
  132. return NULL;
  133. }
  134. outstream = calloc(((xmlStrlen(invalue) / 4) * 3) + 1, sizeof(unsigned char));
  135. while (invalue[in_index] != '\0') {
  136. for (blocklen = 0, i = 0; i < 4 && invalue[in_index]; i++) {
  137. v = 0;
  138. while (invalue[in_index] != '\0' && v == 0) {
  139. v = (unsigned char) invalue[in_index++];
  140. v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]);
  141. if (v) {
  142. v = (unsigned char) ((v == '$') ? 0 : v - 61);
  143. }
  144. }
  145. if (invalue[in_index] != '\0') {
  146. blocklen++;
  147. if (v) {
  148. in[i] = (unsigned char) (v - 1);
  149. }
  150. }
  151. else {
  152. in[i] = 0;
  153. }
  154. }
  155. if (blocklen) {
  156. _decode_base64_block( in, out );
  157. for( i = 0; i < blocklen - 1; i++ ) {
  158. outstream[out_index++] = out[i];
  159. }
  160. }
  161. }
  162. if (outsize != NULL) {
  163. *outsize = out_index;
  164. }
  165. return outstream;
  166. }
  167. #endif /* ENUNCIATE_C_UTILITIES */
  168. #ifndef ENUNCIATE_OBJC_CLASSES
  169. #define ENUNCIATE_OBJC_CLASSES
  170. /**
  171. * Protocol defining a JAXB (see https://jaxb.dev.java.net/) type.
  172. */
  173. @protocol JAXBType
  174. /**
  175. * Read an XML type from an XML reader.
  176. *
  177. * @param reader The reader.
  178. * @return An instance of the object defining the JAXB type.
  179. */
  180. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader;
  181. /**
  182. * Initialize the object with an XML reader.
  183. *
  184. * @param reader The XML reader from which to initialize the values of this type.
  185. */
  186. - (id) initWithReader: (xmlTextReaderPtr) reader;
  187. /**
  188. * Write this instance of a JAXB type to a writer.
  189. *
  190. * @param writer The writer.
  191. */
  192. - (void) writeXMLType: (xmlTextWriterPtr) writer;
  193. @end /*protocol JAXBType*/
  194. /**
  195. * Protocol defining a JAXB (see https://jaxb.dev.java.net/) element.
  196. */
  197. @protocol JAXBElement
  198. /**
  199. * Read the XML element from an XML reader. It is assumed
  200. * that the reader is pointing at the start element (be careful
  201. * that it's not still pointing to the XML document).
  202. *
  203. * @param reader The reader.
  204. * @return An instance of the object defining the JAXB element.
  205. */
  206. + (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader;
  207. /**
  208. * Write this instance of a JAXB element to a writer.
  209. *
  210. * @param writer The writer.
  211. */
  212. - (void) writeXMLElement: (xmlTextWriterPtr) writer;
  213. /**
  214. * Write this instance of a JAXB element to a writer.
  215. *
  216. * @param writer The writer.
  217. * @param writeNs Whether to write the namespaces for this element to the xml writer.
  218. */
  219. - (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs;
  220. @end /*protocol JAXBElement*/
  221. /**
  222. * Protocol defining methods for events that occur
  223. * when reading/parsing XML. Intended for internal
  224. * use only.
  225. */
  226. @protocol JAXBReading
  227. /**
  228. * Method for reading an attribute.
  229. *
  230. * @param reader The reader pointing to the attribute.
  231. * @return Whether the attribute was read.
  232. */
  233. - (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader;
  234. /**
  235. * Method for reading the value of an element.
  236. *
  237. * @param reader The reader pointing to the element containing a value.
  238. * @return Whether the value was read.
  239. */
  240. - (BOOL) readJAXBValue: (xmlTextReaderPtr) reader;
  241. /**
  242. * Method for reading a child element. If (and only if) the child
  243. * element was handled, the element in the reader should be
  244. * "consumed" and the reader will be pointing to the end element.
  245. *
  246. * @param reader The reader pointing to the child element.
  247. * @return Whether the child element was read.
  248. */
  249. - (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader;
  250. /**
  251. * Method for reading an unknown attribute.
  252. *
  253. * @param reader The reader pointing to the unknown attribute.
  254. * @return Whether the attribute was read.
  255. */
  256. - (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader;
  257. /**
  258. * Method for reading an unknown child element. Implementations
  259. * must be responsible for "consuming" the child element.
  260. *
  261. * @param reader The reader pointing to the unknown child element.
  262. * @return The status of the reader after having consumed the unknown child element.
  263. */
  264. - (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader;
  265. @end /*protocol JAXBReading*/
  266. /**
  267. * Protocol defining methods for events that occur
  268. * when writing XML. Intended for internal
  269. * use only.
  270. */
  271. @protocol JAXBWriting
  272. /**
  273. * Method for writing the attributes.
  274. *
  275. * @param writer The writer.
  276. */
  277. - (void) writeJAXBAttributes: (xmlTextWriterPtr) writer;
  278. /**
  279. * Method for writing the element value.
  280. *
  281. * @param writer The writer.
  282. */
  283. - (void) writeJAXBValue: (xmlTextWriterPtr) writer;
  284. /**
  285. * Method for writing the child elements.
  286. *
  287. * @param writer The writer.
  288. */
  289. - (void) writeJAXBChildElements: (xmlTextWriterPtr) writer;
  290. @end /*protocol JAXBWriting*/
  291. /**
  292. * Declaration of the JAXB type, element, events for a base object.
  293. */
  294. @interface NSObject (JAXB) <JAXBType, JAXBElement, JAXBReading, JAXBWriting>
  295. @end
  296. /**
  297. * Implementation of the JAXB type, element, events for a base object.
  298. */
  299. @implementation NSObject (JAXB)
  300. /**
  301. * Read the XML type from the reader; an instance of NSXMLElement.
  302. *
  303. * @param reader The reader.
  304. * @return An instance of NSXMLElement
  305. */
  306. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  307. {
  308. return [JAXBBasicXMLNode readXMLType: reader];
  309. }
  310. /**
  311. * Read an XML type from an XML reader into an existing instance.
  312. *
  313. * @param reader The reader.
  314. * @param existing The existing instance into which to read values.
  315. */
  316. - (id) initWithReader: (xmlTextReaderPtr) reader
  317. {
  318. int status, depth;
  319. if ((self = [self init])) {
  320. if (xmlTextReaderHasAttributes(reader)) {
  321. while (xmlTextReaderMoveToNextAttribute(reader)) {
  322. if ([self readJAXBAttribute: reader] == NO) {
  323. [self readUnknownJAXBAttribute: reader];
  324. }
  325. }
  326. status = xmlTextReaderMoveToElement(reader);
  327. if (!status) {
  328. //panic: unable to return to the element node.
  329. [NSException raise: @"XMLReadError"
  330. format: @"Error moving back to element position from attributes."];
  331. }
  332. }
  333. if ([self readJAXBValue: reader] == NO) {
  334. //no value handled; attempt to process child elements
  335. if (xmlTextReaderIsEmptyElement(reader) == 0) {
  336. depth = xmlTextReaderDepth(reader);//track the depth.
  337. status = xmlTextReaderAdvanceToNextStartOrEndElement(reader);
  338. while (xmlTextReaderDepth(reader) > depth) {
  339. if (status < 1) {
  340. //panic: XML read error.
  341. [NSException raise: @"XMLReadError"
  342. format: @"Error handling a child element."];
  343. }
  344. else if ([self readJAXBChildElement: reader]) {
  345. status = xmlTextReaderAdvanceToNextStartOrEndElement(reader);
  346. }
  347. else {
  348. status = [self readUnknownJAXBChildElement: reader];
  349. }
  350. }
  351. }
  352. }
  353. }
  354. return self;
  355. }
  356. /**
  357. * Write the XML type value of this object to the writer.
  358. *
  359. * @param writer The writer.
  360. */
  361. - (void) writeXMLType: (xmlTextWriterPtr) writer
  362. {
  363. [self writeJAXBAttributes: writer];
  364. [self writeJAXBValue: writer];
  365. [self writeJAXBChildElements: writer];
  366. }
  367. /**
  368. * Read the XML element from the reader; an instance of NSXMLElement.
  369. *
  370. * @param reader The reader.
  371. * @return An instance of NSXMLElement
  372. */
  373. + (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader
  374. {
  375. return (id<JAXBElement>) [JAXBBasicXMLNode readXMLType: reader];
  376. }
  377. /**
  378. * No op; root objects don't have an element name/namespace. Subclasses must override.
  379. *
  380. * @param writer The writer.
  381. */
  382. - (void) writeXMLElement: (xmlTextWriterPtr) writer
  383. {
  384. //no-op
  385. }
  386. /**
  387. * No op; root objects don't have an element name/namespace. Subclasses must override.
  388. *
  389. * @param writer The writer.
  390. * @param writeNs Ignored.
  391. */
  392. - (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs
  393. {
  394. //no-op
  395. }
  396. /**
  397. * No-op; base objects do not handle any attributes.
  398. *
  399. * @param reader The reader pointing to the attribute.
  400. * @return NO
  401. */
  402. - (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader
  403. {
  404. return NO;
  405. }
  406. /**
  407. * No-op; base objects do not handle any values.
  408. *
  409. * @param reader The reader pointing to the element containing a value.
  410. * @return NO
  411. */
  412. - (BOOL) readJAXBValue: (xmlTextReaderPtr) reader
  413. {
  414. return NO;
  415. }
  416. /**
  417. * No-op; base objects do not handle any child elements.
  418. *
  419. * @param reader The reader pointing to the child element.
  420. * @return NO
  421. */
  422. - (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader
  423. {
  424. return NO;
  425. }
  426. /**
  427. * No-op; base objects do not handle any attributes.
  428. *
  429. * @param reader The reader pointing to the unknown attribute.
  430. */
  431. - (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader
  432. {
  433. }
  434. /**
  435. * Just skips the unknown element; base objects do not handle any child elements.
  436. *
  437. * @param reader The reader pointing to the unknown child element.
  438. * @return The status of the reader after skipping the unknown child element.
  439. */
  440. - (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader
  441. {
  442. return xmlTextReaderSkipElement(reader);
  443. }
  444. /**
  445. * No-op; base objects have no attributes.
  446. *
  447. * @param writer The writer.
  448. */
  449. - (void) writeJAXBAttributes: (xmlTextWriterPtr) writer
  450. {
  451. //no-op.
  452. }
  453. /**
  454. * No-op; base objects have no element value.
  455. *
  456. * @param writer The writer.
  457. */
  458. - (void) writeJAXBValue: (xmlTextWriterPtr) writer
  459. {
  460. //no-op.
  461. }
  462. /**
  463. * No-op; base objects have no child elements.
  464. *
  465. * @param writer The writer.
  466. */
  467. - (void) writeJAXBChildElements: (xmlTextWriterPtr) writer
  468. {
  469. //no-op.
  470. }
  471. @end /*NSObject (JAXB)*/
  472. /**
  473. * Implementation of the JAXB type, element for an xml element.
  474. */
  475. @implementation JAXBBasicXMLNode
  476. /**
  477. * Accessor for the (local) name of the XML node.
  478. *
  479. * @return The (local) name of the XML node.
  480. */
  481. - (NSString *) name
  482. {
  483. return _name;
  484. }
  485. /**
  486. * Accessor for the (local) name of the XML node.
  487. *
  488. * @param newName The (local) name of the XML node.
  489. */
  490. - (void) setName: (NSString *) newName
  491. {
  492. [newName retain];
  493. [_name release];
  494. _name = newName;
  495. }
  496. /**
  497. * Accessor for the namespace of the XML node.
  498. *
  499. * @return The namespace of the XML node.
  500. */
  501. - (NSString *) ns
  502. {
  503. return _ns;
  504. }
  505. /**
  506. * Accessor for the namespace of the XML node.
  507. *
  508. * @param newNs The namespace of the XML node.
  509. */
  510. - (void) setNs: (NSString *) newNs
  511. {
  512. [newNs retain];
  513. [_ns release];
  514. _ns = newNs;
  515. }
  516. /**
  517. * Accessor for the namespace prefix of the XML node.
  518. *
  519. * @return The namespace prefix of the XML node.
  520. */
  521. - (NSString *) prefix
  522. {
  523. return _prefix;
  524. }
  525. /**
  526. * Accessor for the namespace prefix of the XML node.
  527. *
  528. * @param newPrefix The namespace prefix of the XML node.
  529. */
  530. - (void) setPrefix: (NSString *) newPrefix
  531. {
  532. [newPrefix retain];
  533. [_prefix release];
  534. _prefix = newPrefix;
  535. }
  536. /**
  537. * Accessor for the value of the XML node.
  538. *
  539. * @return The value of the XML node.
  540. */
  541. - (NSString *) value
  542. {
  543. return _value;
  544. }
  545. /**
  546. * Accessor for the value of the XML node.
  547. *
  548. * @param newValue The value of the XML node.
  549. */
  550. - (void) setValue: (NSString *) newValue
  551. {
  552. [newValue retain];
  553. [_value release];
  554. _value = newValue;
  555. }
  556. /**
  557. * Accessor for the child elements of the XML node.
  558. *
  559. * @return The child elements of the XML node.
  560. */
  561. - (NSArray *) childElements
  562. {
  563. return _childElements;
  564. }
  565. /**
  566. * Accessor for the child elements of the XML node.
  567. *
  568. * @param newValue The child elements of the XML node.
  569. */
  570. - (void) setChildElements: (NSArray *) newChildElements
  571. {
  572. [newChildElements retain];
  573. [_childElements release];
  574. _childElements = newChildElements;
  575. }
  576. /**
  577. * Accessor for the attributes of the XML node.
  578. *
  579. * @return The attributes of the XML node.
  580. */
  581. - (NSArray *) attributes
  582. {
  583. return _attributes;
  584. }
  585. /**
  586. * Accessor for the attributes of the XML node.
  587. *
  588. * @param newAttributes The attributes of the XML node.
  589. */
  590. - (void) setAttributes: (NSArray *) newAttributes
  591. {
  592. [newAttributes retain];
  593. [_attributes release];
  594. _attributes = newAttributes;
  595. }
  596. - (void) dealloc {
  597. [self setName: nil];
  598. [self setNs: nil];
  599. [self setPrefix: nil];
  600. [self setValue: nil];
  601. [self setChildElements: nil];
  602. [self setAttributes: nil];
  603. [super dealloc];
  604. }
  605. @end /*implementation JAXBBasicXMLNode*/
  606. /**
  607. * Internal, private interface for JAXB reading and writing.
  608. */
  609. @interface JAXBBasicXMLNode (JAXB) <JAXBType, JAXBElement>
  610. @end /*interface JAXBBasicXMLNode (JAXB)*/
  611. @implementation JAXBBasicXMLNode (JAXB)
  612. /**
  613. * Read the XML type from the reader; an instance of JAXBBasicXMLNode.
  614. *
  615. * @param reader The reader.
  616. * @return An instance of JAXBBasicXMLNode
  617. */
  618. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  619. {
  620. JAXBBasicXMLNode *node = [[JAXBBasicXMLNode alloc] init];
  621. NS_DURING
  622. {
  623. [node initWithReader: reader];
  624. }
  625. NS_HANDLER
  626. {
  627. [node dealloc];
  628. node = nil;
  629. [localException raise];
  630. }
  631. NS_ENDHANDLER
  632. [node autorelease];
  633. return node;
  634. }
  635. /**
  636. * Read an XML type from an XML reader into an existing instance of JAXBBasicXMLNode.
  637. *
  638. * @param reader The reader.
  639. * @param existing The existing instance into which to read values.
  640. */
  641. - (id) initWithReader: (xmlTextReaderPtr) reader
  642. {
  643. int status, depth;
  644. JAXBBasicXMLNode *child;
  645. xmlChar *value = NULL;
  646. const xmlChar *text;
  647. NSMutableArray *children;
  648. if ((self = [self init])) {
  649. depth = xmlTextReaderDepth(reader);
  650. [self setName: [NSString stringWithUTF8String: (const char *) xmlTextReaderLocalName(reader)]];
  651. [self setNs: [NSString stringWithUTF8String: (const char *) xmlTextReaderNamespaceUri(reader)]];
  652. [self setPrefix: [NSString stringWithUTF8String: (const char *)xmlTextReaderPrefix(reader)]];
  653. if (xmlTextReaderHasAttributes(reader)) {
  654. child = nil;
  655. children = [[NSMutableArray alloc] init];
  656. while (xmlTextReaderMoveToNextAttribute(reader)) {
  657. child = [[JAXBBasicXMLNode alloc] init];
  658. [child setName: [NSString stringWithUTF8String: (const char *) xmlTextReaderLocalName(reader)]];
  659. [child setNs: [NSString stringWithUTF8String: (const char *)xmlTextReaderNamespaceUri(reader)]];
  660. [child setPrefix: [NSString stringWithUTF8String: (const char *) xmlTextReaderPrefix(reader)]];
  661. [child setValue: [NSString stringWithUTF8String: (const char *) xmlTextReaderValue(reader)]];
  662. [children addObject: child];
  663. }
  664. [self setAttributes: children];
  665. status = xmlTextReaderMoveToElement(reader);
  666. if (status < 1) {
  667. //panic: unable to return to the element node.
  668. [NSException raise: @"XMLReadError"
  669. format: @"Error moving to element from attributes."];
  670. }
  671. }
  672. if (xmlTextReaderIsEmptyElement(reader) == 0) {
  673. children = [[NSMutableArray alloc] init];
  674. status = xmlTextReaderRead(reader);
  675. while (status == 1 && xmlTextReaderDepth(reader) > depth) {
  676. switch (xmlTextReaderNodeType(reader)) {
  677. case XML_READER_TYPE_ELEMENT:
  678. child = (JAXBBasicXMLNode *) [JAXBBasicXMLNode readXMLType: reader];
  679. [children addObject: child];
  680. break;
  681. case XML_READER_TYPE_TEXT:
  682. case XML_READER_TYPE_CDATA:
  683. text = xmlTextReaderConstValue(reader);
  684. value = xmlStrncat(value, text, xmlStrlen(text));
  685. break;
  686. default:
  687. //skip anything else.
  688. break;
  689. }
  690. status = xmlTextReaderRead(reader);
  691. }
  692. if (status < 1) {
  693. //panic: xml read error
  694. [NSException raise: @"XMLReadError"
  695. format: @"Error reading child elements."];
  696. }
  697. if ([children count] > 0) {
  698. [self setChildElements: children];
  699. }
  700. if (value != NULL) {
  701. [self setValue: [NSString stringWithUTF8String: (const char *) value]];
  702. }
  703. }
  704. }
  705. return self;
  706. }
  707. /**
  708. * Read the XML element from the reader; an instance of NSXMLElement.
  709. *
  710. * @param reader The reader.
  711. * @return An instance of NSXMLElement
  712. */
  713. + (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader
  714. {
  715. return (id<JAXBElement>) [JAXBBasicXMLNode readXMLType: reader];
  716. }
  717. /**
  718. * Write the basic node to an xml writer.
  719. *
  720. * @param writer The writer.
  721. */
  722. - (void) writeXMLType: (xmlTextWriterPtr) writer
  723. {
  724. int status;
  725. NSEnumerator *enumerator;
  726. JAXBBasicXMLNode *child;
  727. xmlChar *childns, *childname, *childprefix, *childvalue;
  728. status = xmlTextWriterStartElementNS(writer, _prefix ? BAD_CAST [_prefix UTF8String] : NULL, _name ? BAD_CAST [_name UTF8String] : NULL, _ns ? BAD_CAST [_ns UTF8String] : NULL);
  729. if (status < 0) {
  730. childns = BAD_CAST "";
  731. if (_ns) {
  732. childns = BAD_CAST [_ns UTF8String];
  733. }
  734. childname = BAD_CAST "";
  735. if (_name) {
  736. childname = BAD_CAST [_name UTF8String];
  737. }
  738. [NSException raise: @"XMLWriteError"
  739. format: @"Error writing start element {%s}%s for JAXBBasicXMLNode.", childns, childname];
  740. }
  741. if (_attributes) {
  742. enumerator = [_attributes objectEnumerator];
  743. while ( (child = (JAXBBasicXMLNode *)[enumerator nextObject]) ) {
  744. childns = NULL;
  745. if ([child ns]) {
  746. childns = BAD_CAST [[child ns] UTF8String];
  747. }
  748. childprefix = NULL;
  749. if ([child prefix]) {
  750. childprefix = BAD_CAST [[child prefix] UTF8String];
  751. }
  752. childname = NULL;
  753. if ([child name]) {
  754. childname = BAD_CAST [[child name] UTF8String];
  755. }
  756. childvalue = NULL;
  757. if ([child value]) {
  758. childvalue = BAD_CAST [[child value] UTF8String];
  759. }
  760. status = xmlTextWriterWriteAttributeNS(writer, childprefix, childname, childns, childvalue);
  761. if (status < 0) {
  762. [NSException raise: @"XMLWriteError"
  763. format: @"Error writing attribute {%s}%s for JAXBBasicXMLNode.", childns, childname];
  764. }
  765. }
  766. }
  767. if (_value) {
  768. status = xmlTextWriterWriteString(writer, BAD_CAST [_value UTF8String]);
  769. if (status < 0) {
  770. [NSException raise: @"XMLWriteError"
  771. format: @"Error writing value of JAXBBasicXMLNode."];
  772. }
  773. }
  774. if (_childElements) {
  775. enumerator = [_childElements objectEnumerator];
  776. while ( (child = [enumerator nextObject]) ) {
  777. [child writeXMLType: writer];
  778. }
  779. }
  780. status = xmlTextWriterEndElement(writer);
  781. if (status < 0) {
  782. childns = BAD_CAST "";
  783. if (_ns) {
  784. childns = BAD_CAST [_ns UTF8String];
  785. }
  786. childname = BAD_CAST "";
  787. if (_name) {
  788. childname = BAD_CAST [_name UTF8String];
  789. }
  790. [NSException raise: @"XMLWriteError"
  791. format: @"Error writing end element {%s}%s for JAXBBasicXMLNode.", childns, childname];
  792. }
  793. }
  794. /**
  795. * Writes this node to a writer.
  796. *
  797. * @param writer The writer.
  798. */
  799. - (void) writeXMLElement: (xmlTextWriterPtr) writer
  800. {
  801. [self writeXMLType: writer];
  802. }
  803. /**
  804. * Writes this node to a writer.
  805. *
  806. * @param writer The writer.
  807. * @param writeNs Whether to write the namespaces for this element to the xml writer.
  808. */
  809. - (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs
  810. {
  811. [self writeXMLType: writer];
  812. }
  813. @end /* implementation JAXBBasicXMLNode (JAXB) */
  814. /**
  815. * Declaration of the JAXB type for a string.
  816. */
  817. @interface NSString (JAXBType) <JAXBType>
  818. @end
  819. /**
  820. * Implementation of the JAXB type for a string.
  821. */
  822. @implementation NSString (JAXBType)
  823. /**
  824. * Read the XML type from the reader.
  825. *
  826. * @param reader The reader.
  827. * @return The NSString that was read from the reader.
  828. */
  829. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  830. {
  831. return [NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)];
  832. }
  833. /**
  834. * Read an XML type from an XML reader into an existing instance.
  835. *
  836. * @param reader The reader.
  837. * @param existing The existing instance into which to read values.
  838. */
  839. - (id) initWithReader: (xmlTextReaderPtr) reader
  840. {
  841. [NSException raise: @"XMLReadError"
  842. format: @"An existing string cannot be modified."];
  843. return nil;
  844. }
  845. /**
  846. * Write the NSString to the writer.
  847. *
  848. * @param writer The writer.
  849. */
  850. - (void) writeXMLType: (xmlTextWriterPtr) writer
  851. {
  852. xmlTextWriterWriteString(writer, BAD_CAST [self UTF8String]);
  853. }
  854. @end /*NSString (JAXBType)*/
  855. /**
  856. * Declaration of the JAXB type for a big number.
  857. */
  858. @interface NSNumber (JAXBType) <JAXBType>
  859. @end
  860. /**
  861. * Implementation of the JAXB type for a big number.
  862. */
  863. @implementation NSNumber (JAXBType)
  864. /**
  865. * Read the XML type from the reader.
  866. *
  867. * @param reader The reader.
  868. * @return The NSNumber that was read from the reader.
  869. */
  870. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  871. {
  872. return [NSNumber numberWithLongLong: [[NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)] longLongValue]];
  873. }
  874. /**
  875. * Read an XML type from an XML reader into an existing instance.
  876. *
  877. * @param reader The reader.
  878. * @param existing The existing instance into which to read values.
  879. */
  880. - (id) initWithReader: (xmlTextReaderPtr) reader
  881. {
  882. [NSException raise: @"XMLReadError"
  883. format: @"An existing number cannot be modified."];
  884. return nil;
  885. }
  886. /**
  887. * Write the NSNumber to the writer.
  888. *
  889. * @param writer The writer.
  890. */
  891. - (void) writeXMLType: (xmlTextWriterPtr) writer
  892. {
  893. xmlTextWriterWriteString(writer, BAD_CAST [[self description] UTF8String]);
  894. }
  895. @end /*NSNumber (JAXBType)*/
  896. /**
  897. * Declaration of the JAXB type for a big number.
  898. */
  899. @interface NSDecimalNumber (JAXBType) <JAXBType>
  900. @end
  901. /**
  902. * Implementation of the JAXB type for a big number.
  903. */
  904. @implementation NSDecimalNumber (JAXBType)
  905. /**
  906. * Read the XML type from the reader.
  907. *
  908. * @param reader The reader.
  909. * @return The NSDecimalNumber that was read from the reader.
  910. */
  911. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  912. {
  913. return [NSDecimalNumber decimalNumberWithString: [NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)]];
  914. }
  915. /**
  916. * Read an XML type from an XML reader into an existing instance.
  917. *
  918. * @param reader The reader.
  919. * @param existing The existing instance into which to read values.
  920. */
  921. - (id) initWithReader: (xmlTextReaderPtr) reader
  922. {
  923. [NSException raise: @"XMLReadError"
  924. format: @"An existing decimal number cannot be modified."];
  925. return nil;
  926. }
  927. /**
  928. * Write the NSDecimalNumber to the writer.
  929. *
  930. * @param writer The writer.
  931. */
  932. - (void) writeXMLType: (xmlTextWriterPtr) writer
  933. {
  934. xmlTextWriterWriteString(writer, BAD_CAST [[self description] UTF8String]);
  935. }
  936. @end /*NSDecimalNumber (JAXBType)*/
  937. /**
  938. * Declaration of the JAXB type for a url.
  939. */
  940. @interface NSURL (JAXBType) <JAXBType>
  941. @end
  942. /**
  943. * Implementation of the JAXB type for a url.
  944. */
  945. @implementation NSURL (JAXBType)
  946. /**
  947. * Read the XML type from the reader.
  948. *
  949. * @param reader The reader.
  950. * @return The NSURL that was read from the reader.
  951. */
  952. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  953. {
  954. return [NSURL URLWithString: [NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)]];
  955. }
  956. /**
  957. * Read an XML type from an XML reader into an existing instance.
  958. *
  959. * @param reader The reader.
  960. * @param existing The existing instance into which to read values.
  961. */
  962. - (id) initWithReader: (xmlTextReaderPtr) reader
  963. {
  964. [NSException raise: @"XMLReadError"
  965. format: @"An existing url cannot be modified."];
  966. return nil;
  967. }
  968. /**
  969. * Write the NSURL to the writer.
  970. *
  971. * @param writer The writer.
  972. */
  973. - (void) writeXMLType: (xmlTextWriterPtr) writer
  974. {
  975. xmlTextWriterWriteString(writer, BAD_CAST [[self absoluteString] UTF8String]);
  976. }
  977. @end /*NSURL (JAXBType)*/
  978. /**
  979. * Declaration of the JAXB type for binary data.
  980. */
  981. @interface NSData (JAXBType) <JAXBType>
  982. @end
  983. /**
  984. * Implementation of the JAXB type for a binary data.
  985. */
  986. @implementation NSData (JAXBType)
  987. /**
  988. * Read the XML type from the reader.
  989. *
  990. * @param reader The reader.
  991. * @return The NSData that was read from the reader.
  992. */
  993. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  994. {
  995. xmlChar *base64data = xmlTextReaderReadEntireNodeValue(reader);
  996. int len;
  997. unsigned char *data = _decode_base64(base64data, &len);
  998. NSData *wrappedData = [NSData dataWithBytesNoCopy: data length: len];
  999. free(base64data);
  1000. return wrappedData;
  1001. }
  1002. /**
  1003. * Read an XML type from an XML reader into an existing instance.
  1004. *
  1005. * @param reader The reader.
  1006. * @param existing The existing instance into which to read values.
  1007. */
  1008. - (id) initWithReader: (xmlTextReaderPtr) reader
  1009. {
  1010. [NSException raise: @"XMLReadError"
  1011. format: @"An existing NSData cannot be modified."];
  1012. return nil;
  1013. }
  1014. /**
  1015. * Write the NSData to the writer.
  1016. *
  1017. * @param writer The writer.
  1018. */
  1019. - (void) writeXMLType: (xmlTextWriterPtr) writer
  1020. {
  1021. xmlChar *out = _encode_base64((unsigned char *)[self bytes], [self length]);
  1022. xmlTextWriterWriteString(writer, out);
  1023. free(out);
  1024. }
  1025. @end /*NSData (JAXBType)*/
  1026. /**
  1027. * Declaration of the JAXB type for a big number.
  1028. */
  1029. @interface NSDate (JAXBType) <JAXBType>
  1030. @end
  1031. /**
  1032. * Implementation of the JAXB type for a big number.
  1033. */
  1034. @implementation NSDate (JAXBType)
  1035. /**
  1036. * Read the XML type from the reader.
  1037. *
  1038. * @param reader The reader.
  1039. * @return The NSDate that was read from the reader.
  1040. */
  1041. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  1042. {
  1043. return [NSCalendarDate readXMLType: reader];
  1044. }
  1045. /**
  1046. * Read an XML type from an XML reader into an existing instance.
  1047. *
  1048. * @param reader The reader.
  1049. * @param existing The existing instance into which to read values.
  1050. */
  1051. - (id) initWithReader: (xmlTextReaderPtr) reader
  1052. {
  1053. [NSException raise: @"XMLReadError"
  1054. format: @"An existing date cannot be modified."];
  1055. return nil;
  1056. }
  1057. /**
  1058. * Write the NSDate to the writer.
  1059. *
  1060. * @param writer The writer.
  1061. */
  1062. - (void) writeXMLType: (xmlTextWriterPtr) writer
  1063. {
  1064. NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat: @"%Y-%m-%dT%H:%M:%S %z" allowNaturalLanguage: NO];
  1065. xmlChar *timevalue = BAD_CAST [[formatter stringForObjectValue: self] UTF8String];
  1066. timevalue[19] = timevalue[20];
  1067. timevalue[20] = timevalue[21];
  1068. timevalue[21] = timevalue[22];
  1069. timevalue[22] = ':';
  1070. xmlTextWriterWriteString(writer, timevalue);
  1071. [formatter release];
  1072. }
  1073. @end /*NSDate (JAXBType)*/
  1074. /**
  1075. * Declaration of the JAXB type for a big number.
  1076. */
  1077. @interface NSCalendarDate (JAXBType) <JAXBType>
  1078. @end
  1079. /**
  1080. * Implementation of the JAXB type for a big number.
  1081. */
  1082. @implementation NSCalendarDate (JAXBType)
  1083. /**
  1084. * Read the XML type from the reader.
  1085. *
  1086. * @param reader The reader.
  1087. * @return The NSCalendarDate that was read from the reader.
  1088. */
  1089. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  1090. {
  1091. xmlChar *timevalue = xmlTextReaderReadEntireNodeValue(reader);
  1092. NSInteger year = 0;
  1093. NSUInteger month = 1, day = 1, hour = 0, minute = 0, second = 0;
  1094. NSTimeZone *tz = nil;
  1095. BOOL skip_time = NO;
  1096. int index = 0, token_index = 0, len = xmlStrlen(timevalue), offset_seconds = 0;
  1097. char token[len];
  1098. if (len > (index + 5) && timevalue[index + 4] == '-') {
  1099. //assume we're at yyyy-MM-dd
  1100. token_index = 0;
  1101. while (index < len && timevalue[index] != '-') {
  1102. token[token_index++] = timevalue[index++];
  1103. }
  1104. token[token_index] = '\0';
  1105. if (token_index != 4) {
  1106. [NSException raise: @"XMLReadError"
  1107. format: @"Unable to read dateTime %s; invalid year: %s", timevalue, token];
  1108. }
  1109. year = atoi(token);
  1110. index++;
  1111. //go to next '-' character.
  1112. token_index = 0;
  1113. while (index < len && timevalue[index] != '-') {
  1114. token[token_index++] = timevalue[index++];
  1115. }
  1116. token[token_index] = '\0';
  1117. if (token_index != 2) {
  1118. [NSException raise: @"XMLReadError"
  1119. format: @"Unable to read dateTime %s; invalid month: %s", timevalue, token];
  1120. }
  1121. month = atoi(token);
  1122. index++;
  1123. //go to 'T', 'Z', '+', or '-' character.
  1124. token_index = 0;
  1125. while (index < len && timevalue[index] != 'T' && timevalue[index] != 'Z' && timevalue[index] != '-' && timevalue[index] != '+') {
  1126. token[token_index++] = timevalue[index++];
  1127. }
  1128. token[token_index] = '\0';
  1129. if (token_index != 2) {
  1130. [NSException raise: @"XMLReadError"
  1131. format: @"Unable to read dateTime %s; invalid day of month: %s", timevalue, token];
  1132. }
  1133. day = atoi(token);
  1134. if (timevalue[index] != 'T') {
  1135. skip_time = YES;
  1136. }
  1137. if (timevalue[index] != '-') {
  1138. index++;
  1139. }
  1140. }
  1141. if (skip_time == NO || (len > (index + 3) && timevalue[index + 2] == ':')) {
  1142. //assume we're at HH:mm:ss
  1143. //go to ':' character.
  1144. token_index = 0;
  1145. while (index < len && timevalue[index] != ':') {
  1146. token[token_index++] = timevalue[index++];
  1147. }
  1148. token[token_index] = '\0';
  1149. if (token_index != 2) {
  1150. [NSException raise: @"XMLReadError"
  1151. format: @"Unable to read dateTime %s; invalid hour: %s", timevalue, token];
  1152. }
  1153. hour = atoi(token);
  1154. index++;
  1155. //go to ':' character.
  1156. token_index = 0;
  1157. while (index < len && timevalue[index] != ':') {
  1158. token[token_index++] = timevalue[index++];
  1159. }
  1160. token[token_index] = '\0';
  1161. if (token_index != 2) {
  1162. [NSException raise: @"XMLReadError"
  1163. format: @"Unable to read dateTime %s; invalid minute: %s", timevalue, token];
  1164. }
  1165. minute = atoi(token);
  1166. index++;
  1167. //go to '+' or '-' or 'Z' character.
  1168. token_index = 0;
  1169. while (index < len && timevalue[index] != '+' && timevalue[index] != '-' && timevalue[index] != 'Z') {
  1170. token[token_index++] = timevalue[index++];
  1171. }
  1172. token[token_index] = '\0';
  1173. if (token_index == 0) {
  1174. [NSException raise: @"XMLReadError"
  1175. format: @"Unable to read dateTime %s; invalid seconds: %s", timevalue, token];
  1176. }
  1177. second = (NSUInteger) atof(token);
  1178. if (timevalue[index] != '-') {
  1179. index++;
  1180. }
  1181. }
  1182. //go to ':' character.
  1183. token_index = 0;
  1184. while (index < len && timevalue[index] != ':') {
  1185. token[token_index++] = timevalue[index++];
  1186. }
  1187. token[token_index] = '\0';
  1188. offset_seconds += atoi(token) * 60 * 60;
  1189. index++;
  1190. //go to end.
  1191. token_index = 0;
  1192. while (index < len) {
  1193. token[token_index++] = timevalue[index++];
  1194. }
  1195. token[token_index] = '\0';
  1196. offset_seconds += atoi(token) * 60;
  1197. tz = [NSTimeZone timeZoneForSecondsFromGMT: offset_seconds];
  1198. free(timevalue);
  1199. return [NSCalendarDate dateWithYear: year month: month day: day hour: hour minute: minute second: second timeZone: tz];
  1200. }
  1201. /**
  1202. * Read an XML type from an XML reader into an existing instance.
  1203. *
  1204. * @param reader The reader.
  1205. * @param existing The existing instance into which to read values.
  1206. */
  1207. - (id) initWithReader: (xmlTextReaderPtr) reader
  1208. {
  1209. [NSException raise: @"XMLReadError"
  1210. format: @"An existing date cannot be modified."];
  1211. return nil;
  1212. }
  1213. /**
  1214. * Write the NSDate to the writer.
  1215. *
  1216. * @param writer The writer.
  1217. */
  1218. - (void) writeXMLType: (xmlTextWriterPtr) writer
  1219. {
  1220. [super writeXMLType: writer];
  1221. }
  1222. @end /*NSCalendarDate (JAXBType)*/
  1223. #endif /* ENUNCIATE_OBJC_CLASSES */
  1224. #ifndef ENUNCIATE_XML_OBJC_PRIMITIVE_FUNCTIONS
  1225. #define ENUNCIATE_XML_OBJC_PRIMITIVE_FUNCTIONS
  1226. /*******************boolean************************************/
  1227. /**
  1228. * Read a boolean value from the reader.
  1229. *
  1230. * @param reader The reader (pointing at a node with a value).
  1231. * @return YES if "true" was read. NO otherwise.
  1232. */
  1233. static BOOL *xmlTextReaderReadBooleanType(xmlTextReaderPtr reader) {
  1234. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1235. BOOL *value = malloc(sizeof(BOOL));
  1236. *value = (xmlStrcmp(BAD_CAST "true", nodeValue) == 0) ? YES : NO;
  1237. free(nodeValue);
  1238. return value;
  1239. }
  1240. /**
  1241. * Write a boolean value to the writer.
  1242. *
  1243. * @param writer The writer.
  1244. * @param value The value to be written.
  1245. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1246. */
  1247. static int xmlTextWriterWriteBooleanType(xmlTextWriterPtr writer, BOOL *value) {
  1248. if (*value) {
  1249. return xmlTextWriterWriteString(writer, BAD_CAST "false");
  1250. }
  1251. else {
  1252. return xmlTextWriterWriteString(writer, BAD_CAST "true");
  1253. }
  1254. }
  1255. /*******************byte************************************/
  1256. /**
  1257. * Read a byte value from the reader.
  1258. *
  1259. * @param reader The reader (pointing at a node with a value).
  1260. * @return the byte.
  1261. */
  1262. static unsigned char *xmlTextReaderReadByteType(xmlTextReaderPtr reader) {
  1263. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1264. unsigned char *value = malloc(sizeof(unsigned char));
  1265. *value = (unsigned char) atoi((char *) nodeValue);
  1266. free(nodeValue);
  1267. return value;
  1268. }
  1269. /**
  1270. * Write a byte value to the writer.
  1271. *
  1272. * @param writer The writer.
  1273. * @param value The value to be written.
  1274. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1275. */
  1276. static int xmlTextWriterWriteByteType(xmlTextWriterPtr writer, unsigned char *value) {
  1277. return xmlTextWriterWriteFormatString(writer, "%i", *value);
  1278. }
  1279. /*******************double************************************/
  1280. /**
  1281. * Read a double value from the reader.
  1282. *
  1283. * @param reader The reader (pointing at a node with a value).
  1284. * @return the double.
  1285. */
  1286. static double *xmlTextReaderReadDoubleType(xmlTextReaderPtr reader) {
  1287. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1288. double *value = malloc(sizeof(double));
  1289. *value = atof((char *) nodeValue);
  1290. free(nodeValue);
  1291. return value;
  1292. }
  1293. /**
  1294. * Write a double value to the writer.
  1295. *
  1296. * @param writer The writer.
  1297. * @param value The value to be written.
  1298. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1299. */
  1300. static int xmlTextWriterWriteDoubleType(xmlTextWriterPtr writer, double *value) {
  1301. return xmlTextWriterWriteFormatString(writer, "%f", *value);
  1302. }
  1303. /*******************float************************************/
  1304. /**
  1305. * Read a float value from the reader.
  1306. *
  1307. * @param reader The reader (pointing at a node with a value).
  1308. * @return the float.
  1309. */
  1310. static float *xmlTextReaderReadFloatType(xmlTextReaderPtr reader) {
  1311. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1312. float *value = malloc(sizeof(float));
  1313. *value = atof((char *)nodeValue);
  1314. free(nodeValue);
  1315. return value;
  1316. }
  1317. /**
  1318. * Write a float value to the writer.
  1319. *
  1320. * @param writer The writer.
  1321. * @param value The value to be written.
  1322. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1323. */
  1324. static int xmlTextWriterWriteFloatType(xmlTextWriterPtr writer, float *value) {
  1325. return xmlTextWriterWriteFormatString(writer, "%f", *value);
  1326. }
  1327. /*******************int************************************/
  1328. /**
  1329. * Read a int value from the reader.
  1330. *
  1331. * @param reader The reader (pointing at a node with a value).
  1332. * @param value The value to be written.
  1333. * @return the int.
  1334. */
  1335. static int *xmlTextReaderReadIntType(xmlTextReaderPtr reader) {
  1336. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1337. int *value = malloc(sizeof(int));
  1338. *value = atoi((char *)nodeValue);
  1339. free(nodeValue);
  1340. return value;
  1341. }
  1342. /**
  1343. * Write a int value to the writer.
  1344. *
  1345. * @param writer The writer.
  1346. * @param value The value to be written.
  1347. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1348. */
  1349. static int xmlTextWriterWriteIntType(xmlTextWriterPtr writer, int *value) {
  1350. return xmlTextWriterWriteFormatString(writer, "%i", *value);
  1351. }
  1352. /*******************long************************************/
  1353. /**
  1354. * Read a long value from the reader.
  1355. *
  1356. * @param reader The reader (pointing at a node with a value).
  1357. * @return the long.
  1358. */
  1359. static long *xmlTextReaderReadLongType(xmlTextReaderPtr reader) {
  1360. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1361. long *value = malloc(sizeof(long));
  1362. *value = atol((char *)nodeValue);
  1363. free(nodeValue);
  1364. return value;
  1365. }
  1366. /**
  1367. * Write a long value to the writer.
  1368. *
  1369. * @param writer The writer.
  1370. * @param value The value to be written.
  1371. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1372. */
  1373. static int xmlTextWriterWriteLongType(xmlTextWriterPtr writer, long *value) {
  1374. return xmlTextWriterWriteFormatString(writer, "%ld", *value);
  1375. }
  1376. /*******************short************************************/
  1377. /**
  1378. * Read a short value from the reader.
  1379. *
  1380. * @param reader The reader (pointing at a node with a value).
  1381. * @return the short.
  1382. */
  1383. static short *xmlTextReaderReadShortType(xmlTextReaderPtr reader) {
  1384. xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader);
  1385. short *value = malloc(sizeof(short));
  1386. *value = atoi((char *)nodeValue);
  1387. free(nodeValue);
  1388. return value;
  1389. }
  1390. /**
  1391. * Write a short value to the writer.
  1392. *
  1393. * @param writer The writer.
  1394. * @param value The value to be written.
  1395. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1396. */
  1397. static int xmlTextWriterWriteShortType(xmlTextWriterPtr writer, short *value) {
  1398. return xmlTextWriterWriteFormatString(writer, "%h", *value);
  1399. }
  1400. /*******************char************************************/
  1401. /**
  1402. * Read a character value from the reader.
  1403. *
  1404. * @param reader The reader (pointing at a node with a value).
  1405. * @return the character.
  1406. */
  1407. static xmlChar *xmlTextReaderReadCharacterType(xmlTextReaderPtr reader) {
  1408. return xmlTextReaderReadEntireNodeValue(reader);
  1409. }
  1410. /**
  1411. * Write a character value to the writer.
  1412. *
  1413. * @param writer The writer.
  1414. * @param value The value to be written.
  1415. * @return the bytes written (may be 0 because of buffering) or -1 in case of error.
  1416. */
  1417. static int xmlTextWriterWriteCharacterType(xmlTextWriterPtr writer, xmlChar *value) {
  1418. return xmlTextWriterWriteString(writer, value);
  1419. }
  1420. #endif /* ENUNCIATE_XML_OBJC_PRIMITIVE_FUNCTIONS */
  1421. /**
  1422. * A collection of cards from the temple.
  1423. @author Duane Kuehne
  1424. */
  1425. @implementation FSRESERVATIONV1Cards
  1426. /**
  1427. * The cards.
  1428. */
  1429. - (NSArray *) cardItems
  1430. {
  1431. return _cardItems;
  1432. }
  1433. /**
  1434. * The cards.
  1435. */
  1436. - (void) setCardItems: (NSArray *) newCardItems
  1437. {
  1438. [newCardItems retain];
  1439. [_cardItems release];
  1440. _cardItems = newCardItems;
  1441. }
  1442. - (void) dealloc
  1443. {
  1444. [self setCardItems: nil];
  1445. [super dealloc];
  1446. }
  1447. @end /* implementation FSRESERVATIONV1Cards */
  1448. /**
  1449. * Internal, private interface for JAXB reading and writing.
  1450. */
  1451. @interface FSRESERVATIONV1Cards (JAXB) <JAXBReading, JAXBWriting, JAXBType>
  1452. @end /*interface FSRESERVATIONV1Cards (JAXB)*/
  1453. /**
  1454. * Internal, private implementation for JAXB reading and writing.
  1455. */
  1456. @implementation FSRESERVATIONV1Cards (JAXB)
  1457. /**
  1458. * Read an instance of FSRESERVATIONV1Cards from an XML reader.
  1459. *
  1460. * @param reader The reader.
  1461. * @return An instance of FSRESERVATIONV1Cards defined by the XML reader.
  1462. */
  1463. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  1464. {
  1465. FSRESERVATIONV1Cards *_fSRESERVATIONV1Cards = [[FSRESERVATIONV1Cards alloc] init];
  1466. NS_DURING
  1467. {
  1468. [_fSRESERVATIONV1Cards initWithReader: reader];
  1469. }
  1470. NS_HANDLER
  1471. {
  1472. [_fSRESERVATIONV1Cards dealloc];
  1473. _fSRESERVATIONV1Cards = nil;
  1474. [localException raise];
  1475. }
  1476. NS_ENDHANDLER
  1477. [_fSRESERVATIONV1Cards autorelease];
  1478. return _fSRESERVATIONV1Cards;
  1479. }
  1480. /**
  1481. * Initialize this instance of FSRESERVATIONV1Cards according to
  1482. * the XML being read from the reader.
  1483. *
  1484. * @param reader The reader.
  1485. */
  1486. - (id) initWithReader: (xmlTextReaderPtr) reader
  1487. {
  1488. return [super initWithReader: reader];
  1489. }
  1490. /**
  1491. * Write the XML for this instance of FSRESERVATIONV1Cards to the writer.
  1492. * Note that since we're only writing the XML type,
  1493. * No start/end element will be written.
  1494. *
  1495. * @param reader The reader.
  1496. */
  1497. - (void) writeXMLType: (xmlTextWriterPtr) writer
  1498. {
  1499. [super writeXMLType:writer];
  1500. }
  1501. //documentation inherited.
  1502. - (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader
  1503. {
  1504. void *_child_accessor;
  1505. if ([super readJAXBAttribute: reader]) {
  1506. return YES;
  1507. }
  1508. return NO;
  1509. }
  1510. //documentation inherited.
  1511. - (BOOL) readJAXBValue: (xmlTextReaderPtr) reader
  1512. {
  1513. return [super readJAXBValue: reader];
  1514. }
  1515. //documentation inherited.
  1516. - (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader
  1517. {
  1518. id __child;
  1519. void *_child_accessor;
  1520. int status, depth;
  1521. if ([super readJAXBChildElement: reader]) {
  1522. return YES;
  1523. }
  1524. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
  1525. && xmlStrcmp(BAD_CAST "card", xmlTextReaderConstLocalName(reader)) == 0
  1526. && xmlStrcmp(BAD_CAST "http://api.familysearch.org/reservation/v1", xmlTextReaderConstNamespaceUri(reader)) == 0) {
  1527. #if DEBUG_ENUNCIATE > 1
  1528. NSLog(@"Attempting to read choice {http://api.familysearch.org/reservation/v1}card of type {http://api.familysearch.org/reservation/v1}card.");
  1529. #endif
  1530. __child = [FSRESERVATIONV1Card readXMLType: reader];
  1531. #if DEBUG_ENUNCIATE > 1
  1532. NSLog(@"successfully read choice {http://api.familysearch.org/reservation/v1}card of type {http://api.familysearch.org/reservation/v1}card.");
  1533. #endif
  1534. if ([self cardItems]) {
  1535. [self setCardItems: [[self cardItems] arrayByAddingObject: __child]];
  1536. }
  1537. else {
  1538. [self setCardItems: [NSArray arrayWithObject: __child]];
  1539. }
  1540. return YES;
  1541. } //end "if choice"
  1542. return NO;
  1543. }
  1544. //documentation inherited.
  1545. - (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader
  1546. {
  1547. return [super readUnknownJAXBChildElement: reader];
  1548. }
  1549. //documentation inherited.
  1550. - (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader
  1551. {
  1552. [super readUnknownJAXBAttribute: reader];
  1553. }
  1554. //documentation inherited.
  1555. - (void) writeJAXBAttributes: (xmlTextWriterPtr) writer
  1556. {
  1557. int status;
  1558. [super writeJAXBAttributes: writer];
  1559. }
  1560. //documentation inherited.
  1561. - (void) writeJAXBValue: (xmlTextWriterPtr) writer
  1562. {
  1563. [super writeJAXBValue: writer];
  1564. }
  1565. /**
  1566. * Method for writing the child elements.
  1567. *
  1568. * @param writer The writer.
  1569. */
  1570. - (void) writeJAXBChildElements: (xmlTextWriterPtr) writer
  1571. {
  1572. int status;
  1573. id __item;
  1574. NSEnumerator *__enumerator;
  1575. [super writeJAXBChildElements: writer];
  1576. if ([self cardItems]) {
  1577. __enumerator = [[self cardItems] objectEnumerator];
  1578. while ( (__item = [__enumerator nextObject]) ) {
  1579. status = xmlTextWriterStartElementNS(writer, BAD_CAST "reservation_v1", BAD_CAST "card", NULL);
  1580. if (status < 0) {
  1581. [NSException raise: @"XMLWriteError"
  1582. format: @"Error writing start child element {http://api.familysearch.org/reservation/v1}card."];
  1583. }
  1584. #if DEBUG_ENUNCIATE > 1
  1585. NSLog(@"writing element {http://api.familysearch.org/reservation/v1}card...");
  1586. #endif
  1587. [__item writeXMLType: writer];
  1588. #if DEBUG_ENUNCIATE > 1
  1589. NSLog(@"successfully wrote element {http://api.familysearch.org/reservation/v1}card...");
  1590. #endif
  1591. status = xmlTextWriterEndElement(writer);
  1592. if (status < 0) {
  1593. [NSException raise: @"XMLWriteError"
  1594. format: @"Error writing end child element {http://api.familysearch.org/reservation/v1}card."];
  1595. }
  1596. } //end item iterator.
  1597. }
  1598. }
  1599. @end /* implementation FSRESERVATIONV1Cards (JAXB) */
  1600. /**
  1601. * A date.
  1602. @author Ryan Heaton
  1603. */
  1604. @implementation FSRESERVATIONV1DateData
  1605. /**
  1606. * The date value.
  1607. */
  1608. - (NSString *) original
  1609. {
  1610. return _original;
  1611. }
  1612. /**
  1613. * The date value.
  1614. */
  1615. - (void) setOriginal: (NSString *) newOriginal
  1616. {
  1617. [newOriginal retain];
  1618. [_original release];
  1619. _original = newOriginal;
  1620. }
  1621. /**
  1622. * The normalized value.
  1623. */
  1624. - (NSString *) normalized
  1625. {
  1626. return _normalized;
  1627. }
  1628. /**
  1629. * The normalized value.
  1630. */
  1631. - (void) setNormalized: (NSString *) newNormalized
  1632. {
  1633. [newNormalized retain];
  1634. [_normalized release];
  1635. _normalized = newNormalized;
  1636. }
  1637. /**
  1638. * The astro date.
  1639. */
  1640. - (FSRESERVATIONV1DateAstro *) astro
  1641. {
  1642. return _astro;
  1643. }
  1644. /**
  1645. * The astro date.
  1646. */
  1647. - (void) setAstro: (FSRESERVATIONV1DateAstro *) newAstro
  1648. {
  1649. [newAstro retain];
  1650. [_astro release];
  1651. _astro = newAstro;
  1652. }
  1653. - (void) dealloc
  1654. {
  1655. [self setOriginal: nil];
  1656. [self setNormalized: nil];
  1657. [self setAstro: nil];
  1658. [super dealloc];
  1659. }
  1660. @end /* implementation FSRESERVATIONV1DateData */
  1661. /**
  1662. * Internal, private interface for JAXB reading and writing.
  1663. */
  1664. @interface FSRESERVATIONV1DateData (JAXB) <JAXBReading, JAXBWriting, JAXBType>
  1665. @end /*interface FSRESERVATIONV1DateData (JAXB)*/
  1666. /**
  1667. * Internal, private implementation for JAXB reading and writing.
  1668. */
  1669. @implementation FSRESERVATIONV1DateData (JAXB)
  1670. /**
  1671. * Read an instance of FSRESERVATIONV1DateData from an XML reader.
  1672. *
  1673. * @param reader The reader.
  1674. * @return An instance of FSRESERVATIONV1DateData defined by the XML reader.
  1675. */
  1676. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  1677. {
  1678. FSRESERVATIONV1DateData *_fSRESERVATIONV1DateData = [[FSRESERVATIONV1DateData alloc] init];
  1679. NS_DURING
  1680. {
  1681. [_fSRESERVATIONV1DateData initWithReader: reader];
  1682. }
  1683. NS_HANDLER
  1684. {
  1685. [_fSRESERVATIONV1DateData dealloc];
  1686. _fSRESERVATIONV1DateData = nil;
  1687. [localException raise];
  1688. }
  1689. NS_ENDHANDLER
  1690. [_fSRESERVATIONV1DateData autorelease];
  1691. return _fSRESERVATIONV1DateData;
  1692. }
  1693. /**
  1694. * Initialize this instance of FSRESERVATIONV1DateData according to
  1695. * the XML being read from the reader.
  1696. *
  1697. * @param reader The reader.
  1698. */
  1699. - (id) initWithReader: (xmlTextReaderPtr) reader
  1700. {
  1701. return [super initWithReader: reader];
  1702. }
  1703. /**
  1704. * Write the XML for this instance of FSRESERVATIONV1DateData to the writer.
  1705. * Note that since we're only writing the XML type,
  1706. * No start/end element will be written.
  1707. *
  1708. * @param reader The reader.
  1709. */
  1710. - (void) writeXMLType: (xmlTextWriterPtr) writer
  1711. {
  1712. [super writeXMLType:writer];
  1713. }
  1714. //documentation inherited.
  1715. - (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader
  1716. {
  1717. void *_child_accessor;
  1718. if ([super readJAXBAttribute: reader]) {
  1719. return YES;
  1720. }
  1721. return NO;
  1722. }
  1723. //documentation inherited.
  1724. - (BOOL) readJAXBValue: (xmlTextReaderPtr) reader
  1725. {
  1726. return [super readJAXBValue: reader];
  1727. }
  1728. //documentation inherited.
  1729. - (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader
  1730. {
  1731. id __child;
  1732. void *_child_accessor;
  1733. int status, depth;
  1734. if ([super readJAXBChildElement: reader]) {
  1735. return YES;
  1736. }
  1737. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
  1738. && xmlStrcmp(BAD_CAST "original", xmlTextReaderConstLocalName(reader)) == 0
  1739. && xmlStrcmp(BAD_CAST "http://api.familysearch.org/reservation/v1", xmlTextReaderConstNamespaceUri(reader)) == 0) {
  1740. #if DEBUG_ENUNCIATE > 1
  1741. NSLog(@"Attempting to read choice {http://api.familysearch.org/reservation/v1}original of type {http://www.w3.org/2001/XMLSchema}string.");
  1742. #endif
  1743. __child = [NSString readXMLType: reader];
  1744. #if DEBUG_ENUNCIATE > 1
  1745. NSLog(@"successfully read choice {http://api.familysearch.org/reservation/v1}original of type {http://www.w3.org/2001/XMLSchema}string.");
  1746. #endif
  1747. [self setOriginal: __child];
  1748. return YES;
  1749. } //end "if choice"
  1750. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
  1751. && xmlStrcmp(BAD_CAST "normalized", xmlTextReaderConstLocalName(reader)) == 0
  1752. && xmlStrcmp(BAD_CAST "http://api.familysearch.org/reservation/v1", xmlTextReaderConstNamespaceUri(reader)) == 0) {
  1753. #if DEBUG_ENUNCIATE > 1
  1754. NSLog(@"Attempting to read choice {http://api.familysearch.org/reservation/v1}normalized of type {http://www.w3.org/2001/XMLSchema}string.");
  1755. #endif
  1756. __child = [NSString readXMLType: reader];
  1757. #if DEBUG_ENUNCIATE > 1
  1758. NSLog(@"successfully read choice {http://api.familysearch.org/reservation/v1}normalized of type {http://www.w3.org/2001/XMLSchema}string.");
  1759. #endif
  1760. [self setNormalized: __child];
  1761. return YES;
  1762. } //end "if choice"
  1763. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
  1764. && xmlStrcmp(BAD_CAST "astro", xmlTextReaderConstLocalName(reader)) == 0
  1765. && xmlStrcmp(BAD_CAST "http://api.familysearch.org/reservation/v1", xmlTextReaderConstNamespaceUri(reader)) == 0) {
  1766. #if DEBUG_ENUNCIATE > 1
  1767. NSLog(@"Attempting to read choice {http://api.familysearch.org/reservation/v1}astro of type {http://api.familysearch.org/reservation/v1}dateAstro.");
  1768. #endif
  1769. __child = [FSRESERVATIONV1DateAstro readXMLType: reader];
  1770. #if DEBUG_ENUNCIATE > 1
  1771. NSLog(@"successfully read choice {http://api.familysearch.org/reservation/v1}astro of type {http://api.familysearch.org/reservation/v1}dateAstro.");
  1772. #endif
  1773. [self setAstro: __child];
  1774. return YES;
  1775. } //end "if choice"
  1776. return NO;
  1777. }
  1778. //documentation inherited.
  1779. - (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader
  1780. {
  1781. return [super readUnknownJAXBChildElement: reader];
  1782. }
  1783. //documentation inherited.
  1784. - (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader
  1785. {
  1786. [super readUnknownJAXBAttribute: reader];
  1787. }
  1788. //documentation inherited.
  1789. - (void) writeJAXBAttributes: (xmlTextWriterPtr) writer
  1790. {
  1791. int status;
  1792. [super writeJAXBAttributes: writer];
  1793. }
  1794. //documentation inherited.
  1795. - (void) writeJAXBValue: (xmlTextWriterPtr) writer
  1796. {
  1797. [super writeJAXBValue: writer];
  1798. }
  1799. /**
  1800. * Method for writing the child elements.
  1801. *
  1802. * @param writer The writer.
  1803. */
  1804. - (void) writeJAXBChildElements: (xmlTextWriterPtr) writer
  1805. {
  1806. int status;
  1807. id __item;
  1808. NSEnumerator *__enumerator;
  1809. [super writeJAXBChildElements: writer];
  1810. if ([self original]) {
  1811. status = xmlTextWriterStartElementNS(writer, BAD_CAST "reservation_v1", BAD_CAST "original", NULL);
  1812. if (status < 0) {
  1813. [NSException raise: @"XMLWriteError"
  1814. format: @"Error writing start child element {http://api.familysearch.org/reservation/v1}original."];
  1815. }
  1816. #if DEBUG_ENUNCIATE > 1
  1817. NSLog(@"writing element {http://api.familysearch.org/reservation/v1}original...");
  1818. #endif
  1819. [[self original] writeXMLType: writer];
  1820. #if DEBUG_ENUNCIATE > 1
  1821. NSLog(@"successfully wrote element {http://api.familysearch.org/reservation/v1}original...");
  1822. #endif
  1823. status = xmlTextWriterEndElement(writer);
  1824. if (status < 0) {
  1825. [NSException raise: @"XMLWriteError"
  1826. format: @"Error writing end child element {http://api.familysearch.org/reservation/v1}original."];
  1827. }
  1828. }
  1829. if ([self normalized]) {
  1830. status = xmlTextWriterStartElementNS(writer, BAD_CAST "reservation_v1", BAD_CAST "normalized", NULL);
  1831. if (status < 0) {
  1832. [NSException raise: @"XMLWriteError"
  1833. format: @"Error writing start child element {http://api.familysearch.org/reservation/v1}normalized."];
  1834. }
  1835. #if DEBUG_ENUNCIATE > 1
  1836. NSLog(@"writing element {http://api.familysearch.org/reservation/v1}normalized...");
  1837. #endif
  1838. [[self normalized] writeXMLType: writer];
  1839. #if DEBUG_ENUNCIATE > 1
  1840. NSLog(@"successfully wrote element {http://api.familysearch.org/reservation/v1}normalized...");
  1841. #endif
  1842. status = xmlTextWriterEndElement(writer);
  1843. if (status < 0) {
  1844. [NSException raise: @"XMLWriteError"
  1845. format: @"Error writing end child element {http://api.familysearch.org/reservation/v1}normalized."];
  1846. }
  1847. }
  1848. if ([self astro]) {
  1849. status = xmlTextWriterStartElementNS(writer, BAD_CAST "reservation_v1", BAD_CAST "astro", NULL);
  1850. if (status < 0) {
  1851. [NSException raise: @"XMLWriteError"
  1852. format: @"Error writing start child element {http://api.familysearch.org/reservation/v1}astro."];
  1853. }
  1854. #if DEBUG_ENUNCIATE > 1
  1855. NSLog(@"writing element {http://api.familysearch.org/reservation/v1}astro...");
  1856. #endif
  1857. [[self astro] writeXMLType: writer];
  1858. #if DEBUG_ENUNCIATE > 1
  1859. NSLog(@"successfully wrote element {http://api.familysearch.org/reservation/v1}astro...");
  1860. #endif
  1861. status = xmlTextWriterEndElement(writer);
  1862. if (status < 0) {
  1863. [NSException raise: @"XMLWriteError"
  1864. format: @"Error writing end child element {http://api.familysearch.org/reservation/v1}astro."];
  1865. }
  1866. }
  1867. }
  1868. @end /* implementation FSRESERVATIONV1DateData (JAXB) */
  1869. /**
  1870. * An astro date.
  1871. @author Rob Lyon
  1872. */
  1873. @implementation FSRESERVATIONV1DateAstro
  1874. /**
  1875. * The earliest astro date.
  1876. */
  1877. - (NSString *) earliest
  1878. {
  1879. return _earliest;
  1880. }
  1881. /**
  1882. * The earliest astro date.
  1883. */
  1884. - (void) setEarliest: (NSString *) newEarliest
  1885. {
  1886. [newEarliest retain];
  1887. [_earliest release];
  1888. _earliest = newEarliest;
  1889. }
  1890. /**
  1891. * The lastest astro date.
  1892. */
  1893. - (NSString *) latest
  1894. {
  1895. return _latest;
  1896. }
  1897. /**
  1898. * The lastest astro date.
  1899. */
  1900. - (void) setLatest: (NSString *) newLatest
  1901. {
  1902. [newLatest retain];
  1903. [_latest release];
  1904. _latest = newLatest;
  1905. }
  1906. - (void) dealloc
  1907. {
  1908. [self setEarliest: nil];
  1909. [self setLatest: nil];
  1910. [super dealloc];
  1911. }
  1912. @end /* implementation FSRESERVATIONV1DateAstro */
  1913. /**
  1914. * Internal, private interface for JAXB reading and writing.
  1915. */
  1916. @interface FSRESERVATIONV1DateAstro (JAXB) <JAXBReading, JAXBWriting, JAXBType>
  1917. @end /*interface FSRESERVATIONV1DateAstro (JAXB)*/
  1918. /**
  1919. * Internal, private implementation for JAXB reading and writing.
  1920. */
  1921. @implementation FSRESERVATIONV1DateAstro (JAXB)
  1922. /**
  1923. * Read an instance of FSRESERVATIONV1DateAstro from an XML reader.
  1924. *
  1925. * @param reader The reader.
  1926. * @return An instance of FSRESERVATIONV1DateAstro defined by the XML reader.
  1927. */
  1928. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  1929. {
  1930. FSRESERVATIONV1DateAstro *_fSRESERVATIONV1DateAstro = [[FSRESERVATIONV1DateAstro alloc] init];
  1931. NS_DURING
  1932. {
  1933. [_fSRESERVATIONV1DateAstro initWithReader: reader];
  1934. }
  1935. NS_HANDLER
  1936. {
  1937. [_fSRESERVATIONV1DateAstro dealloc];
  1938. _fSRESERVATIONV1DateAstro = nil;
  1939. [localException raise];
  1940. }
  1941. NS_ENDHANDLER
  1942. [_fSRESERVATIONV1DateAstro autorelease];
  1943. return _fSRESERVATIONV1DateAstro;
  1944. }
  1945. /**
  1946. * Initialize this instance of FSRESERVATIONV1DateAstro according to
  1947. * the XML being read from the reader.
  1948. *
  1949. * @param reader The reader.
  1950. */
  1951. - (id) initWithReader: (xmlTextReaderPtr) reader
  1952. {
  1953. return [super initWithReader: reader];
  1954. }
  1955. /**
  1956. * Write the XML for this instance of FSRESERVATIONV1DateAstro to the writer.
  1957. * Note that since we're only writing the XML type,
  1958. * No start/end element will be written.
  1959. *
  1960. * @param reader The reader.
  1961. */
  1962. - (void) writeXMLType: (xmlTextWriterPtr) writer
  1963. {
  1964. [super writeXMLType:writer];
  1965. }
  1966. //documentation inherited.
  1967. - (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader
  1968. {
  1969. void *_child_accessor;
  1970. if ([super readJAXBAttribute: reader]) {
  1971. return YES;
  1972. }
  1973. return NO;
  1974. }
  1975. //documentation inherited.
  1976. - (BOOL) readJAXBValue: (xmlTextReaderPtr) reader
  1977. {
  1978. return [super readJAXBValue: reader];
  1979. }
  1980. //documentation inherited.
  1981. - (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader
  1982. {
  1983. id __child;
  1984. void *_child_accessor;
  1985. int status, depth;
  1986. if ([super readJAXBChildElement: reader]) {
  1987. return YES;
  1988. }
  1989. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
  1990. && xmlStrcmp(BAD_CAST "earliest", xmlTextReaderConstLocalName(reader)) == 0
  1991. && xmlStrcmp(BAD_CAST "http://api.familysearch.org/reservation/v1", xmlTextReaderConstNamespaceUri(reader)) == 0) {
  1992. #if DEBUG_ENUNCIATE > 1
  1993. NSLog(@"Attempting to read choice {http://api.familysearch.org/reservation/v1}earliest of type {http://www.w3.org/2001/XMLSchema}string.");
  1994. #endif
  1995. __child = [NSString readXMLType: reader];
  1996. #if DEBUG_ENUNCIATE > 1
  1997. NSLog(@"successfully read choice {http://api.familysearch.org/reservation/v1}earliest of type {http://www.w3.org/2001/XMLSchema}string.");
  1998. #endif
  1999. [self setEarliest: __child];
  2000. return YES;
  2001. } //end "if choice"
  2002. if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
  2003. && xmlStrcmp(BAD_CAST "latest", xmlTextReaderConstLocalName(reader)) == 0
  2004. && xmlStrcmp(BAD_CAST "http://api.familysearch.org/reservation/v1", xmlTextReaderConstNamespaceUri(reader)) == 0) {
  2005. #if DEBUG_ENUNCIATE > 1
  2006. NSLog(@"Attempting to read choice {http://api.familysearch.org/reservation/v1}latest of type {http://www.w3.org/2001/XMLSchema}string.");
  2007. #endif
  2008. __child = [NSString readXMLType: reader];
  2009. #if DEBUG_ENUNCIATE > 1
  2010. NSLog(@"successfully read choice {http://api.familysearch.org/reservation/v1}latest of type {http://www.w3.org/2001/XMLSchema}string.");
  2011. #endif
  2012. [self setLatest: __child];
  2013. return YES;
  2014. } //end "if choice"
  2015. return NO;
  2016. }
  2017. //documentation inherited.
  2018. - (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader
  2019. {
  2020. return [super readUnknownJAXBChildElement: reader];
  2021. }
  2022. //documentation inherited.
  2023. - (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader
  2024. {
  2025. [super readUnknownJAXBAttribute: reader];
  2026. }
  2027. //documentation inherited.
  2028. - (void) writeJAXBAttributes: (xmlTextWriterPtr) writer
  2029. {
  2030. int status;
  2031. [super writeJAXBAttributes: writer];
  2032. }
  2033. //documentation inherited.
  2034. - (void) writeJAXBValue: (xmlTextWriterPtr) writer
  2035. {
  2036. [super writeJAXBValue: writer];
  2037. }
  2038. /**
  2039. * Method for writing the child elements.
  2040. *
  2041. * @param writer The writer.
  2042. */
  2043. - (void) writeJAXBChildElements: (xmlTextWriterPtr) writer
  2044. {
  2045. int status;
  2046. id __item;
  2047. NSEnumerator *__enumerator;
  2048. [super writeJAXBChildElements: writer];
  2049. if ([self earliest]) {
  2050. status = xmlTextWriterStartElementNS(writer, BAD_CAST "reservation_v1", BAD_CAST "earliest", NULL);
  2051. if (status < 0) {
  2052. [NSException raise: @"XMLWriteError"
  2053. format: @"Error writing start child element {http://api.familysearch.org/reservation/v1}earliest."];
  2054. }
  2055. #if DEBUG_ENUNCIATE > 1
  2056. NSLog(@"writing element {http://api.familysearch.org/reservation/v1}earliest...");
  2057. #endif
  2058. [[self earliest] writeXMLType: writer];
  2059. #if DEBUG_ENUNCIATE > 1
  2060. NSLog(@"successfully wrote element {http://api.familysearch.org/reservation/v1}earliest...");
  2061. #endif
  2062. status = xmlTextWriterEndElement(writer);
  2063. if (status < 0) {
  2064. [NSException raise: @"XMLWriteError"
  2065. format: @"Error writing end child element {http://api.familysearch.org/reservation/v1}earliest."];
  2066. }
  2067. }
  2068. if ([self latest]) {
  2069. status = xmlTextWriterStartElementNS(writer, BAD_CAST "reservation_v1", BAD_CAST "latest", NULL);
  2070. if (status < 0) {
  2071. [NSException raise: @"XMLWriteError"
  2072. format: @"Error writing start child element {http://api.familysearch.org/reservation/v1}latest."];
  2073. }
  2074. #if DEBUG_ENUNCIATE > 1
  2075. NSLog(@"writing element {http://api.familysearch.org/reservation/v1}latest...");
  2076. #endif
  2077. [[self latest] writeXMLType: writer];
  2078. #if DEBUG_ENUNCIATE > 1
  2079. NSLog(@"successfully wrote element {http://api.familysearch.org/reservation/v1}latest...");
  2080. #endif
  2081. status = xmlTextWriterEndElement(writer);
  2082. if (status < 0) {
  2083. [NSException raise: @"XMLWriteError"
  2084. format: @"Error writing end child element {http://api.familysearch.org/reservation/v1}latest."];
  2085. }
  2086. }
  2087. }
  2088. @end /* implementation FSRESERVATIONV1DateAstro (JAXB) */
  2089. /**
  2090. * a Reference to a Contributor. This is currently used for the owner of a {@link Reservation}.
  2091. @author PabstEC
  2092. */
  2093. @implementation FSRESERVATIONV1ContributorReference
  2094. /**
  2095. * the reference
  2096. */
  2097. - (NSString *) ref
  2098. {
  2099. return _ref;
  2100. }
  2101. /**
  2102. * the reference
  2103. */
  2104. - (void) setRef: (NSString *) newRef
  2105. {
  2106. [newRef retain];
  2107. [_ref release];
  2108. _ref = newRef;
  2109. }
  2110. - (void) dealloc
  2111. {
  2112. [self setRef: nil];
  2113. [super dealloc];
  2114. }
  2115. @end /* implementation FSRESERVATIONV1ContributorReference */
  2116. /**
  2117. * Internal, private interface for JAXB reading and writing.
  2118. */
  2119. @interface FSRESERVATIONV1ContributorReference (JAXB) <JAXBReading, JAXBWriting, JAXBType>
  2120. @end /*interface FSRESERVATIONV1ContributorReference (JAXB)*/
  2121. /**
  2122. * Internal, private implementation for JAXB reading and writing.
  2123. */
  2124. @implementation FSRESERVATIONV1ContributorReference (JAXB)
  2125. /**
  2126. * Read an instance of FSRESERVATIONV1ContributorReference from an XML reader.
  2127. *
  2128. * @param reader The reader.
  2129. * @return An instance of FSRESERVATIONV1ContributorReference defined by the XML reader.
  2130. */
  2131. + (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader
  2132. {
  2133. FSRESERVATIONV1ContributorReference *_fSRESERVATIONV1ContributorReference = [[FSRESERVATIONV1ContributorReference alloc] init];
  2134. NS_DURING
  2135. {
  2136. [_fSRESERVATIONV1ContributorReference initWithReader: reader];
  2137. }
  2138. NS_HANDLER
  2139. {
  2140. [_fSRESERVATIONV1ContributorReference dealloc];
  2141. _fSRESERVATIONV1ContributorReference = nil;
  2142. [localException raise];
  2143. }
  2144. NS_ENDHANDLER
  2145. [_fSRESERVATIONV1ContributorReference autorelease];
  2146. return _fSRESERVATIONV1ContributorReference;
  2147. }
  2148. /**
  2149. * Initialize this instance of FSRESERVATIONV1ContributorReference according to
  2150. * the XML being read from the reader.
  2151. *
  2152. * @param reader The reader.
  2153. */
  2154. - (id) initWithReader: (xmlTextReaderPtr) reader
  2155. {
  2156. return [super initWithReader: reader];
  2157. }
  2158. /**
  2159. * Write the XML for this instance of FSRESERVATIONV1ContributorReference to the writer.
  2160. * Note that since we're only writing the XML type,
  2161. * No start/end element will be written.
  2162. *
  2163. * @param reader The reader.
  2164. */
  2165. - (void) writeXMLType: (xmlTextWriterPtr) writer
  2166. {
  2167. [super writeXMLType:writer];
  2168. }
  2169. //documentation inherited.
  2170. - (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader
  2171. {
  2172. void *_child_accessor;
  2173. if ([super readJAXBAttribute: reader]) {
  2174. return YES;
  2175. }
  2176. if ((xmlStrcmp(BAD_CAST "ref", xmlTextReaderConstLocalName(reader)) == 0) && (xmlTextReaderConstNamespaceUri(reader) == NULL)) {
  2177. #if DEBUG_ENUNCIATE > 1
  2178. NSLog(@"Attempting to read attribute {}ref...");
  2179. #endif
  2180. [self setRef: (NSString*) [NSString readXMLType: reader]];
  2181. #if DEBUG_ENUNCIATE > 1
  2182. NSLog(@"successfully read attribute {}ref...");
  2183. #endif
  2184. return YES;
  2185. }
  2186. return NO;
  2187. }
  2188. //do