Created
July 5, 2013 16:58
-
-
Save stoicflame/5935846 to your computer and use it in GitHub Desktop.
This is a sample of [Enunciate](http://enunciate.codehaus.org)-generated Objective-C code. Since I'm not an Objective-C programmer, I'm looking for any feedback on how to make this better. Help me out by forking and/or commenting as needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* | |
* Generated by <a href="http://enunciate.codehaus.org">Enunciate</a>. | |
*/ | |
#import <libxml/xmlwriter.h> | |
#import <libxml/xmlreader.h> | |
#import <Foundation/Foundation.h> | |
#ifndef DEBUG_ENUNCIATE | |
//turn off enunciate debugging. | |
#define DEBUG_ENUNCIATE 0 | |
#endif | |
/*******************xml utilities************************************/ | |
int xmlTextReaderAdvanceToNextStartOrEndElement(xmlTextReaderPtr reader); | |
int xmlTextReaderSkipElement(xmlTextReaderPtr reader); | |
xmlChar *xmlTextReaderReadEntireNodeValue(xmlTextReaderPtr reader); | |
/** | |
* Enunciate-specific interfaces and protocols. | |
*/ | |
#ifndef ENUNCIATE_OBJC_TYPES | |
#define ENUNCIATE_OBJC_TYPES | |
/** | |
* Protocol defining an Enunciate XML I/O methods. | |
*/ | |
@protocol EnunciateXML | |
/** | |
* Read an instance from XML. | |
* | |
* @param xml The XML to read. | |
*/ | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml; | |
/** | |
* Write this instance as XML. | |
* | |
* @return The XML. | |
*/ | |
- (NSData *) writeToXML; | |
@end /*protocol EnunciateXML*/ | |
/** | |
* A basic XML node. Can be an element or an attribute. Used | |
* instead of NSXMLElement because it's not supported on all | |
* platforms yet. | |
*/ | |
@interface JAXBBasicXMLNode : NSObject | |
{ | |
@private | |
NSString *_name; | |
NSString *_ns; | |
NSString *_prefix; | |
NSString *_value; | |
NSArray *_childElements; | |
NSArray *_attributes; | |
} | |
/** | |
* Accessor for the (local) name of the XML node. | |
* | |
* @return The (local) name of the XML node. | |
*/ | |
- (NSString *) name; | |
/** | |
* Accessor for the (local) name of the XML node. | |
* | |
* @param newName The (local) name of the XML node. | |
*/ | |
- (void) setName: (NSString *) newName; | |
/** | |
* Accessor for the namespace of the XML node. | |
* | |
* @return The namespace of the XML node. | |
*/ | |
- (NSString *) ns; | |
/** | |
* Accessor for the namespace of the XML node. | |
* | |
* @param newNs The namespace of the XML node. | |
*/ | |
- (void) setNs: (NSString *) newNs; | |
/** | |
* Accessor for the namespace prefix of the XML node. | |
* | |
* @return The namespace prefix of the XML node. | |
*/ | |
- (NSString *) prefix; | |
/** | |
* Accessor for the namespace prefix of the XML node. | |
* | |
* @param newPrefix The namespace prefix of the XML node. | |
*/ | |
- (void) setPrefix: (NSString *) newPrefix; | |
/** | |
* Accessor for the value of the XML node. | |
* | |
* @return The value of the XML node. | |
*/ | |
- (NSString *) value; | |
/** | |
* Accessor for the value of the XML node. | |
* | |
* @param newValue The value of the XML node. | |
*/ | |
- (void) setValue: (NSString *) newValue; | |
/** | |
* Accessor for the child elements of the XML node. | |
* | |
* @return The child elements of the XML node. | |
*/ | |
- (NSArray *) childElements; | |
/** | |
* Accessor for the child elements of the XML node. | |
* | |
* @param newValue The child elements of the XML node. | |
*/ | |
- (void) setChildElements: (NSArray *) newChildElements; | |
/** | |
* Accessor for the attributes of the XML node. | |
* | |
* @return The attributes of the XML node. | |
*/ | |
- (NSArray *) attributes; | |
/** | |
* Accessor for the attributes of the XML node. | |
* | |
* @param newAttributes The attributes of the XML node. | |
*/ | |
- (void) setAttributes: (NSArray *) newAttributes; | |
@end /*interface JAXBBasicXMLNode*/ | |
/** | |
* A basic XML node. Can be an element or an attribute. Used | |
* instead of NSXMLElement because it's not supported on all | |
* platforms yet. | |
*/ | |
@interface QName : NSObject | |
{ | |
@private | |
NSString *_localPart; | |
NSString *_namespaceURI; | |
NSString *_prefix; | |
} | |
/** | |
* Accessor for the local part of the QName. | |
* | |
* @return The local part of the QName. | |
*/ | |
- (NSString *) localPart; | |
/** | |
* Accessor for the local part of the QName. | |
* | |
* @param newLocalPart The new local part of the QName. | |
*/ | |
- (void) setLocalPart: (NSString *) newLocalPart; | |
/** | |
* Accessor for the namespace URI of the QName. | |
* | |
* @return The namespace URI of the QName. | |
*/ | |
- (NSString *) namespaceURI; | |
/** | |
* Accessor for the namespace URI of the QName. | |
* | |
* @param newNamespaceURI The new namespace URI of the QName. | |
*/ | |
- (void) setNamespaceURI: (NSString *) newNamespaceURI; | |
/** | |
* Accessor for the namespace prefix of the QName. | |
* | |
* @return The namespace prefix of the QName. | |
*/ | |
- (NSString *) prefix; | |
/** | |
* Accessor for the namespace prefix of the QName. | |
* | |
* @param newPrefix The namespace prefix of the QName. | |
*/ | |
- (void) setPrefix: (NSString *) newPrefix; | |
@end /*interface QName*/ | |
#endif /* ENUNCIATE_OBJC_TYPES */ | |
/** | |
* Protocol defining a JAXB (see https://jaxb.dev.java.net/) type. | |
*/ | |
@protocol JAXBType | |
/** | |
* Read an XML type from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of the object defining the JAXB type. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader; | |
/** | |
* Initialize the object with an XML reader. | |
* | |
* @param reader The XML reader from which to initialize the values of this type. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader; | |
/** | |
* Write this instance of a JAXB type to a writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer; | |
@end /*protocol JAXBType*/ | |
/** | |
* Protocol defining a JAXB (see https://jaxb.dev.java.net/) element. | |
*/ | |
@protocol JAXBElement | |
/** | |
* Read the XML element from an XML reader. It is assumed | |
* that the reader is pointing at the start element (be careful | |
* that it's not still pointing to the XML document). | |
* | |
* @param reader The reader. | |
* @return An instance of the object defining the JAXB element. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader; | |
/** | |
* Write this instance of a JAXB element to a writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer; | |
/** | |
* Write this instance of a JAXB element to a writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs; | |
@end /*protocol JAXBElement*/ | |
/** | |
* Protocol defining methods for events that occur | |
* when reading/parsing XML. Intended for internal | |
* use only. | |
*/ | |
@protocol JAXBReading | |
/** | |
* Method for reading an attribute. | |
* | |
* @param reader The reader pointing to the attribute. | |
* @return Whether the attribute was read. | |
*/ | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader; | |
/** | |
* Method for reading the value of an element. | |
* | |
* @param reader The reader pointing to the element containing a value. | |
* @return Whether the value was read. | |
*/ | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader; | |
/** | |
* Method for reading a child element. If (and only if) the child | |
* element was handled, the element in the reader should be | |
* "consumed" and the reader will be pointing to the end element. | |
* | |
* @param reader The reader pointing to the child element. | |
* @return Whether the child element was read. | |
*/ | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader; | |
/** | |
* Method for reading an unknown attribute. | |
* | |
* @param reader The reader pointing to the unknown attribute. | |
* @return Whether the attribute was read. | |
*/ | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader; | |
/** | |
* Method for reading an unknown child element. Implementations | |
* must be responsible for "consuming" the child element. | |
* | |
* @param reader The reader pointing to the unknown child element. | |
* @return The status of the reader after having consumed the unknown child element. | |
*/ | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader; | |
@end /*protocol JAXBReading*/ | |
/** | |
* Protocol defining methods for events that occur | |
* when writing XML. Intended for internal | |
* use only. | |
*/ | |
@protocol JAXBWriting | |
/** | |
* Method for writing the attributes. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer; | |
/** | |
* Method for writing the element value. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer; | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer; | |
@end /*protocol JAXBWriting*/ | |
/** | |
* Declaration of the JAXB type, element, events for a base object. | |
*/ | |
@interface NSObject (JAXB) <JAXBType, JAXBElement, JAXBReading, JAXBWriting> | |
@end | |
/*******************boolean************************************/ | |
/** | |
* Read a boolean value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return YES if "true" was read. NO otherwise. | |
*/ | |
BOOL *xmlTextReaderReadBooleanType(xmlTextReaderPtr reader); | |
/** | |
* Write a boolean value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteBooleanType(xmlTextWriterPtr writer, BOOL *value); | |
/*******************byte************************************/ | |
/** | |
* Read a byte value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the byte. | |
*/ | |
unsigned char *xmlTextReaderReadByteType(xmlTextReaderPtr reader); | |
/** | |
* Write a byte value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteByteType(xmlTextWriterPtr writer, unsigned char *value); | |
/*******************double************************************/ | |
/** | |
* Read a double value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the double. | |
*/ | |
double *xmlTextReaderReadDoubleType(xmlTextReaderPtr reader); | |
/** | |
* Write a double value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteDoubleType(xmlTextWriterPtr writer, double *value); | |
/*******************float************************************/ | |
/** | |
* Read a float value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the float. | |
*/ | |
float *xmlTextReaderReadFloatType(xmlTextReaderPtr reader); | |
/** | |
* Write a float value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteFloatType(xmlTextWriterPtr writer, float *value); | |
/*******************int************************************/ | |
/** | |
* Read a int value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @param value The value to be written. | |
* @return the int. | |
*/ | |
int *xmlTextReaderReadIntType(xmlTextReaderPtr reader); | |
/** | |
* Write a int value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteIntType(xmlTextWriterPtr writer, int *value); | |
/*******************long************************************/ | |
/** | |
* Read a long value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the long. | |
*/ | |
long *xmlTextReaderReadLongType(xmlTextReaderPtr reader); | |
/** | |
* Write a long value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteLongType(xmlTextWriterPtr writer, long *value); | |
/*******************short************************************/ | |
/** | |
* Read a short value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the short. | |
*/ | |
short *xmlTextReaderReadShortType(xmlTextReaderPtr reader); | |
/** | |
* Write a short value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteShortType(xmlTextWriterPtr writer, short *value); | |
/*******************unsigned short***************************/ | |
/** | |
* Read an unsigned short value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the unsigned short. | |
*/ | |
unsigned short *xmlTextReaderReadUnsignedShortType(xmlTextReaderPtr reader); | |
/** | |
* Write an unsigned short value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteUnsignedShortType(xmlTextWriterPtr writer, unsigned short *value); | |
/*******************char************************************/ | |
/** | |
* Read a character value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the character. | |
*/ | |
xmlChar *xmlTextReaderReadCharacterType(xmlTextReaderPtr reader); | |
/** | |
* Write a character value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteCharacterType(xmlTextWriterPtr writer, xmlChar *value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "enunciate-common.h" | |
/** | |
* Enunciate-specific C functions. | |
*/ | |
#ifndef ENUNCIATE_C_UTILITIES | |
#define ENUNCIATE_C_UTILITIES | |
/*******************xml utilities************************************/ | |
int xmlTextReaderAdvanceToNextStartOrEndElement(xmlTextReaderPtr reader) { | |
int status = xmlTextReaderRead(reader); | |
while (status && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT && xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) { | |
status = xmlTextReaderRead(reader); | |
} | |
return status; | |
} | |
int xmlTextReaderSkipElement(xmlTextReaderPtr reader) { | |
int status = xmlTextReaderNext(reader); | |
while (status && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT && xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT) { | |
status = xmlTextReaderRead(reader); | |
} | |
return status; | |
} | |
xmlChar *xmlTextReaderReadEntireNodeValue(xmlTextReaderPtr reader) { | |
xmlChar *buffer = calloc(1, sizeof(xmlChar)); | |
const xmlChar *snippet; | |
int status; | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ATTRIBUTE) { | |
return xmlTextReaderValue(reader); | |
} | |
else if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
status = xmlTextReaderRead(reader); | |
while (status && (xmlTextReaderNodeType(reader) == XML_READER_TYPE_TEXT || xmlTextReaderNodeType(reader) == XML_READER_TYPE_CDATA || xmlTextReaderNodeType(reader) == XML_READER_TYPE_ENTITY_REFERENCE)) { | |
snippet = xmlTextReaderConstValue(reader); | |
buffer = realloc(buffer, (xmlStrlen(buffer) + xmlStrlen(snippet) + 1) * sizeof(xmlChar)); | |
xmlStrcat(buffer, snippet); | |
status = xmlTextReaderRead(reader); | |
} | |
} | |
return buffer; | |
} | |
/*******************base 64 utilities************************************/ | |
/* | |
* Base64 Translation Table as described in RFC1113. | |
* | |
* This code was graciously ripped from http://base64.sourceforge.net | |
*/ | |
const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
/* | |
* Base64 Translation Table to decode (created by author) | |
* | |
* This code was graciously ripped from http://base64.sourceforge.net | |
*/ | |
const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq"; | |
/* | |
* encode 3 8-bit binary bytes as 4 '6-bit' characters | |
* | |
* This code was graciously ripped from http://base64.sourceforge.net | |
* | |
* @param in the block to encode | |
* @param out the block to encode to | |
* @param len the length of the 'in' block. | |
*/ | |
void _encode_base64_block(unsigned char in[3], unsigned char out[4], int len) { | |
out[0] = cb64[ in[0] >> 2 ]; | |
out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ]; | |
out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '='); | |
out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '='); | |
} | |
/* | |
* decode 4 '6-bit' characters into 3 8-bit binary bytes | |
* | |
* This code was graciously ripped from http://base64.sourceforge.net | |
*/ | |
void _decode_base64_block( unsigned char in[4], unsigned char out[3] ) | |
{ | |
out[ 0 ] = (unsigned char ) (in[0] << 2 | in[1] >> 4); | |
out[ 1 ] = (unsigned char ) (in[1] << 4 | in[2] >> 2); | |
out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | in[3]); | |
} | |
/* | |
* base64 encode a stream adding padding and line breaks as per spec. | |
* | |
* This code was graciously ripped from http://base64.sourceforge.net | |
* | |
* @param instream The stream to encode. | |
* @param insize The size of the stream to encode. | |
* @return The encoded string. | |
*/ | |
xmlChar *_encode_base64(unsigned char *instream, int insize) { | |
unsigned char in[3]; | |
unsigned char out[4]; | |
xmlChar *encoded; | |
int i, in_index = 0, out_index = 0, blocklen; | |
if (insize == 0) { | |
return BAD_CAST "\0"; | |
} | |
encoded = calloc(((insize / 3) * 4) + 10, sizeof(xmlChar)); | |
while (in_index <= insize) { | |
blocklen = 0; | |
for (i = 0; i < 3; i++) { | |
in[i] = instream[in_index++]; | |
if (in_index <= insize) { | |
blocklen++; | |
} | |
else { | |
in[i] = 0; | |
} | |
} | |
if (blocklen) { | |
_encode_base64_block(in, out, blocklen); | |
for( i = 0; i < 4; i++ ) { | |
encoded[out_index++] = out[i]; | |
} | |
} | |
} | |
return encoded; | |
} | |
/* | |
* Decode a base64 encoded stream discarding padding, line breaks and noise | |
* | |
* This code was graciously ripped from http://base64.sourceforge.net | |
* | |
* @param invalue The string to decode. | |
* @param outsize Holder for the length of the returned data. | |
* @return The decoded data. | |
*/ | |
unsigned char *_decode_base64( const xmlChar *invalue, int *outsize ) { | |
xmlChar in[4]; | |
unsigned char out[3], v; | |
int i, in_index = 0, out_index = 0, blocklen; | |
unsigned char *outstream; | |
if (invalue == NULL) { | |
return NULL; | |
} | |
outstream = calloc(((xmlStrlen(invalue) / 4) * 3) + 1, sizeof(unsigned char)); | |
while (invalue[in_index] != '\0') { | |
for (blocklen = 0, i = 0; i < 4 && invalue[in_index]; i++) { | |
v = 0; | |
while (invalue[in_index] != '\0' && v == 0) { | |
v = (unsigned char) invalue[in_index++]; | |
v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]); | |
if (v) { | |
v = (unsigned char) ((v == '$') ? 0 : v - 61); | |
} | |
} | |
if (invalue[in_index] != '\0') { | |
blocklen++; | |
if (v) { | |
in[i] = (unsigned char) (v - 1); | |
} | |
} | |
else { | |
in[i] = 0; | |
} | |
} | |
if (blocklen) { | |
_decode_base64_block( in, out ); | |
for( i = 0; i < blocklen - 1; i++ ) { | |
outstream[out_index++] = out[i]; | |
} | |
} | |
} | |
if (outsize != NULL) { | |
*outsize = out_index; | |
} | |
return outstream; | |
} | |
#endif /* ENUNCIATE_C_UTILITIES */ | |
#ifndef ENUNCIATE_OBJC_CLASSES | |
#define ENUNCIATE_OBJC_CLASSES | |
/** | |
* Implementation of the JAXB type, element, events for a base object. | |
*/ | |
@implementation NSObject (JAXB) | |
/** | |
* Read the XML type from the reader; an instance of NSXMLElement. | |
* | |
* @param reader The reader. | |
* @return An instance of NSXMLElement | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
return [JAXBBasicXMLNode readXMLType: reader]; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
int status, depth; | |
if ((self = [self init])) { | |
if (xmlTextReaderHasAttributes(reader)) { | |
while (xmlTextReaderMoveToNextAttribute(reader)) { | |
if ([self readJAXBAttribute: reader] == NO) { | |
[self readUnknownJAXBAttribute: reader]; | |
} | |
} | |
status = xmlTextReaderMoveToElement(reader); | |
if (!status) { | |
//panic: unable to return to the element node. | |
[NSException raise: @"XMLReadError" | |
format: @"Error moving back to element position from attributes."]; | |
} | |
} | |
if ([self readJAXBValue: reader] == NO) { | |
//no value handled; attempt to process child elements | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
depth = xmlTextReaderDepth(reader);//track the depth. | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
while (xmlTextReaderDepth(reader) > depth) { | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Error handling a child element."]; | |
} | |
else if ([self readJAXBChildElement: reader]) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
} | |
else { | |
status = [self readUnknownJAXBChildElement: reader]; | |
} | |
} | |
} | |
else { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing past an empty child element."]; | |
} | |
} | |
} | |
} | |
return self; | |
} | |
/** | |
* Write the XML type value of this object to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[self writeJAXBAttributes: writer]; | |
[self writeJAXBValue: writer]; | |
[self writeJAXBChildElements: writer]; | |
} | |
/** | |
* Read the XML element from the reader; an instance of NSXMLElement. | |
* | |
* @param reader The reader. | |
* @return An instance of NSXMLElement | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader | |
{ | |
return (id<JAXBElement>) [JAXBBasicXMLNode readXMLType: reader]; | |
} | |
/** | |
* No op; root objects don't have an element name/namespace. Subclasses must override. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
//no-op | |
} | |
/** | |
* No op; root objects don't have an element name/namespace. Subclasses must override. | |
* | |
* @param writer The writer. | |
* @param writeNs Ignored. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
//no-op | |
} | |
/** | |
* No-op; base objects do not handle any attributes. | |
* | |
* @param reader The reader pointing to the attribute. | |
* @return NO | |
*/ | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
return NO; | |
} | |
/** | |
* No-op; base objects do not handle any values. | |
* | |
* @param reader The reader pointing to the element containing a value. | |
* @return NO | |
*/ | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return NO; | |
} | |
/** | |
* No-op; base objects do not handle any child elements. | |
* | |
* @param reader The reader pointing to the child element. | |
* @return NO | |
*/ | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return NO; | |
} | |
/** | |
* No-op; base objects do not handle any attributes. | |
* | |
* @param reader The reader pointing to the unknown attribute. | |
*/ | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
} | |
/** | |
* Just skips the unknown element; base objects do not handle any child elements. | |
* | |
* @param reader The reader pointing to the unknown child element. | |
* @return The status of the reader after skipping the unknown child element. | |
*/ | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return xmlTextReaderSkipElement(reader); | |
} | |
/** | |
* No-op; base objects have no attributes. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
//no-op. | |
} | |
/** | |
* No-op; base objects have no element value. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
//no-op. | |
} | |
/** | |
* No-op; base objects have no child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
//no-op. | |
} | |
@end /*NSObject (JAXB)*/ | |
/** | |
* Implementation of the JAXB type, element for an xml element. | |
*/ | |
@implementation JAXBBasicXMLNode | |
/** | |
* Accessor for the (local) name of the XML node. | |
* | |
* @return The (local) name of the XML node. | |
*/ | |
- (NSString *) name | |
{ | |
return _name; | |
} | |
/** | |
* Accessor for the (local) name of the XML node. | |
* | |
* @param newName The (local) name of the XML node. | |
*/ | |
- (void) setName: (NSString *) newName | |
{ | |
[newName retain]; | |
[_name release]; | |
_name = newName; | |
} | |
/** | |
* Accessor for the namespace of the XML node. | |
* | |
* @return The namespace of the XML node. | |
*/ | |
- (NSString *) ns | |
{ | |
return _ns; | |
} | |
/** | |
* Accessor for the namespace of the XML node. | |
* | |
* @param newNs The namespace of the XML node. | |
*/ | |
- (void) setNs: (NSString *) newNs | |
{ | |
[newNs retain]; | |
[_ns release]; | |
_ns = newNs; | |
} | |
/** | |
* Accessor for the namespace prefix of the XML node. | |
* | |
* @return The namespace prefix of the XML node. | |
*/ | |
- (NSString *) prefix | |
{ | |
return _prefix; | |
} | |
/** | |
* Accessor for the namespace prefix of the XML node. | |
* | |
* @param newPrefix The namespace prefix of the XML node. | |
*/ | |
- (void) setPrefix: (NSString *) newPrefix | |
{ | |
[newPrefix retain]; | |
[_prefix release]; | |
_prefix = newPrefix; | |
} | |
/** | |
* Accessor for the value of the XML node. | |
* | |
* @return The value of the XML node. | |
*/ | |
- (NSString *) value | |
{ | |
return _value; | |
} | |
/** | |
* Accessor for the value of the XML node. | |
* | |
* @param newValue The value of the XML node. | |
*/ | |
- (void) setValue: (NSString *) newValue | |
{ | |
[newValue retain]; | |
[_value release]; | |
_value = newValue; | |
} | |
/** | |
* Accessor for the child elements of the XML node. | |
* | |
* @return The child elements of the XML node. | |
*/ | |
- (NSArray *) childElements | |
{ | |
return _childElements; | |
} | |
/** | |
* Accessor for the child elements of the XML node. | |
* | |
* @param newValue The child elements of the XML node. | |
*/ | |
- (void) setChildElements: (NSArray *) newChildElements | |
{ | |
[newChildElements retain]; | |
[_childElements release]; | |
_childElements = newChildElements; | |
} | |
/** | |
* Accessor for the attributes of the XML node. | |
* | |
* @return The attributes of the XML node. | |
*/ | |
- (NSArray *) attributes | |
{ | |
return _attributes; | |
} | |
/** | |
* Accessor for the attributes of the XML node. | |
* | |
* @param newAttributes The attributes of the XML node. | |
*/ | |
- (void) setAttributes: (NSArray *) newAttributes | |
{ | |
[newAttributes retain]; | |
[_attributes release]; | |
_attributes = newAttributes; | |
} | |
- (void) dealloc { | |
[_name release]; | |
[_ns release]; | |
[_prefix release]; | |
[_value release]; | |
[_childElements release]; | |
[_attributes release]; | |
[super dealloc]; | |
} | |
@end /*implementation JAXBBasicXMLNode*/ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface JAXBBasicXMLNode (JAXB) <JAXBType, JAXBElement> | |
@end /*interface JAXBBasicXMLNode (JAXB)*/ | |
@implementation JAXBBasicXMLNode (JAXB) | |
/** | |
* Read the XML type from the reader; an instance of JAXBBasicXMLNode. | |
* | |
* @param reader The reader. | |
* @return An instance of JAXBBasicXMLNode | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
JAXBBasicXMLNode *node = [[JAXBBasicXMLNode alloc] init]; | |
NS_DURING | |
{ | |
[node initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
node = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[node autorelease]; | |
return node; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance of JAXBBasicXMLNode. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
int status, depth; | |
JAXBBasicXMLNode *child; | |
xmlChar *value = NULL; | |
const xmlChar *text; | |
NSMutableArray *children; | |
if ((self = [self init])) { | |
depth = xmlTextReaderDepth(reader); | |
[self setName: [NSString stringWithUTF8String: (const char *) xmlTextReaderLocalName(reader)]]; | |
[self setNs: [NSString stringWithUTF8String: (const char *) xmlTextReaderNamespaceUri(reader)]]; | |
[self setPrefix: [NSString stringWithUTF8String: (const char *)xmlTextReaderPrefix(reader)]]; | |
if (xmlTextReaderHasAttributes(reader)) { | |
child = nil; | |
children = [[NSMutableArray alloc] init]; | |
while (xmlTextReaderMoveToNextAttribute(reader)) { | |
child = [[JAXBBasicXMLNode alloc] init]; | |
[child setName: [NSString stringWithUTF8String: (const char *) xmlTextReaderLocalName(reader)]]; | |
[child setNs: [NSString stringWithUTF8String: (const char *)xmlTextReaderNamespaceUri(reader)]]; | |
[child setPrefix: [NSString stringWithUTF8String: (const char *) xmlTextReaderPrefix(reader)]]; | |
[child setValue: [NSString stringWithUTF8String: (const char *) xmlTextReaderValue(reader)]]; | |
[children addObject: child]; | |
[child release]; | |
} | |
[self setAttributes: children]; | |
[children release]; | |
status = xmlTextReaderMoveToElement(reader); | |
if (status < 1) { | |
//panic: unable to return to the element node. | |
[NSException raise: @"XMLReadError" | |
format: @"Error moving to element from attributes."]; | |
} | |
} | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
children = [[NSMutableArray alloc] init]; | |
status = xmlTextReaderRead(reader); | |
while (status == 1 && xmlTextReaderDepth(reader) > depth) { | |
switch (xmlTextReaderNodeType(reader)) { | |
case XML_READER_TYPE_ELEMENT: | |
child = (JAXBBasicXMLNode *) [JAXBBasicXMLNode readXMLType: reader]; | |
[children addObject: child]; | |
break; | |
case XML_READER_TYPE_TEXT: | |
case XML_READER_TYPE_CDATA: | |
text = xmlTextReaderConstValue(reader); | |
value = xmlStrncat(value, text, xmlStrlen(text)); | |
break; | |
default: | |
//skip anything else. | |
break; | |
} | |
status = xmlTextReaderRead(reader); | |
} | |
if (status < 1) { | |
//panic: xml read error | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading child elements."]; | |
} | |
if ([children count] > 0) { | |
[self setChildElements: children]; | |
} | |
if (value != NULL) { | |
[self setValue: [NSString stringWithUTF8String: (const char *) value]]; | |
} | |
[children release]; | |
} | |
} | |
return self; | |
} | |
/** | |
* Read the XML element from the reader; an instance of NSXMLElement. | |
* | |
* @param reader The reader. | |
* @return An instance of NSXMLElement | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader | |
{ | |
return (id<JAXBElement>) [JAXBBasicXMLNode readXMLType: reader]; | |
} | |
/** | |
* Write the basic node to an xml writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
NSEnumerator *enumerator; | |
JAXBBasicXMLNode *child; | |
xmlChar *childns, *childname, *childprefix, *childvalue; | |
status = xmlTextWriterStartElementNS(writer, _prefix ? BAD_CAST [_prefix UTF8String] : NULL, _name ? BAD_CAST [_name UTF8String] : NULL, _ns ? BAD_CAST [_ns UTF8String] : NULL); | |
if (status < 0) { | |
childns = BAD_CAST ""; | |
if (_ns) { | |
childns = BAD_CAST [_ns UTF8String]; | |
} | |
childname = BAD_CAST ""; | |
if (_name) { | |
childname = BAD_CAST [_name UTF8String]; | |
} | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {%s}%s for JAXBBasicXMLNode.", childns, childname]; | |
} | |
if (_attributes) { | |
enumerator = [_attributes objectEnumerator]; | |
while ( (child = (JAXBBasicXMLNode *)[enumerator nextObject]) ) { | |
childns = NULL; | |
if ([child ns]) { | |
childns = BAD_CAST [[child ns] UTF8String]; | |
} | |
childprefix = NULL; | |
if ([child prefix]) { | |
childprefix = BAD_CAST [[child prefix] UTF8String]; | |
} | |
childname = NULL; | |
if ([child name]) { | |
childname = BAD_CAST [[child name] UTF8String]; | |
} | |
childvalue = NULL; | |
if ([child value]) { | |
childvalue = BAD_CAST [[child value] UTF8String]; | |
} | |
status = xmlTextWriterWriteAttributeNS(writer, childprefix, childname, childns, childvalue); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute {%s}%s for JAXBBasicXMLNode.", childns, childname]; | |
} | |
} | |
} | |
if (_value) { | |
status = xmlTextWriterWriteString(writer, BAD_CAST [_value UTF8String]); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing value of JAXBBasicXMLNode."]; | |
} | |
} | |
if (_childElements) { | |
enumerator = [_childElements objectEnumerator]; | |
while ( (child = [enumerator nextObject]) ) { | |
[child writeXMLType: writer]; | |
} | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
childns = BAD_CAST ""; | |
if (_ns) { | |
childns = BAD_CAST [_ns UTF8String]; | |
} | |
childname = BAD_CAST ""; | |
if (_name) { | |
childname = BAD_CAST [_name UTF8String]; | |
} | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {%s}%s for JAXBBasicXMLNode.", childns, childname]; | |
} | |
} | |
/** | |
* Writes this node to a writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLType: writer]; | |
} | |
/** | |
* Writes this node to a writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
[self writeXMLType: writer]; | |
} | |
@end /* implementation JAXBBasicXMLNode (JAXB) */ | |
/** | |
* Implementation of the QName | |
*/ | |
@implementation QName | |
/** | |
* Accessor for the local part of the QName. | |
* | |
* @return The local part of the QName. | |
*/ | |
- (NSString *) localPart | |
{ | |
return _localPart; | |
} | |
/** | |
* Accessor for the local part of the QName. | |
* | |
* @param newLocalPart The local part of the QName. | |
*/ | |
- (void) setLocalPart: (NSString *) newLocalPart | |
{ | |
[newLocalPart retain]; | |
[_localPart release]; | |
_localPart = newLocalPart; | |
} | |
/** | |
* Accessor for the namespace URI of the QName. | |
* | |
* @return The namespace URI of the QName. | |
*/ | |
- (NSString *) namespaceURI | |
{ | |
return _namespaceURI; | |
} | |
/** | |
* Accessor for the namespace URI of the QName. | |
* | |
* @param newNamespaceURI The namespace URI of the QName. | |
*/ | |
- (void) setNamespaceURI: (NSString *) newNamespaceURI | |
{ | |
[newNamespaceURI retain]; | |
[_namespaceURI release]; | |
_namespaceURI = newNamespaceURI; | |
} | |
/** | |
* Accessor for the namespace prefix of the QName. | |
* | |
* @return The namespace prefix of the QName. | |
*/ | |
- (NSString *) prefix | |
{ | |
return _prefix; | |
} | |
/** | |
* Accessor for the namespace prefix of the QName. | |
* | |
* @param newPrefix The namespace prefix of the QName. | |
*/ | |
- (void) setPrefix: (NSString *) newPrefix | |
{ | |
[newPrefix retain]; | |
[_prefix release]; | |
_prefix = newPrefix; | |
} | |
- (void) dealloc { | |
[super dealloc]; | |
} | |
@end /*implementation QName*/ | |
/** | |
* Declaration of the JAXB type for a QName. | |
*/ | |
@interface QName (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a QName. | |
*/ | |
@implementation QName (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The QName that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
QName *qname = [[QName alloc] init]; | |
NS_DURING | |
{ | |
[qname initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
qname = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[qname autorelease]; | |
return qname; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
xmlChar *value = xmlTextReaderReadEntireNodeValue(reader); | |
int len = 0; | |
xmlChar *prefix; | |
if ((self = [self init])) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Reading QName value %s...\n", value); | |
#endif | |
if (value[len] == 0) { | |
[NSException raise: @"XMLReadError" | |
format: @"Empty QName value"]; | |
} | |
else if (value[0] == ':') { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"QName value that starts with ':'. Weird.\n"); | |
#endif | |
/* nasty but valid */ | |
[self setLocalPart: [NSString stringWithUTF8String: (const char *) xmlStrsub(value, 1, xmlStrlen(value) - 1)]]; | |
[self setNamespaceURI: @""]; | |
} | |
else { | |
/* | |
* look for the ':' | |
*/ | |
while ((value[len] != 0) && (value[len] != ':')) { | |
len++; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"QName ':' character found at %i.\n", len); | |
#endif | |
if (value[len] == 0) { | |
[self setLocalPart: [NSString stringWithUTF8String: (const char *) xmlStrdup(value)]]; | |
[self setNamespaceURI: @""]; | |
} | |
else { | |
prefix = xmlStrsub(value, 0, len); | |
[self setLocalPart: [NSString stringWithUTF8String: (const char *) xmlStrsub(value, len + 1, xmlStrlen(value) - len - 1)]]; | |
[self setNamespaceURI: [NSString stringWithUTF8String: (const char *) xmlTextReaderLookupNamespace(reader, prefix)]]; | |
free(prefix); | |
} | |
} | |
} | |
free(value); | |
return self; | |
} | |
/** | |
* Write the NSString to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
if ([[self localPart] length] == 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Attempt to write a QName with an empty local part."]; | |
} | |
if (([[self namespaceURI] length] == 0) || ([[self prefix] length] == 0)) { | |
xmlTextWriterWriteString(writer, BAD_CAST [[self localPart] UTF8String]); | |
} | |
else { | |
xmlTextWriterWriteFormatString(writer, "%s:%s", BAD_CAST [[self prefix] UTF8String], BAD_CAST [[self localPart] UTF8String]); | |
} | |
} | |
@end /*QName (JAXBType)*/ | |
/** | |
* Declaration of the JAXB type for a string. | |
*/ | |
@interface NSString (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a string. | |
*/ | |
@implementation NSString (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The NSString that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
return [NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)]; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
[NSException raise: @"XMLReadError" | |
format: @"An existing string cannot be modified."]; | |
return nil; | |
} | |
/** | |
* Write the NSString to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
xmlTextWriterWriteString(writer, BAD_CAST [self UTF8String]); | |
} | |
@end /*NSString (JAXBType)*/ | |
/** | |
* Declaration of the JAXB type for a big number. | |
*/ | |
@interface NSNumber (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a big number. | |
*/ | |
@implementation NSNumber (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The NSNumber that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
return [NSNumber numberWithLongLong: [[NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)] longLongValue]]; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
[NSException raise: @"XMLReadError" | |
format: @"An existing number cannot be modified."]; | |
return nil; | |
} | |
/** | |
* Write the NSNumber to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
xmlTextWriterWriteString(writer, BAD_CAST [[self description] UTF8String]); | |
} | |
@end /*NSNumber (JAXBType)*/ | |
/** | |
* Declaration of the JAXB type for a big number. | |
*/ | |
@interface NSDecimalNumber (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a big number. | |
*/ | |
@implementation NSDecimalNumber (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The NSDecimalNumber that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
return [NSDecimalNumber decimalNumberWithString: [NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)]]; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
[NSException raise: @"XMLReadError" | |
format: @"An existing decimal number cannot be modified."]; | |
return nil; | |
} | |
/** | |
* Write the NSDecimalNumber to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
xmlTextWriterWriteString(writer, BAD_CAST [[self description] UTF8String]); | |
} | |
@end /*NSDecimalNumber (JAXBType)*/ | |
/** | |
* Declaration of the JAXB type for a url. | |
*/ | |
@interface NSURL (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a url. | |
*/ | |
@implementation NSURL (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The NSURL that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
return [NSURL URLWithString: [NSString stringWithUTF8String: (const char *) xmlTextReaderReadEntireNodeValue(reader)]]; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
[NSException raise: @"XMLReadError" | |
format: @"An existing url cannot be modified."]; | |
return nil; | |
} | |
/** | |
* Write the NSURL to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
xmlTextWriterWriteString(writer, BAD_CAST [[self absoluteString] UTF8String]); | |
} | |
@end /*NSURL (JAXBType)*/ | |
/** | |
* Declaration of the JAXB type for binary data. | |
*/ | |
@interface NSData (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a binary data. | |
*/ | |
@implementation NSData (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The NSData that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
xmlChar *base64data = xmlTextReaderReadEntireNodeValue(reader); | |
int len; | |
unsigned char *data = _decode_base64(base64data, &len); | |
NSData *wrappedData = [NSData dataWithBytesNoCopy: data length: len]; | |
free(base64data); | |
return wrappedData; | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
[NSException raise: @"XMLReadError" | |
format: @"An existing NSData cannot be modified."]; | |
return nil; | |
} | |
/** | |
* Write the NSData to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
xmlChar *out = _encode_base64((unsigned char *)[self bytes], [self length]); | |
xmlTextWriterWriteString(writer, out); | |
free(out); | |
} | |
@end /*NSData (JAXBType)*/ | |
/** | |
* Declaration of the JAXB type for a big number. | |
*/ | |
@interface NSDate (JAXBType) <JAXBType> | |
@end | |
/** | |
* Implementation of the JAXB type for a big number. | |
*/ | |
@implementation NSDate (JAXBType) | |
/** | |
* Read the XML type from the reader. | |
* | |
* @param reader The reader. | |
* @return The NSDate that was read from the reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
xmlChar *timevalue = xmlTextReaderReadEntireNodeValue(reader); | |
NSInteger year = 0; | |
NSUInteger month = 1, day = 1, hour = 0, minute = 0, second = 0; | |
BOOL skip_time = NO; | |
int index = 0, token_index = 0, len = xmlStrlen(timevalue), offset_hour = 0, offset_minute = 0; | |
char token[len]; | |
if (len > (index + 5) && timevalue[index + 4] == '-') { | |
//assume we're at yyyy-MM-dd | |
token_index = 0; | |
while (index < len && timevalue[index] != '-') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
if (token_index != 4) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read dateTime %s; invalid year: %s", timevalue, token]; | |
} | |
year = atoi(token); | |
index++; | |
//go to next '-' character. | |
token_index = 0; | |
while (index < len && timevalue[index] != '-') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
if (token_index != 2) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read dateTime %s; invalid month: %s", timevalue, token]; | |
} | |
month = atoi(token); | |
index++; | |
//go to 'T', 'Z', '+', or '-' character. | |
token_index = 0; | |
while (index < len && timevalue[index] != 'T' && timevalue[index] != 'Z' && timevalue[index] != '-' && timevalue[index] != '+') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
if (token_index != 2) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read dateTime %s; invalid day of month: %s", timevalue, token]; | |
} | |
day = atoi(token); | |
if (timevalue[index] != 'T') { | |
skip_time = YES; | |
} | |
if (timevalue[index] != '-') { | |
index++; | |
} | |
} | |
if (skip_time == NO || (len > (index + 3) && timevalue[index + 2] == ':')) { | |
//assume we're at HH:mm:ss | |
//go to ':' character. | |
token_index = 0; | |
while (index < len && timevalue[index] != ':') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
if (token_index != 2) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read dateTime %s; invalid hour: %s", timevalue, token]; | |
} | |
hour = atoi(token); | |
index++; | |
//go to ':' character. | |
token_index = 0; | |
while (index < len && timevalue[index] != ':') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
if (token_index != 2) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read dateTime %s; invalid minute: %s", timevalue, token]; | |
} | |
minute = atoi(token); | |
index++; | |
//go to '+' or '-' or 'Z' character. | |
token_index = 0; | |
while (index < len && timevalue[index] != '+' && timevalue[index] != '-' && timevalue[index] != 'Z') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
if (token_index == 0) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read dateTime %s; invalid seconds: %s", timevalue, token]; | |
} | |
second = (NSUInteger) atof(token); | |
if (timevalue[index] != '-') { | |
index++; | |
} | |
} | |
//go to ':' character. | |
token_index = 0; | |
while (index < len && timevalue[index] != ':') { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
offset_hour += atoi(token); | |
index++; | |
//go to end. | |
token_index = 0; | |
while (index < len) { | |
token[token_index++] = timevalue[index++]; | |
} | |
token[token_index] = '\0'; | |
offset_minute += atoi(token); | |
//YYYY-MM-DD HH:MM:SS -HHHMM | |
free(timevalue); | |
NSString *dateString = [NSString stringWithFormat: @"%04i-%02i-%02i %02i:%02i:%02i %+03i%02i", year, month, day, hour, minute, second, offset_hour, offset_minute]; | |
#ifdef GNUSTEP | |
/* GNUstep code goes here ... */ | |
return [NSDate dateWithString: dateString]; | |
#else | |
/* Cocoa/Cocoa Touch native code goes here ... */ | |
// Create date formatter | |
static NSDateFormatter *dateFormatter = nil; | |
if (!dateFormatter) { | |
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4]; | |
NSLocale *enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]; | |
dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setLocale:enUSPOSIXLocale]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZ"]; | |
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; | |
[enUSPOSIXLocale release]; | |
} | |
return [dateFormatter dateFromString: dateString]; | |
#endif | |
} | |
/** | |
* Read an XML type from an XML reader into an existing instance. | |
* | |
* @param reader The reader. | |
* @param existing The existing instance into which to read values. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
[NSException raise: @"XMLReadError" | |
format: @"An existing date cannot be modified."]; | |
return nil; | |
} | |
/** | |
* Write the NSDate to the writer. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
#ifdef GNUSTEP | |
/* GNUstep code goes here ... */ | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat: @"%Y-%m-%dT%H:%M:%S %z" allowNaturalLanguage: NO]; | |
#else | |
/* Cocoa/Cocoa Touch native code goes here ... */ | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss ZZ"]; | |
#endif | |
xmlChar *timevalue = BAD_CAST [[formatter stringForObjectValue: self] UTF8String]; | |
timevalue[19] = timevalue[20]; | |
timevalue[20] = timevalue[21]; | |
timevalue[21] = timevalue[22]; | |
timevalue[22] = ':'; | |
xmlTextWriterWriteString(writer, timevalue); | |
[formatter release]; | |
} | |
@end /*NSDate (JAXBType)*/ | |
#endif /* ENUNCIATE_OBJC_CLASSES */ | |
#ifndef ENUNCIATE_XML_OBJC_PRIMITIVE_FUNCTIONS | |
#define ENUNCIATE_XML_OBJC_PRIMITIVE_FUNCTIONS | |
/*******************boolean************************************/ | |
/** | |
* Read a boolean value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return YES if "true" was read. NO otherwise. | |
*/ | |
BOOL *xmlTextReaderReadBooleanType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
BOOL *value = malloc(sizeof(BOOL)); | |
*value = (xmlStrcmp(BAD_CAST "true", nodeValue) == 0) ? YES : NO; | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a boolean value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteBooleanType(xmlTextWriterPtr writer, BOOL *value) { | |
if (*value) { | |
return xmlTextWriterWriteString(writer, BAD_CAST "true"); | |
} | |
else { | |
return xmlTextWriterWriteString(writer, BAD_CAST "false"); | |
} | |
} | |
/*******************byte************************************/ | |
/** | |
* Read a byte value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the byte. | |
*/ | |
unsigned char *xmlTextReaderReadByteType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
unsigned char *value = malloc(sizeof(unsigned char)); | |
*value = (unsigned char) atoi((char *) nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a byte value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteByteType(xmlTextWriterPtr writer, unsigned char *value) { | |
return xmlTextWriterWriteFormatString(writer, "%i", *value); | |
} | |
/*******************double************************************/ | |
/** | |
* Read a double value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the double. | |
*/ | |
double *xmlTextReaderReadDoubleType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
double *value = malloc(sizeof(double)); | |
*value = atof((char *) nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a double value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteDoubleType(xmlTextWriterPtr writer, double *value) { | |
return xmlTextWriterWriteFormatString(writer, "%f", *value); | |
} | |
/*******************float************************************/ | |
/** | |
* Read a float value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the float. | |
*/ | |
float *xmlTextReaderReadFloatType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
float *value = malloc(sizeof(float)); | |
*value = atof((char *)nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a float value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteFloatType(xmlTextWriterPtr writer, float *value) { | |
return xmlTextWriterWriteFormatString(writer, "%f", *value); | |
} | |
/*******************int************************************/ | |
/** | |
* Read a int value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @param value The value to be written. | |
* @return the int. | |
*/ | |
int *xmlTextReaderReadIntType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
int *value = malloc(sizeof(int)); | |
*value = atoi((char *)nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a int value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteIntType(xmlTextWriterPtr writer, int *value) { | |
return xmlTextWriterWriteFormatString(writer, "%i", *value); | |
} | |
/*******************long************************************/ | |
/** | |
* Read a long value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the long. | |
*/ | |
long *xmlTextReaderReadLongType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
long *value = malloc(sizeof(long)); | |
*value = atol((char *)nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a long value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteLongType(xmlTextWriterPtr writer, long *value) { | |
return xmlTextWriterWriteFormatString(writer, "%ld", *value); | |
} | |
/*******************short************************************/ | |
/** | |
* Read a short value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the short. | |
*/ | |
short *xmlTextReaderReadShortType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
short *value = malloc(sizeof(short)); | |
*value = atoi((char *)nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write a short value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteShortType(xmlTextWriterPtr writer, short *value) { | |
return xmlTextWriterWriteFormatString(writer, "%hi", *value); | |
} | |
/*******************unsigned short***************************/ | |
/** | |
* Read an unsigned short value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the unsigned short. | |
*/ | |
unsigned short *xmlTextReaderReadUnsignedShortType(xmlTextReaderPtr reader) { | |
xmlChar *nodeValue = xmlTextReaderReadEntireNodeValue(reader); | |
unsigned short *value = malloc(sizeof(unsigned short)); | |
*value = atoi((char *)nodeValue); | |
free(nodeValue); | |
return value; | |
} | |
/** | |
* Write an unsigned short value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteUnsignedShortType(xmlTextWriterPtr writer, unsigned short *value) { | |
return xmlTextWriterWriteFormatString(writer, "%hi", *value); | |
} | |
/*******************char************************************/ | |
/** | |
* Read a character value from the reader. | |
* | |
* @param reader The reader (pointing at a node with a value). | |
* @return the character. | |
*/ | |
xmlChar *xmlTextReaderReadCharacterType(xmlTextReaderPtr reader) { | |
return xmlTextReaderReadEntireNodeValue(reader); | |
} | |
/** | |
* Write a character value to the writer. | |
* | |
* @param writer The writer. | |
* @param value The value to be written. | |
* @return the bytes written (may be 0 because of buffering) or -1 in case of error. | |
*/ | |
int xmlTextWriterWriteCharacterType(xmlTextWriterPtr writer, xmlChar *value) { | |
return xmlTextWriterWriteString(writer, value); | |
} | |
#endif /* ENUNCIATE_XML_OBJC_PRIMITIVE_FUNCTIONS */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "enunciate-common.h" | |
#ifndef DEF_ENUNCIATESTRUCTURESHouseColor_H | |
#define DEF_ENUNCIATESTRUCTURESHouseColor_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
enum ENUNCIATESTRUCTURESHouseColor | |
{ | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSECOLOR_BLUE, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSECOLOR_RED, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSECOLOR_YELLOW, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSECOLOR_UNKNOWN | |
}; | |
/** | |
* Gets the known HouseColor for a QName. | |
* | |
* @param qname The QName | |
* @return The HouseColor, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATESTRUCTURESHouseColor getKnownENUNCIATESTRUCTURESHouseColor(NSURL *qname); | |
/** | |
* Convert a known HouseColor to a QName. | |
* | |
* @param _houseColor The known HouseColor. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static NSURL *convertKnownENUNCIATESTRUCTURESHouseColor(enum ENUNCIATESTRUCTURESHouseColor _houseColor); | |
#endif /* DEF_ENUNCIATESTRUCTURESHouseColor_H */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouseType_H | |
#define DEF_ENUNCIATESTRUCTURESHouseType_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
enum ENUNCIATESTRUCTURESHouseType | |
{ | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSETYPE_BRICK, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSETYPE_WOOD, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSETYPE_MUD, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSETYPE_UNKNOWN | |
}; | |
/** | |
* Gets the known HouseType for a QName. | |
* | |
* @param qname The QName | |
* @return The HouseType, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATESTRUCTURESHouseType getKnownENUNCIATESTRUCTURESHouseType(QName *qname); | |
/** | |
* Convert a known HouseType to a QName. | |
* | |
* @param _houseType The known HouseType. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static QName *convertKnownENUNCIATESTRUCTURESHouseType(enum ENUNCIATESTRUCTURESHouseType _houseType); | |
#endif /* DEF_ENUNCIATESTRUCTURESHouseType_H */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouseStyle_H | |
#define DEF_ENUNCIATESTRUCTURESHouseStyle_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
enum ENUNCIATESTRUCTURESHouseStyle | |
{ | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSESTYLE_VICTORIAN, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSESTYLE_CONTEMPORARY, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_STRUCTURES_HOUSESTYLE_LATIN | |
}; | |
/** | |
* Gets the known HouseStyle for a QName. | |
* | |
* @param qname The QName | |
* @return The HouseStyle, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATESTRUCTURESHouseStyle getKnownENUNCIATESTRUCTURESHouseStyle(QName *qname); | |
/** | |
* Convert a known HouseStyle to a QName. | |
* | |
* @param _houseStyle The known HouseStyle. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static QName *convertKnownENUNCIATESTRUCTURESHouseStyle(enum ENUNCIATESTRUCTURESHouseStyle _houseStyle); | |
#endif /* DEF_ENUNCIATESTRUCTURESHouseStyle_H */ | |
#ifndef DEF_ENUNCIATENS0Color_H | |
#define DEF_ENUNCIATENS0Color_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
enum ENUNCIATENS0Color | |
{ | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_COLOR_RED, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_COLOR_YELLOW, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_COLOR_GREEN, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_COLOR_BLUE | |
}; | |
/** | |
* Reads a Color from XML. The reader is assumed to be at the start element. | |
* | |
* @param reader The XML reader. | |
* @return The Color, or NULL if unable to be read. | |
*/ | |
static enum ENUNCIATENS0Color *xmlTextReaderReadENUNCIATENS0ColorType(xmlTextReaderPtr reader); | |
/** | |
* Writes a Color to XML. | |
* | |
* @param writer The XML writer. | |
* @param _color The Color to write. | |
* @return The bytes written (may be 0 in case of buffering) or -1 in case of error. | |
*/ | |
static int xmlTextWriterWriteENUNCIATENS0ColorType(xmlTextWriterPtr writer, enum ENUNCIATENS0Color *_color); | |
/** | |
* Utility method for getting the enum value for a string. | |
* | |
* @param _color The string to format. | |
* @return The enum value or NULL on error. | |
*/ | |
static enum ENUNCIATENS0Color *formatStringToENUNCIATENS0ColorType(NSString *_color); | |
/** | |
* Utility method for getting the string value of Color. | |
* | |
* @param _color The Color to format. | |
* @return The string value or NULL on error. | |
*/ | |
static NSString *formatENUNCIATENS0ColorTypeToString(enum ENUNCIATENS0Color *_color); | |
#endif /* DEF_ENUNCIATENS0Color_H */ | |
#ifndef DEF_ENUNCIATENS0LineStyle_H | |
#define DEF_ENUNCIATENS0LineStyle_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
enum ENUNCIATENS0LineStyle | |
{ | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_LINESTYLE_SOLID, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_LINESTYLE_DOTTED, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS0_LINESTYLE_DASHED | |
}; | |
/** | |
* Reads a LineStyle from XML. The reader is assumed to be at the start element. | |
* | |
* @param reader The XML reader. | |
* @return The LineStyle, or NULL if unable to be read. | |
*/ | |
static enum ENUNCIATENS0LineStyle *xmlTextReaderReadENUNCIATENS0LineStyleType(xmlTextReaderPtr reader); | |
/** | |
* Writes a LineStyle to XML. | |
* | |
* @param writer The XML writer. | |
* @param _lineStyle The LineStyle to write. | |
* @return The bytes written (may be 0 in case of buffering) or -1 in case of error. | |
*/ | |
static int xmlTextWriterWriteENUNCIATENS0LineStyleType(xmlTextWriterPtr writer, enum ENUNCIATENS0LineStyle *_lineStyle); | |
/** | |
* Utility method for getting the enum value for a string. | |
* | |
* @param _lineStyle The string to format. | |
* @return The enum value or NULL on error. | |
*/ | |
static enum ENUNCIATENS0LineStyle *formatStringToENUNCIATENS0LineStyleType(NSString *_lineStyle); | |
/** | |
* Utility method for getting the string value of LineStyle. | |
* | |
* @param _lineStyle The LineStyle to format. | |
* @return The string value or NULL on error. | |
*/ | |
static NSString *formatENUNCIATENS0LineStyleTypeToString(enum ENUNCIATENS0LineStyle *_lineStyle); | |
#endif /* DEF_ENUNCIATENS0LineStyle_H */ | |
#ifndef DEF_ENUNCIATENS1BusType_H | |
#define DEF_ENUNCIATENS1BusType_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
enum ENUNCIATENS1BusType | |
{ | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS1_BUSTYPE_CHARTER, | |
/** | |
* (no documentation provided) | |
*/ | |
ENUNCIATE_NS1_BUSTYPE_SCHOOL | |
}; | |
/** | |
* Gets the known BusType for a QName. | |
* | |
* @param qname The QName | |
* @return The BusType, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATENS1BusType getKnownENUNCIATENS1BusType(QName *qname); | |
/** | |
* Convert a known BusType to a QName. | |
* | |
* @param _busType The known BusType. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static QName *convertKnownENUNCIATENS1BusType(enum ENUNCIATENS1BusType _busType); | |
#endif /* DEF_ENUNCIATENS1BusType_H */ | |
@class ENUNCIATENS0Label; | |
@class ENUNCIATENS0Shape; | |
@class ENUNCIATENS0Figure; | |
@class ENUNCIATEDRAWCanvasAttachment; | |
@class ENUNCIATEDRAWCanvas; | |
@class ENUNCIATENS0Line; | |
@class ENUNCIATENS0Dot; | |
@class ENUNCIATEANIMALSCat; | |
@class ENUNCIATEVEHICLESBus; | |
@class ENUNCIATESTRUCTURESHouse; | |
@class ENUNCIATENS0Rectangle; | |
@class ENUNCIATENS0Triangle; | |
@class ENUNCIATENS0Circle; | |
#ifndef DEF_ENUNCIATENS0Label_H | |
#define DEF_ENUNCIATENS0Label_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Label : NSObject | |
{ | |
@private | |
NSString *_value; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) value; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setValue: (NSString *) newValue; | |
@end /* interface ENUNCIATENS0Label */ | |
#endif /* DEF_ENUNCIATENS0Label_H */ | |
#ifndef DEF_ENUNCIATENS0Shape_H | |
#define DEF_ENUNCIATENS0Shape_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Shape : NSObject | |
{ | |
@private | |
NSString *_identifier; | |
int _positionX; | |
int _positionY; | |
enum ENUNCIATENS0Color *_color; | |
enum ENUNCIATENS0LineStyle *_lineStyle; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) identifier; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setIdentifier: (NSString *) newIdentifier; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) positionX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setPositionX: (int) newPositionX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) positionY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setPositionY: (int) newPositionY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (enum ENUNCIATENS0Color *) color; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setColor: (enum ENUNCIATENS0Color *) newColor; | |
/** | |
* (no documentation provided) | |
*/ | |
- (enum ENUNCIATENS0LineStyle *) lineStyle; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setLineStyle: (enum ENUNCIATENS0LineStyle *) newLineStyle; | |
@end /* interface ENUNCIATENS0Shape */ | |
#endif /* DEF_ENUNCIATENS0Shape_H */ | |
#ifndef DEF_ENUNCIATENS0Figure_H | |
#define DEF_ENUNCIATENS0Figure_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Figure : NSObject | |
{ | |
@private | |
NSString *_identifier; | |
NSString *_labels; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) identifier; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setIdentifier: (NSString *) newIdentifier; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) labels; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setLabels: (NSString *) newLabels; | |
@end /* interface ENUNCIATENS0Figure */ | |
#endif /* DEF_ENUNCIATENS0Figure_H */ | |
#ifndef DEF_ENUNCIATEDRAWCanvasAttachment_H | |
#define DEF_ENUNCIATEDRAWCanvasAttachment_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATEDRAWCanvasAttachment : NSObject | |
{ | |
@private | |
NSData *_value; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSData *) value; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setValue: (NSData *) newValue; | |
@end /* interface ENUNCIATEDRAWCanvasAttachment */ | |
#endif /* DEF_ENUNCIATEDRAWCanvasAttachment_H */ | |
#ifndef DEF_ENUNCIATEDRAWCanvas_H | |
#define DEF_ENUNCIATEDRAWCanvas_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATEDRAWCanvas : NSObject <EnunciateXML> | |
{ | |
@private | |
NSArray *_shapes; | |
NSArray *_figures; | |
NSArray *_lines; | |
int _dimensionX; | |
int _dimensionY; | |
NSData *_backgroundImage; | |
NSData *_explicitBase64Attachment; | |
NSArray *_otherAttachments; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) shapes; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setShapes: (NSArray *) newShapes; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) figures; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setFigures: (NSArray *) newFigures; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) lines; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setLines: (NSArray *) newLines; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) dimensionX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDimensionX: (int) newDimensionX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) dimensionY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDimensionY: (int) newDimensionY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSData *) backgroundImage; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setBackgroundImage: (NSData *) newBackgroundImage; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSData *) explicitBase64Attachment; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setExplicitBase64Attachment: (NSData *) newExplicitBase64Attachment; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) otherAttachments; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setOtherAttachments: (NSArray *) newOtherAttachments; | |
@end /* interface ENUNCIATEDRAWCanvas */ | |
#endif /* DEF_ENUNCIATEDRAWCanvas_H */ | |
#ifndef DEF_ENUNCIATENS0Line_H | |
#define DEF_ENUNCIATENS0Line_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Line : NSObject <EnunciateXML> | |
{ | |
@private | |
NSString *_identifier; | |
int _startX; | |
int _startY; | |
int _endX; | |
int _endY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) identifier; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setIdentifier: (NSString *) newIdentifier; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) startX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStartX: (int) newStartX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) startY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStartY: (int) newStartY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) endX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEndX: (int) newEndX; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) endY; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEndY: (int) newEndY; | |
@end /* interface ENUNCIATENS0Line */ | |
#endif /* DEF_ENUNCIATENS0Line_H */ | |
#ifndef DEF_ENUNCIATENS0Dot_H | |
#define DEF_ENUNCIATENS0Dot_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Dot : NSObject <EnunciateXML> | |
{ | |
@private | |
NSString *_why; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) why; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWhy: (NSString *) newWhy; | |
@end /* interface ENUNCIATENS0Dot */ | |
#endif /* DEF_ENUNCIATENS0Dot_H */ | |
#ifndef DEF_ENUNCIATEANIMALSCat_H | |
#define DEF_ENUNCIATEANIMALSCat_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATEANIMALSCat : ENUNCIATENS0Figure <EnunciateXML> | |
{ | |
@private | |
NSString *_mouth; | |
ENUNCIATENS0Circle *_face; | |
NSArray *_eyes; | |
NSArray *_ears; | |
NSString *_nose; | |
NSArray *_whiskers; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) mouth; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setMouth: (NSString *) newMouth; | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Circle *) face; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setFace: (ENUNCIATENS0Circle *) newFace; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) eyes; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEyes: (NSArray *) newEyes; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) ears; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEars: (NSArray *) newEars; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) nose; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setNose: (NSString *) newNose; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) whiskers; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWhiskers: (NSArray *) newWhiskers; | |
@end /* interface ENUNCIATEANIMALSCat */ | |
#endif /* DEF_ENUNCIATEANIMALSCat_H */ | |
#ifndef DEF_ENUNCIATEVEHICLESBus_H | |
#define DEF_ENUNCIATEVEHICLESBus_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATEVEHICLESBus : ENUNCIATENS0Figure <EnunciateXML> | |
{ | |
@private | |
ENUNCIATENS0Rectangle *_frame; | |
NSArray *_wheels; | |
NSArray *_windows; | |
ENUNCIATENS0Rectangle *_door; | |
QName *_type; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) frame; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setFrame: (ENUNCIATENS0Rectangle *) newFrame; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) wheels; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWheels: (NSArray *) newWheels; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) windows; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWindows: (NSArray *) newWindows; | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) door; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDoor: (ENUNCIATENS0Rectangle *) newDoor; | |
/** | |
* (no documentation provided) | |
*/ | |
- (QName *) type; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setType: (QName *) newType; | |
/** | |
* Get the associated enum for type, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATENS1BusType) knownType; | |
/** | |
* Set the value of type using a known enumeration. | |
* | |
* @param newType The new value. | |
*/ | |
- (void) setKnownType: (enum ENUNCIATENS1BusType) newType; | |
@end /* interface ENUNCIATEVEHICLESBus */ | |
#endif /* DEF_ENUNCIATEVEHICLESBus_H */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouse_H | |
#define DEF_ENUNCIATESTRUCTURESHouse_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATESTRUCTURESHouse : ENUNCIATENS0Figure <EnunciateXML> | |
{ | |
@private | |
QName *_type; | |
ENUNCIATENS0Rectangle *_base; | |
ENUNCIATENS0Triangle *_roof; | |
ENUNCIATENS0Rectangle *_door; | |
ENUNCIATENS0Circle *_doorKnob; | |
NSArray *_windows; | |
NSDate *_constructedDate; | |
QName *_style; | |
NSURL *_color; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (QName *) type; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setType: (QName *) newType; | |
/** | |
* Get the associated enum for type, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATESTRUCTURESHouseType) knownType; | |
/** | |
* Set the value of type using a known enumeration. | |
* | |
* @param newType The new value. | |
*/ | |
- (void) setKnownType: (enum ENUNCIATESTRUCTURESHouseType) newType; | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) base; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setBase: (ENUNCIATENS0Rectangle *) newBase; | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Triangle *) roof; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setRoof: (ENUNCIATENS0Triangle *) newRoof; | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) door; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDoor: (ENUNCIATENS0Rectangle *) newDoor; | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Circle *) doorKnob; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDoorKnob: (ENUNCIATENS0Circle *) newDoorKnob; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) windows; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWindows: (NSArray *) newWindows; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSDate *) constructedDate; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setConstructedDate: (NSDate *) newConstructedDate; | |
/** | |
* (no documentation provided) | |
*/ | |
- (QName *) style; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStyle: (QName *) newStyle; | |
/** | |
* Get the associated enum for style, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATESTRUCTURESHouseStyle) knownStyle; | |
/** | |
* Set the value of style using a known enumeration. | |
* | |
* @param newStyle The new value. | |
*/ | |
- (void) setKnownStyle: (enum ENUNCIATESTRUCTURESHouseStyle) newStyle; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSURL *) color; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setColor: (NSURL *) newColor; | |
/** | |
* Get the associated enum for color, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATESTRUCTURESHouseColor) knownColor; | |
/** | |
* Set the value of color using a known enumeration. | |
* | |
* @param newColor The new value. | |
*/ | |
- (void) setKnownColor: (enum ENUNCIATESTRUCTURESHouseColor) newColor; | |
@end /* interface ENUNCIATESTRUCTURESHouse */ | |
#endif /* DEF_ENUNCIATESTRUCTURESHouse_H */ | |
#ifndef DEF_ENUNCIATENS0Rectangle_H | |
#define DEF_ENUNCIATENS0Rectangle_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Rectangle : ENUNCIATENS0Shape <EnunciateXML> | |
{ | |
@private | |
int _width; | |
int _height; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) width; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWidth: (int) newWidth; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) height; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setHeight: (int) newHeight; | |
@end /* interface ENUNCIATENS0Rectangle */ | |
#endif /* DEF_ENUNCIATENS0Rectangle_H */ | |
#ifndef DEF_ENUNCIATENS0Triangle_H | |
#define DEF_ENUNCIATENS0Triangle_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Triangle : ENUNCIATENS0Shape <EnunciateXML> | |
{ | |
@private | |
int _base; | |
int _height; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) base; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setBase: (int) newBase; | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) height; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setHeight: (int) newHeight; | |
@end /* interface ENUNCIATENS0Triangle */ | |
#endif /* DEF_ENUNCIATENS0Triangle_H */ | |
#ifndef DEF_ENUNCIATENS0Circle_H | |
#define DEF_ENUNCIATENS0Circle_H | |
/** | |
* @author Ryan Heaton | |
*/ | |
@interface ENUNCIATENS0Circle : ENUNCIATENS0Shape <EnunciateXML> | |
{ | |
@private | |
int _radius; | |
NSArray *_dots; | |
NSArray *_stars; | |
NSArray *_palette; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) radius; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setRadius: (int) newRadius; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) dots; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDots: (NSArray *) newDots; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) stars; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStars: (NSArray *) newStars; | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) palette; | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setPalette: (NSArray *) newPalette; | |
@end /* interface ENUNCIATENS0Circle */ | |
#endif /* DEF_ENUNCIATENS0Circle_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "enunciate.h" | |
#ifndef DEF_ENUNCIATENS0Label_M | |
#define DEF_ENUNCIATENS0Label_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Label | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) value | |
{ | |
return _value; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setValue: (NSString *) newValue | |
{ | |
[newValue retain]; | |
[_value release]; | |
_value = newValue; | |
} | |
- (void) dealloc | |
{ | |
[self setValue: nil]; | |
[super dealloc]; | |
} | |
@end /* implementation ENUNCIATENS0Label */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Label (JAXB) <JAXBReading, JAXBWriting, JAXBType> | |
@end /*interface ENUNCIATENS0Label (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Label (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Label from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Label defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Label *_eNUNCIATENS0Label = [[ENUNCIATENS0Label alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Label initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Label = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Label autorelease]; | |
return _eNUNCIATENS0Label; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Label according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Label to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read element value..."); | |
#endif | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
[self setValue: (NSString *) [NSString readXMLType: reader]]; | |
} | |
else { | |
[self setValue: @""]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read element value..."); | |
#endif | |
return YES; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element value..."); | |
#endif | |
[[self value] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element value..."); | |
#endif | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBChildElements: writer]; | |
} | |
@end /* implementation ENUNCIATENS0Label (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Label_M */ | |
#ifndef DEF_ENUNCIATENS0Shape_M | |
#define DEF_ENUNCIATENS0Shape_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Shape | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) identifier | |
{ | |
return _identifier; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setIdentifier: (NSString *) newIdentifier | |
{ | |
[newIdentifier retain]; | |
[_identifier release]; | |
_identifier = newIdentifier; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) positionX | |
{ | |
return _positionX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setPositionX: (int) newPositionX | |
{ | |
_positionX = newPositionX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) positionY | |
{ | |
return _positionY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setPositionY: (int) newPositionY | |
{ | |
_positionY = newPositionY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (enum ENUNCIATENS0Color *) color | |
{ | |
return _color; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setColor: (enum ENUNCIATENS0Color *) newColor | |
{ | |
if (_color != NULL) { | |
free(_color); | |
} | |
_color = newColor; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (enum ENUNCIATENS0LineStyle *) lineStyle | |
{ | |
return _lineStyle; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setLineStyle: (enum ENUNCIATENS0LineStyle *) newLineStyle | |
{ | |
if (_lineStyle != NULL) { | |
free(_lineStyle); | |
} | |
_lineStyle = newLineStyle; | |
} | |
- (void) dealloc | |
{ | |
[self setIdentifier: nil]; | |
[self setColor: NULL]; | |
[self setLineStyle: NULL]; | |
[super dealloc]; | |
} | |
@end /* implementation ENUNCIATENS0Shape */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Shape (JAXB) <JAXBReading, JAXBWriting, JAXBType> | |
@end /*interface ENUNCIATENS0Shape (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Shape (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Shape from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Shape defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Shape *_eNUNCIATENS0Shape = [[ENUNCIATENS0Shape alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Shape initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Shape = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Shape autorelease]; | |
return _eNUNCIATENS0Shape; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Shape according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Shape to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
if ((xmlStrcmp(BAD_CAST "id", xmlTextReaderConstLocalName(reader)) == 0) && (xmlTextReaderConstNamespaceUri(reader) == NULL)) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read attribute {}id..."); | |
#endif | |
[self setIdentifier: (NSString*) [NSString readXMLType: reader]]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read attribute {}id..."); | |
#endif | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "positionX", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setPositionX: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "positionY", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setPositionY: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "color", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadENUNCIATENS0ColorType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setColor: ((enum ENUNCIATENS0Color*) _child_accessor)]; | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "lineStyle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadENUNCIATENS0LineStyleType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setLineStyle: ((enum ENUNCIATENS0LineStyle*) _child_accessor)]; | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
if ([self identifier]) { | |
status = xmlTextWriterStartAttributeNS(writer, NULL, BAD_CAST "id", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start attribute {}id."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing attribute {}id..."); | |
#endif | |
[[self identifier] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote attribute {}id..."); | |
#endif | |
status = xmlTextWriterEndAttribute(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end attribute {}id."]; | |
} | |
} | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "positionX", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}positionX."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}positionX..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_positionX); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}positionX..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}positionX."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}positionX."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "positionY", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}positionY."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}positionY..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_positionY); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}positionY..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}positionY."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}positionY."]; | |
} | |
} | |
if ([self color] != NULL) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "color", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}color."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}color..."); | |
#endif | |
status = xmlTextWriterWriteENUNCIATENS0ColorType(writer, [self color]); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}color..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}color."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}color."]; | |
} | |
} | |
if ([self lineStyle] != NULL) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "lineStyle", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}lineStyle."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}lineStyle..."); | |
#endif | |
status = xmlTextWriterWriteENUNCIATENS0LineStyleType(writer, [self lineStyle]); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}lineStyle..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}lineStyle."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}lineStyle."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATENS0Shape (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Shape_M */ | |
#ifndef DEF_ENUNCIATENS0Figure_M | |
#define DEF_ENUNCIATENS0Figure_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Figure | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) identifier | |
{ | |
return _identifier; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setIdentifier: (NSString *) newIdentifier | |
{ | |
[newIdentifier retain]; | |
[_identifier release]; | |
_identifier = newIdentifier; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) labels | |
{ | |
return _labels; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setLabels: (NSString *) newLabels | |
{ | |
[newLabels retain]; | |
[_labels release]; | |
_labels = newLabels; | |
} | |
- (void) dealloc | |
{ | |
[self setIdentifier: nil]; | |
[self setLabels: nil]; | |
[super dealloc]; | |
} | |
@end /* implementation ENUNCIATENS0Figure */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Figure (JAXB) <JAXBReading, JAXBWriting, JAXBType> | |
@end /*interface ENUNCIATENS0Figure (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Figure (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Figure from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Figure defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Figure *_eNUNCIATENS0Figure = [[ENUNCIATENS0Figure alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Figure initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Figure = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Figure autorelease]; | |
return _eNUNCIATENS0Figure; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Figure according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Figure to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
if ((xmlStrcmp(BAD_CAST "id", xmlTextReaderConstLocalName(reader)) == 0) && (xmlTextReaderConstNamespaceUri(reader) == NULL)) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read attribute {}id..."); | |
#endif | |
[self setIdentifier: (NSString*) [NSString readXMLType: reader]]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read attribute {}id..."); | |
#endif | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "labels", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}labels of type {}label."); | |
#endif | |
__child = [NSString readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}labels of type {}label."); | |
#endif | |
[self setLabels: __child]; | |
return YES; | |
} //end "if choice" | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
if ([self identifier]) { | |
status = xmlTextWriterStartAttributeNS(writer, NULL, BAD_CAST "id", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start attribute {}id."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing attribute {}id..."); | |
#endif | |
[[self identifier] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote attribute {}id..."); | |
#endif | |
status = xmlTextWriterEndAttribute(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end attribute {}id."]; | |
} | |
} | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self labels]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "labels", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}labels."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}labels..."); | |
#endif | |
[[self labels] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}labels..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}labels."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATENS0Figure (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Figure_M */ | |
#ifndef DEF_ENUNCIATEDRAWCanvasAttachment_M | |
#define DEF_ENUNCIATEDRAWCanvasAttachment_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATEDRAWCanvasAttachment | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSData *) value | |
{ | |
return _value; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setValue: (NSData *) newValue | |
{ | |
[newValue retain]; | |
[_value release]; | |
_value = newValue; | |
} | |
- (void) dealloc | |
{ | |
[self setValue: nil]; | |
[super dealloc]; | |
} | |
@end /* implementation ENUNCIATEDRAWCanvasAttachment */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATEDRAWCanvasAttachment (JAXB) <JAXBReading, JAXBWriting, JAXBType> | |
@end /*interface ENUNCIATEDRAWCanvasAttachment (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATEDRAWCanvasAttachment (JAXB) | |
/** | |
* Read an instance of ENUNCIATEDRAWCanvasAttachment from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATEDRAWCanvasAttachment defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATEDRAWCanvasAttachment *_eNUNCIATEDRAWCanvasAttachment = [[ENUNCIATEDRAWCanvasAttachment alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATEDRAWCanvasAttachment initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATEDRAWCanvasAttachment = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATEDRAWCanvasAttachment autorelease]; | |
return _eNUNCIATEDRAWCanvasAttachment; | |
} | |
/** | |
* Initialize this instance of ENUNCIATEDRAWCanvasAttachment according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATEDRAWCanvasAttachment to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read element value..."); | |
#endif | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
[self setValue: (NSData *) [NSData readXMLType: reader]]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read element value..."); | |
#endif | |
return YES; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element value..."); | |
#endif | |
[[self value] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element value..."); | |
#endif | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBChildElements: writer]; | |
} | |
@end /* implementation ENUNCIATEDRAWCanvasAttachment (JAXB) */ | |
#endif /* DEF_ENUNCIATEDRAWCanvasAttachment_M */ | |
#ifndef DEF_ENUNCIATEDRAWCanvas_M | |
#define DEF_ENUNCIATEDRAWCanvas_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATEDRAWCanvas | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) shapes | |
{ | |
return _shapes; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setShapes: (NSArray *) newShapes | |
{ | |
[newShapes retain]; | |
[_shapes release]; | |
_shapes = newShapes; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) figures | |
{ | |
return _figures; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setFigures: (NSArray *) newFigures | |
{ | |
[newFigures retain]; | |
[_figures release]; | |
_figures = newFigures; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) lines | |
{ | |
return _lines; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setLines: (NSArray *) newLines | |
{ | |
[newLines retain]; | |
[_lines release]; | |
_lines = newLines; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) dimensionX | |
{ | |
return _dimensionX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDimensionX: (int) newDimensionX | |
{ | |
_dimensionX = newDimensionX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) dimensionY | |
{ | |
return _dimensionY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDimensionY: (int) newDimensionY | |
{ | |
_dimensionY = newDimensionY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSData *) backgroundImage | |
{ | |
return _backgroundImage; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setBackgroundImage: (NSData *) newBackgroundImage | |
{ | |
[newBackgroundImage retain]; | |
[_backgroundImage release]; | |
_backgroundImage = newBackgroundImage; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSData *) explicitBase64Attachment | |
{ | |
return _explicitBase64Attachment; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setExplicitBase64Attachment: (NSData *) newExplicitBase64Attachment | |
{ | |
[newExplicitBase64Attachment retain]; | |
[_explicitBase64Attachment release]; | |
_explicitBase64Attachment = newExplicitBase64Attachment; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) otherAttachments | |
{ | |
return _otherAttachments; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setOtherAttachments: (NSArray *) newOtherAttachments | |
{ | |
[newOtherAttachments retain]; | |
[_otherAttachments release]; | |
_otherAttachments = newOtherAttachments; | |
} | |
- (void) dealloc | |
{ | |
[self setShapes: nil]; | |
[self setFigures: nil]; | |
[self setLines: nil]; | |
[self setBackgroundImage: nil]; | |
[self setExplicitBase64Attachment: nil]; | |
[self setOtherAttachments: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATEDRAWCanvas *_eNUNCIATEDRAWCanvas; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATEDRAWCanvas = (ENUNCIATEDRAWCanvas *) [ENUNCIATEDRAWCanvas readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATEDRAWCanvas; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATEDRAWCanvas */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATEDRAWCanvas (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATEDRAWCanvas (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATEDRAWCanvas (JAXB) | |
/** | |
* Read an instance of ENUNCIATEDRAWCanvas from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATEDRAWCanvas defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATEDRAWCanvas *_eNUNCIATEDRAWCanvas = [[ENUNCIATEDRAWCanvas alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATEDRAWCanvas initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATEDRAWCanvas = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATEDRAWCanvas autorelease]; | |
return _eNUNCIATEDRAWCanvas; | |
} | |
/** | |
* Initialize this instance of ENUNCIATEDRAWCanvas according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATEDRAWCanvas to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATEDRAWCanvas from an XML reader. The element to be read is | |
* "{http://c.enunciate.codehaus.org/draw}canvas". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATEDRAWCanvas. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATEDRAWCanvas *_canvas = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element {http://c.enunciate.codehaus.org/draw}canvas."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "canvas", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlStrcmp(BAD_CAST "http://c.enunciate.codehaus.org/draw", xmlTextReaderConstNamespaceUri(reader)) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {http://c.enunciate.codehaus.org/draw}canvas."); | |
#endif | |
_canvas = (ENUNCIATEDRAWCanvas *)[ENUNCIATEDRAWCanvas readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {http://c.enunciate.codehaus.org/draw}canvas."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATEDRAWCanvas. Expected element {http://c.enunciate.codehaus.org/draw}canvas. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATEDRAWCanvas. Expected element {http://c.enunciate.codehaus.org/draw}canvas. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _canvas; | |
} | |
/** | |
* Writes this ENUNCIATEDRAWCanvas to XML under element name "{http://c.enunciate.codehaus.org/draw}canvas". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _canvas The Canvas to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATEDRAWCanvas to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, BAD_CAST "draw", BAD_CAST "canvas", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {http://c.enunciate.codehaus.org/draw}canvas. XML writer status: %i\n", rc]; | |
} | |
if (writeNs) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing namespaces for start element {http://c.enunciate.codehaus.org/draw}canvas..."); | |
#endif | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:wsi", BAD_CAST "http://ws-i.org/profiles/basic/1.1/xsd"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:wsi' on '{http://c.enunciate.codehaus.org/draw}canvas'. XML writer status: %i\n", rc]; | |
} | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:structures", BAD_CAST "http://c.enunciate.codehaus.org/structures"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:structures' on '{http://c.enunciate.codehaus.org/draw}canvas'. XML writer status: %i\n", rc]; | |
} | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:vehicles", BAD_CAST "http://c.enunciate.codehaus.org/vehicles"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:vehicles' on '{http://c.enunciate.codehaus.org/draw}canvas'. XML writer status: %i\n", rc]; | |
} | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:animals", BAD_CAST "http://c.enunciate.codehaus.org/animals"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:animals' on '{http://c.enunciate.codehaus.org/draw}canvas'. XML writer status: %i\n", rc]; | |
} | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:draw", BAD_CAST "http://c.enunciate.codehaus.org/draw"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:draw' on '{http://c.enunciate.codehaus.org/draw}canvas'. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote namespaces for start element {http://c.enunciate.codehaus.org/draw}canvas..."); | |
#endif | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {http://c.enunciate.codehaus.org/draw}canvas for root element {http://c.enunciate.codehaus.org/draw}canvas..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {http://c.enunciate.codehaus.org/draw}canvas for root element {http://c.enunciate.codehaus.org/draw}canvas..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {http://c.enunciate.codehaus.org/draw}canvas. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "circle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}circle of element {}circle."); | |
#endif | |
__child = [ENUNCIATENS0Circle readXMLElement: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}circle of element {}circle."); | |
#endif | |
if ([self shapes]) { | |
[self setShapes: [[self shapes] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setShapes: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "rectangle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}rectangle of element {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLElement: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}rectangle of element {}rectangle."); | |
#endif | |
if ([self shapes]) { | |
[self setShapes: [[self shapes] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setShapes: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "triangle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}triangle of element {}triangle."); | |
#endif | |
__child = [ENUNCIATENS0Triangle readXMLElement: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}triangle of element {}triangle."); | |
#endif | |
if ([self shapes]) { | |
[self setShapes: [[self shapes] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setShapes: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "cat", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}cat of type {http://c.enunciate.codehaus.org/animals}cat."); | |
#endif | |
__child = [ENUNCIATEANIMALSCat readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}cat of type {http://c.enunciate.codehaus.org/animals}cat."); | |
#endif | |
if ([self figures]) { | |
[self setFigures: [[self figures] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setFigures: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "house", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}house of type {http://c.enunciate.codehaus.org/structures}house."); | |
#endif | |
__child = [ENUNCIATESTRUCTURESHouse readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}house of type {http://c.enunciate.codehaus.org/structures}house."); | |
#endif | |
if ([self figures]) { | |
[self setFigures: [[self figures] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setFigures: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "bus", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}bus of type {http://c.enunciate.codehaus.org/vehicles}bus."); | |
#endif | |
__child = [ENUNCIATEVEHICLESBus readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}bus of type {http://c.enunciate.codehaus.org/vehicles}bus."); | |
#endif | |
if ([self figures]) { | |
[self setFigures: [[self figures] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setFigures: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "lines", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}lines of type {}line."); | |
#endif | |
__child = [ENUNCIATENS0Line readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}lines of type {}line."); | |
#endif | |
if ([self lines]) { | |
[self setLines: [[self lines] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setLines: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "dimensionX", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setDimensionX: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "dimensionY", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setDimensionY: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "backgroundImage", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}backgroundImage of type {http://ws-i.org/profiles/basic/1.1/xsd}swaRef."); | |
#endif | |
__child = [NSData readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}backgroundImage of type {http://ws-i.org/profiles/basic/1.1/xsd}swaRef."); | |
#endif | |
[self setBackgroundImage: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "explicitBase64Attachment", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}explicitBase64Attachment of type {http://www.w3.org/2001/XMLSchema}base64Binary."); | |
#endif | |
__child = [NSData readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}explicitBase64Attachment of type {http://www.w3.org/2001/XMLSchema}base64Binary."); | |
#endif | |
[self setExplicitBase64Attachment: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "otherAttachments", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Unwrapping wrapper element {}otherAttachments..."); | |
#endif | |
//start wrapper element "{}otherAttachments" | |
depth = xmlTextReaderDepth(reader); | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
while (xmlTextReaderDepth(reader) > depth) { | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to next wrapped child element."]; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "attachment", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}attachment of type {http://c.enunciate.codehaus.org/draw}canvasAttachment."); | |
#endif | |
__child = [ENUNCIATEDRAWCanvasAttachment readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}attachment of type {http://c.enunciate.codehaus.org/draw}canvasAttachment."); | |
#endif | |
if ([self otherAttachments]) { | |
[self setOtherAttachments: [[self otherAttachments] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setOtherAttachments: [NSArray arrayWithObject: __child]]; | |
} | |
continue; //continue "while in wrapper element" loop | |
} //end "if choice" | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully unwrapped wrapper element {}otherAttachments..."); | |
#endif | |
} // end "while in wrapper element" loop | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to end wrapper element."]; | |
} | |
} //end "if empty element" clause | |
else { | |
__child = [NSArray array]; | |
[self setOtherAttachments: (NSArray*) __child]; | |
} | |
return YES; | |
} // end "if wrapper element" clause | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self shapes]) { | |
__enumerator = [[self shapes] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
[__item writeXMLElement: writer writeNamespaces: NO]; | |
} //end item iterator. | |
} | |
if ([self figures]) { | |
__enumerator = [[self figures] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
if ([__item isMemberOfClass: [ENUNCIATEANIMALSCat class]] == YES) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "cat", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}cat."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element choice {}cat..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element choice {}cat..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}cat."]; | |
} | |
continue; | |
} | |
if ([__item isMemberOfClass: [ENUNCIATESTRUCTURESHouse class]] == YES) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "house", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}house."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element choice {}house..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element choice {}house..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}house."]; | |
} | |
continue; | |
} | |
if ([__item isMemberOfClass: [ENUNCIATEVEHICLESBus class]] == YES) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "bus", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}bus."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element choice {}bus..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element choice {}bus..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}bus."]; | |
} | |
continue; | |
} | |
} //end item iterator. | |
} | |
if ([self lines]) { | |
__enumerator = [[self lines] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "lines", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}lines."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}lines..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}lines..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}lines."]; | |
} | |
} //end item iterator. | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "dimensionX", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}dimensionX."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}dimensionX..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_dimensionX); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}dimensionX..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}dimensionX."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}dimensionX."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "dimensionY", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}dimensionY."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}dimensionY..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_dimensionY); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}dimensionY..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}dimensionY."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}dimensionY."]; | |
} | |
} | |
if ([self backgroundImage]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "backgroundImage", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}backgroundImage."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}backgroundImage..."); | |
#endif | |
[[self backgroundImage] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}backgroundImage..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}backgroundImage."]; | |
} | |
} | |
if ([self explicitBase64Attachment]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "explicitBase64Attachment", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}explicitBase64Attachment."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}explicitBase64Attachment..."); | |
#endif | |
[[self explicitBase64Attachment] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}explicitBase64Attachment..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}explicitBase64Attachment."]; | |
} | |
} | |
if ([self otherAttachments]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "otherAttachments", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start wrapper element {}otherAttachments."]; | |
} | |
__enumerator = [[self otherAttachments] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "attachment", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}attachment."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}attachment..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}attachment..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}attachment."]; | |
} | |
} //end item iterator. | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end wrapper element {}otherAttachments."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATEDRAWCanvas (JAXB) */ | |
#endif /* DEF_ENUNCIATEDRAWCanvas_M */ | |
#ifndef DEF_ENUNCIATENS0Line_M | |
#define DEF_ENUNCIATENS0Line_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Line | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) identifier | |
{ | |
return _identifier; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setIdentifier: (NSString *) newIdentifier | |
{ | |
[newIdentifier retain]; | |
[_identifier release]; | |
_identifier = newIdentifier; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) startX | |
{ | |
return _startX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStartX: (int) newStartX | |
{ | |
_startX = newStartX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) startY | |
{ | |
return _startY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStartY: (int) newStartY | |
{ | |
_startY = newStartY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) endX | |
{ | |
return _endX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEndX: (int) newEndX | |
{ | |
_endX = newEndX; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) endY | |
{ | |
return _endY; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEndY: (int) newEndY | |
{ | |
_endY = newEndY; | |
} | |
- (void) dealloc | |
{ | |
[self setIdentifier: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATENS0Line *_eNUNCIATENS0Line; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATENS0Line = (ENUNCIATENS0Line *) [ENUNCIATENS0Line readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATENS0Line; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATENS0Line */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Line (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATENS0Line (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Line (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Line from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Line defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Line *_eNUNCIATENS0Line = [[ENUNCIATENS0Line alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Line initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Line = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Line autorelease]; | |
return _eNUNCIATENS0Line; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Line according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Line to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATENS0Line from an XML reader. The element to be read is | |
* "line". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATENS0Line. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATENS0Line *_line = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element line."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "line", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {}line."); | |
#endif | |
_line = (ENUNCIATENS0Line *)[ENUNCIATENS0Line readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {}line."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Line. Expected element line. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Line. Expected element line. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _line; | |
} | |
/** | |
* Writes this ENUNCIATENS0Line to XML under element name "line". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _line The Line to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATENS0Line to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "line", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {}line. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {}line for root element {}line..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {}line for root element {}line..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {}line. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "id", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}id of type {http://www.w3.org/2001/XMLSchema}ID."); | |
#endif | |
__child = [NSString readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}id of type {http://www.w3.org/2001/XMLSchema}ID."); | |
#endif | |
[self setIdentifier: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "startX", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setStartX: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "startY", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setStartY: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "endX", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setEndX: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "endY", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setEndY: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self identifier]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "id", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}id."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}id..."); | |
#endif | |
[[self identifier] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}id..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}id."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "startX", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}startX."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}startX..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_startX); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}startX..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}startX."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}startX."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "startY", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}startY."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}startY..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_startY); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}startY..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}startY."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}startY."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "endX", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}endX."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}endX..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_endX); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}endX..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}endX."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}endX."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "endY", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}endY."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}endY..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_endY); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}endY..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}endY."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}endY."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATENS0Line (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Line_M */ | |
#ifndef DEF_ENUNCIATENS0Dot_M | |
#define DEF_ENUNCIATENS0Dot_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Dot | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) why | |
{ | |
return _why; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWhy: (NSString *) newWhy | |
{ | |
[newWhy retain]; | |
[_why release]; | |
_why = newWhy; | |
} | |
- (void) dealloc | |
{ | |
[self setWhy: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATENS0Dot *_eNUNCIATENS0Dot; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATENS0Dot = (ENUNCIATENS0Dot *) [ENUNCIATENS0Dot readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATENS0Dot; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATENS0Dot */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Dot (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATENS0Dot (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Dot (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Dot from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Dot defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Dot *_eNUNCIATENS0Dot = [[ENUNCIATENS0Dot alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Dot initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Dot = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Dot autorelease]; | |
return _eNUNCIATENS0Dot; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Dot according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Dot to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATENS0Dot from an XML reader. The element to be read is | |
* "dot". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATENS0Dot. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATENS0Dot *_dot = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element dot."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "dot", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {}dot."); | |
#endif | |
_dot = (ENUNCIATENS0Dot *)[ENUNCIATENS0Dot readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {}dot."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Dot. Expected element dot. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Dot. Expected element dot. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _dot; | |
} | |
/** | |
* Writes this ENUNCIATENS0Dot to XML under element name "dot". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _dot The Dot to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATENS0Dot to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "dot", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {}dot. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {}dot for root element {}dot..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {}dot for root element {}dot..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {}dot. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "why", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}why of type {http://www.w3.org/2001/XMLSchema}string."); | |
#endif | |
__child = [NSString readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}why of type {http://www.w3.org/2001/XMLSchema}string."); | |
#endif | |
[self setWhy: __child]; | |
return YES; | |
} //end "if choice" | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self why]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "why", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}why."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}why..."); | |
#endif | |
[[self why] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}why..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}why."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATENS0Dot (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Dot_M */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouseColor_M | |
#define DEF_ENUNCIATESTRUCTURESHouseColor_M | |
/** | |
* Gets the known HouseColor for a QName. | |
* | |
* @param qname The QName | |
* @return The HouseColor, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATESTRUCTURESHouseColor getKnownENUNCIATESTRUCTURESHouseColor(NSURL *qname) | |
{ | |
if (qname) { | |
if ([@"http://c.enunciate.codehaus.org/structuresblue" isEqualToString:[qname absoluteString]]) { | |
return ENUNCIATE_STRUCTURES_HOUSECOLOR_BLUE; | |
} | |
if ([@"http://c.enunciate.codehaus.org/structuresred" isEqualToString:[qname absoluteString]]) { | |
return ENUNCIATE_STRUCTURES_HOUSECOLOR_RED; | |
} | |
if ([@"http://c.enunciate.codehaus.org/structuresyellow" isEqualToString:[qname absoluteString]]) { | |
return ENUNCIATE_STRUCTURES_HOUSECOLOR_YELLOW; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: qname %@ doesn't match an enum value: returning ENUNCIATE_STRUCTURES_HOUSECOLOR_UNKNOWN.", [qname absoluteString]); | |
#endif | |
return ENUNCIATE_STRUCTURES_HOUSECOLOR_UNKNOWN; | |
} | |
else { | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: nil value."); | |
#endif | |
return -1; | |
} | |
} | |
/** | |
* Convert a known HouseColor to a QName. | |
* | |
* @param _houseColor The known HouseColor. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static NSURL *convertKnownENUNCIATESTRUCTURESHouseColor(enum ENUNCIATESTRUCTURESHouseColor _houseColor) | |
{ | |
NSURL *qname; | |
switch (_houseColor) { | |
case ENUNCIATE_STRUCTURES_HOUSECOLOR_BLUE: | |
qname = [NSURL URLWithString: @"http://c.enunciate.codehaus.org/structuresblue"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSECOLOR_RED: | |
qname = [NSURL URLWithString: @"http://c.enunciate.codehaus.org/structuresred"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSECOLOR_YELLOW: | |
qname = [NSURL URLWithString: @"http://c.enunciate.codehaus.org/structuresyellow"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSECOLOR_UNKNOWN: | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to convert enum value ENUNCIATE_STRUCTURES_HOUSECOLOR_UNKNOWN."); | |
#endif | |
return nil; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to write enum value (no valid value found)."); | |
#endif | |
return nil; | |
} | |
#endif /* DEF_ENUNCIATESTRUCTURESHouseColor_M */ | |
#ifndef DEF_ENUNCIATEANIMALSCat_M | |
#define DEF_ENUNCIATEANIMALSCat_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATEANIMALSCat | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) mouth | |
{ | |
return _mouth; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setMouth: (NSString *) newMouth | |
{ | |
[newMouth retain]; | |
[_mouth release]; | |
_mouth = newMouth; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Circle *) face | |
{ | |
return _face; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setFace: (ENUNCIATENS0Circle *) newFace | |
{ | |
[newFace retain]; | |
[_face release]; | |
_face = newFace; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) eyes | |
{ | |
return _eyes; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEyes: (NSArray *) newEyes | |
{ | |
[newEyes retain]; | |
[_eyes release]; | |
_eyes = newEyes; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) ears | |
{ | |
return _ears; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setEars: (NSArray *) newEars | |
{ | |
[newEars retain]; | |
[_ears release]; | |
_ears = newEars; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSString *) nose | |
{ | |
return _nose; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setNose: (NSString *) newNose | |
{ | |
[newNose retain]; | |
[_nose release]; | |
_nose = newNose; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) whiskers | |
{ | |
return _whiskers; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWhiskers: (NSArray *) newWhiskers | |
{ | |
[newWhiskers retain]; | |
[_whiskers release]; | |
_whiskers = newWhiskers; | |
} | |
- (void) dealloc | |
{ | |
[self setMouth: nil]; | |
[self setFace: nil]; | |
[self setEyes: nil]; | |
[self setEars: nil]; | |
[self setNose: nil]; | |
[self setWhiskers: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATEANIMALSCat *_eNUNCIATEANIMALSCat; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATEANIMALSCat = (ENUNCIATEANIMALSCat *) [ENUNCIATEANIMALSCat readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATEANIMALSCat; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATEANIMALSCat */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATEANIMALSCat (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATEANIMALSCat (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATEANIMALSCat (JAXB) | |
/** | |
* Read an instance of ENUNCIATEANIMALSCat from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATEANIMALSCat defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATEANIMALSCat *_eNUNCIATEANIMALSCat = [[ENUNCIATEANIMALSCat alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATEANIMALSCat initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATEANIMALSCat = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATEANIMALSCat autorelease]; | |
return _eNUNCIATEANIMALSCat; | |
} | |
/** | |
* Initialize this instance of ENUNCIATEANIMALSCat according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATEANIMALSCat to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATEANIMALSCat from an XML reader. The element to be read is | |
* "{http://c.enunciate.codehaus.org/animals}cat". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATEANIMALSCat. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATEANIMALSCat *_cat = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element {http://c.enunciate.codehaus.org/animals}cat."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "cat", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlStrcmp(BAD_CAST "http://c.enunciate.codehaus.org/animals", xmlTextReaderConstNamespaceUri(reader)) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {http://c.enunciate.codehaus.org/animals}cat."); | |
#endif | |
_cat = (ENUNCIATEANIMALSCat *)[ENUNCIATEANIMALSCat readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {http://c.enunciate.codehaus.org/animals}cat."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATEANIMALSCat. Expected element {http://c.enunciate.codehaus.org/animals}cat. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATEANIMALSCat. Expected element {http://c.enunciate.codehaus.org/animals}cat. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _cat; | |
} | |
/** | |
* Writes this ENUNCIATEANIMALSCat to XML under element name "{http://c.enunciate.codehaus.org/animals}cat". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _cat The Cat to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATEANIMALSCat to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, BAD_CAST "animals", BAD_CAST "cat", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {http://c.enunciate.codehaus.org/animals}cat. XML writer status: %i\n", rc]; | |
} | |
if (writeNs) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing namespaces for start element {http://c.enunciate.codehaus.org/animals}cat..."); | |
#endif | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:animals", BAD_CAST "http://c.enunciate.codehaus.org/animals"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:animals' on '{http://c.enunciate.codehaus.org/animals}cat'. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote namespaces for start element {http://c.enunciate.codehaus.org/animals}cat..."); | |
#endif | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {http://c.enunciate.codehaus.org/animals}cat for root element {http://c.enunciate.codehaus.org/animals}cat..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {http://c.enunciate.codehaus.org/animals}cat for root element {http://c.enunciate.codehaus.org/animals}cat..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {http://c.enunciate.codehaus.org/animals}cat. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
if ((xmlStrcmp(BAD_CAST "mouth", xmlTextReaderConstLocalName(reader)) == 0) && (xmlTextReaderConstNamespaceUri(reader) == NULL)) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read attribute {}mouth..."); | |
#endif | |
[self setMouth: (NSString*) [NSString readXMLType: reader]]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read attribute {}mouth..."); | |
#endif | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "circle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}circle of element {}circle."); | |
#endif | |
__child = [ENUNCIATENS0Circle readXMLElement: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}circle of element {}circle."); | |
#endif | |
[self setFace: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "eyes", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}eyes of type {}triangle."); | |
#endif | |
__child = [ENUNCIATENS0Triangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}eyes of type {}triangle."); | |
#endif | |
if ([self eyes]) { | |
[self setEyes: [[self eyes] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setEyes: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "ears", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}ears of type {http://www.w3.org/2001/XMLSchema}IDREF."); | |
#endif | |
__child = [ENUNCIATENS0Triangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}ears of type {http://www.w3.org/2001/XMLSchema}IDREF."); | |
#endif | |
if ([self ears]) { | |
[self setEars: [[self ears] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setEars: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "nose", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}nose of type {http://www.w3.org/2001/XMLSchema}IDREF."); | |
#endif | |
__child = [NSString readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}nose of type {http://www.w3.org/2001/XMLSchema}IDREF."); | |
#endif | |
[self setNose: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "whiskers", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}whiskers of type {}line."); | |
#endif | |
__child = [ENUNCIATENS0Line readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}whiskers of type {}line."); | |
#endif | |
if ([self whiskers]) { | |
[self setWhiskers: [[self whiskers] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setWhiskers: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
if ([self mouth]) { | |
status = xmlTextWriterStartAttributeNS(writer, NULL, BAD_CAST "mouth", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start attribute {}mouth."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing attribute {}mouth..."); | |
#endif | |
[[self mouth] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote attribute {}mouth..."); | |
#endif | |
status = xmlTextWriterEndAttribute(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end attribute {}mouth."]; | |
} | |
} | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self face]) { | |
[[self face] writeXMLElement: writer writeNamespaces: NO]; | |
} | |
if ([self eyes]) { | |
__enumerator = [[self eyes] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "eyes", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}eyes."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}eyes..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}eyes..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}eyes."]; | |
} | |
} //end item iterator. | |
} | |
if ([self ears]) { | |
__enumerator = [[self ears] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "ears", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}ears."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}ears..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}ears..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}ears."]; | |
} | |
} //end item iterator. | |
} | |
if ([self nose]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "nose", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}nose."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}nose..."); | |
#endif | |
[[self nose] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}nose..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}nose."]; | |
} | |
} | |
if ([self whiskers]) { | |
__enumerator = [[self whiskers] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "whiskers", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}whiskers."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}whiskers..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}whiskers..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}whiskers."]; | |
} | |
} //end item iterator. | |
} | |
} | |
@end /* implementation ENUNCIATEANIMALSCat (JAXB) */ | |
#endif /* DEF_ENUNCIATEANIMALSCat_M */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouseType_M | |
#define DEF_ENUNCIATESTRUCTURESHouseType_M | |
/** | |
* Gets the known HouseType for a QName. | |
* | |
* @param qname The QName | |
* @return The HouseType, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATESTRUCTURESHouseType getKnownENUNCIATESTRUCTURESHouseType(QName *qname) | |
{ | |
if (qname) { | |
if (([@"http://c.enunciate.codehaus.org/structures" isEqualToString:[qname namespaceURI] ]) | |
&& ([@"brick" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_STRUCTURES_HOUSETYPE_BRICK; | |
} | |
if (([@"http://c.enunciate.codehaus.org/structures" isEqualToString:[qname namespaceURI] ]) | |
&& ([@"wood" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_STRUCTURES_HOUSETYPE_WOOD; | |
} | |
if (([@"http://c.enunciate.codehaus.org/structures" isEqualToString:[qname namespaceURI] ]) | |
&& ([@"mud" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_STRUCTURES_HOUSETYPE_MUD; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: qname {%@}%@ doesn't match an enum value: returning ENUNCIATE_STRUCTURES_HOUSETYPE_UNKNOWN.", [qname namespaceURI], [qname localPart]); | |
#endif | |
return ENUNCIATE_STRUCTURES_HOUSETYPE_UNKNOWN; | |
} | |
else { | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: nil value."); | |
#endif | |
return -1; | |
} | |
} | |
/** | |
* Convert a known HouseType to a QName. | |
* | |
* @param _houseType The known HouseType. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static QName *convertKnownENUNCIATESTRUCTURESHouseType(enum ENUNCIATESTRUCTURESHouseType _houseType) | |
{ | |
QName *qname; | |
switch (_houseType) { | |
case ENUNCIATE_STRUCTURES_HOUSETYPE_BRICK: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @"http://c.enunciate.codehaus.org/structures"]; | |
[qname setLocalPart: @"brick"]; | |
[qname setPrefix: @"structures"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSETYPE_WOOD: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @"http://c.enunciate.codehaus.org/structures"]; | |
[qname setLocalPart: @"wood"]; | |
[qname setPrefix: @"structures"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSETYPE_MUD: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @"http://c.enunciate.codehaus.org/structures"]; | |
[qname setLocalPart: @"mud"]; | |
[qname setPrefix: @"structures"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSETYPE_UNKNOWN: | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to convert enum value ENUNCIATE_STRUCTURES_HOUSETYPE_UNKNOWN."); | |
#endif | |
return nil; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to write enum value (no valid value found)."); | |
#endif | |
return nil; | |
} | |
#endif /* DEF_ENUNCIATESTRUCTURESHouseType_M */ | |
#ifndef DEF_ENUNCIATEVEHICLESBus_M | |
#define DEF_ENUNCIATEVEHICLESBus_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATEVEHICLESBus | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) frame | |
{ | |
return _frame; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setFrame: (ENUNCIATENS0Rectangle *) newFrame | |
{ | |
[newFrame retain]; | |
[_frame release]; | |
_frame = newFrame; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) wheels | |
{ | |
return _wheels; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWheels: (NSArray *) newWheels | |
{ | |
[newWheels retain]; | |
[_wheels release]; | |
_wheels = newWheels; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) windows | |
{ | |
return _windows; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWindows: (NSArray *) newWindows | |
{ | |
[newWindows retain]; | |
[_windows release]; | |
_windows = newWindows; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) door | |
{ | |
return _door; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDoor: (ENUNCIATENS0Rectangle *) newDoor | |
{ | |
[newDoor retain]; | |
[_door release]; | |
_door = newDoor; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (QName *) type | |
{ | |
return _type; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setType: (QName *) newType | |
{ | |
[newType retain]; | |
[_type release]; | |
_type = newType; | |
} | |
/** | |
* Get the associated enum for type, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATENS1BusType) knownType | |
{ | |
return getKnownENUNCIATENS1BusType([self type]); | |
} | |
/** | |
* Set the value of type using a known enumeration. | |
* | |
* @param newType The new value. | |
*/ | |
- (void) setKnownType: (enum ENUNCIATENS1BusType) newType | |
{ | |
QName *qname = convertKnownENUNCIATENS1BusType(newType); | |
if (qname) { | |
[self setType: qname]; | |
} | |
else { | |
[NSException raise: @"UnknownQNameEnum" | |
format: @"Not a known QName enum."]; | |
} | |
} | |
- (void) dealloc | |
{ | |
[self setFrame: nil]; | |
[self setWheels: nil]; | |
[self setWindows: nil]; | |
[self setDoor: nil]; | |
[self setType: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATEVEHICLESBus *_eNUNCIATEVEHICLESBus; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATEVEHICLESBus = (ENUNCIATEVEHICLESBus *) [ENUNCIATEVEHICLESBus readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATEVEHICLESBus; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATEVEHICLESBus */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATEVEHICLESBus (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATEVEHICLESBus (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATEVEHICLESBus (JAXB) | |
/** | |
* Read an instance of ENUNCIATEVEHICLESBus from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATEVEHICLESBus defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATEVEHICLESBus *_eNUNCIATEVEHICLESBus = [[ENUNCIATEVEHICLESBus alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATEVEHICLESBus initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATEVEHICLESBus = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATEVEHICLESBus autorelease]; | |
return _eNUNCIATEVEHICLESBus; | |
} | |
/** | |
* Initialize this instance of ENUNCIATEVEHICLESBus according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATEVEHICLESBus to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATEVEHICLESBus from an XML reader. The element to be read is | |
* "{http://c.enunciate.codehaus.org/vehicles}bus". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATEVEHICLESBus. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATEVEHICLESBus *_bus = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element {http://c.enunciate.codehaus.org/vehicles}bus."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "bus", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlStrcmp(BAD_CAST "http://c.enunciate.codehaus.org/vehicles", xmlTextReaderConstNamespaceUri(reader)) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {http://c.enunciate.codehaus.org/vehicles}bus."); | |
#endif | |
_bus = (ENUNCIATEVEHICLESBus *)[ENUNCIATEVEHICLESBus readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {http://c.enunciate.codehaus.org/vehicles}bus."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATEVEHICLESBus. Expected element {http://c.enunciate.codehaus.org/vehicles}bus. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATEVEHICLESBus. Expected element {http://c.enunciate.codehaus.org/vehicles}bus. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _bus; | |
} | |
/** | |
* Writes this ENUNCIATEVEHICLESBus to XML under element name "{http://c.enunciate.codehaus.org/vehicles}bus". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _bus The Bus to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATEVEHICLESBus to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, BAD_CAST "vehicles", BAD_CAST "bus", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {http://c.enunciate.codehaus.org/vehicles}bus. XML writer status: %i\n", rc]; | |
} | |
if (writeNs) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing namespaces for start element {http://c.enunciate.codehaus.org/vehicles}bus..."); | |
#endif | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:vehicles", BAD_CAST "http://c.enunciate.codehaus.org/vehicles"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:vehicles' on '{http://c.enunciate.codehaus.org/vehicles}bus'. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote namespaces for start element {http://c.enunciate.codehaus.org/vehicles}bus..."); | |
#endif | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {http://c.enunciate.codehaus.org/vehicles}bus for root element {http://c.enunciate.codehaus.org/vehicles}bus..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {http://c.enunciate.codehaus.org/vehicles}bus for root element {http://c.enunciate.codehaus.org/vehicles}bus..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {http://c.enunciate.codehaus.org/vehicles}bus. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "frame", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}frame of type {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}frame of type {}rectangle."); | |
#endif | |
[self setFrame: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "wheels", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}wheels of type {}circle."); | |
#endif | |
__child = [ENUNCIATENS0Circle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}wheels of type {}circle."); | |
#endif | |
if ([self wheels]) { | |
[self setWheels: [[self wheels] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setWheels: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "windows", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Unwrapping wrapper element {}windows..."); | |
#endif | |
//start wrapper element "{}windows" | |
depth = xmlTextReaderDepth(reader); | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
while (xmlTextReaderDepth(reader) > depth) { | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to next wrapped child element."]; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "windows", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}windows of type {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}windows of type {}rectangle."); | |
#endif | |
if ([self windows]) { | |
[self setWindows: [[self windows] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setWindows: [NSArray arrayWithObject: __child]]; | |
} | |
continue; //continue "while in wrapper element" loop | |
} //end "if choice" | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully unwrapped wrapper element {}windows..."); | |
#endif | |
} // end "while in wrapper element" loop | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to end wrapper element."]; | |
} | |
} //end "if empty element" clause | |
else { | |
__child = [NSArray array]; | |
[self setWindows: (NSArray*) __child]; | |
} | |
return YES; | |
} // end "if wrapper element" clause | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "door", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}door of type {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}door of type {}rectangle."); | |
#endif | |
[self setDoor: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "type", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}type of type {http://www.w3.org/2001/XMLSchema}QName."); | |
#endif | |
__child = [QName readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}type of type {http://www.w3.org/2001/XMLSchema}QName."); | |
#endif | |
[self setType: __child]; | |
return YES; | |
} //end "if choice" | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self frame]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "frame", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}frame."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}frame..."); | |
#endif | |
[[self frame] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}frame..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}frame."]; | |
} | |
} | |
if ([self wheels]) { | |
__enumerator = [[self wheels] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "wheels", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}wheels."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}wheels..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}wheels..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}wheels."]; | |
} | |
} //end item iterator. | |
} | |
if ([self windows]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "windows", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start wrapper element {}windows."]; | |
} | |
__enumerator = [[self windows] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "windows", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}windows."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}windows..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}windows..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}windows."]; | |
} | |
} //end item iterator. | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end wrapper element {}windows."]; | |
} | |
} | |
if ([self door]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "door", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}door."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}door..."); | |
#endif | |
[[self door] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}door..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}door."]; | |
} | |
} | |
if ([self type]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "type", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}type."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}type..."); | |
#endif | |
if (([[[self type] prefix] length] == 0) && | |
([[[self type] namespaceURI] length] > 0)) { | |
status = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:typeNS", BAD_CAST [[[self type] namespaceURI] UTF8String]); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing namespace attribute xmlns:typeNS."]; | |
} | |
[[self type] setPrefix: @"typeNS"]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
else { | |
NSLog(@"No attempt will be made to write xmlns attribute for QName because either it's the empty namespace, or the prefix is already defined, implying that the xmlns attribute is already written."); | |
} | |
#endif | |
[[self type] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}type..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}type."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATEVEHICLESBus (JAXB) */ | |
#endif /* DEF_ENUNCIATEVEHICLESBus_M */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouseStyle_M | |
#define DEF_ENUNCIATESTRUCTURESHouseStyle_M | |
/** | |
* Gets the known HouseStyle for a QName. | |
* | |
* @param qname The QName | |
* @return The HouseStyle, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATESTRUCTURESHouseStyle getKnownENUNCIATESTRUCTURESHouseStyle(QName *qname) | |
{ | |
if (qname) { | |
if (([@"http://c.enunciate.codehaus.org/structures" isEqualToString:[qname namespaceURI] ]) | |
&& ([@"victorian" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_STRUCTURES_HOUSESTYLE_VICTORIAN; | |
} | |
if (([@"http://c.enunciate.codehaus.org/structures" isEqualToString:[qname namespaceURI] ]) | |
&& ([@"contemporary" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_STRUCTURES_HOUSESTYLE_CONTEMPORARY; | |
} | |
if (([@"http://c.enunciate.codehaus.org/structures" isEqualToString:[qname namespaceURI] ]) | |
&& ([@"latin" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_STRUCTURES_HOUSESTYLE_LATIN; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: qname {%@}%@ doesn't match an enum value: returning null.", [qname namespaceURI], [qname localPart]); | |
#endif | |
return -1; | |
} | |
else { | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: nil value."); | |
#endif | |
return -1; | |
} | |
} | |
/** | |
* Convert a known HouseStyle to a QName. | |
* | |
* @param _houseStyle The known HouseStyle. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static QName *convertKnownENUNCIATESTRUCTURESHouseStyle(enum ENUNCIATESTRUCTURESHouseStyle _houseStyle) | |
{ | |
QName *qname; | |
switch (_houseStyle) { | |
case ENUNCIATE_STRUCTURES_HOUSESTYLE_VICTORIAN: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @"http://c.enunciate.codehaus.org/structures"]; | |
[qname setLocalPart: @"victorian"]; | |
[qname setPrefix: @"structures"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSESTYLE_CONTEMPORARY: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @"http://c.enunciate.codehaus.org/structures"]; | |
[qname setLocalPart: @"contemporary"]; | |
[qname setPrefix: @"structures"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_STRUCTURES_HOUSESTYLE_LATIN: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @"http://c.enunciate.codehaus.org/structures"]; | |
[qname setLocalPart: @"latin"]; | |
[qname setPrefix: @"structures"]; | |
[qname autorelease]; | |
return qname; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to write enum value (no valid value found)."); | |
#endif | |
return nil; | |
} | |
#endif /* DEF_ENUNCIATESTRUCTURESHouseStyle_M */ | |
#ifndef DEF_ENUNCIATESTRUCTURESHouse_M | |
#define DEF_ENUNCIATESTRUCTURESHouse_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATESTRUCTURESHouse | |
/** | |
* (no documentation provided) | |
*/ | |
- (QName *) type | |
{ | |
return _type; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setType: (QName *) newType | |
{ | |
[newType retain]; | |
[_type release]; | |
_type = newType; | |
} | |
/** | |
* Get the associated enum for type, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATESTRUCTURESHouseType) knownType | |
{ | |
return getKnownENUNCIATESTRUCTURESHouseType([self type]); | |
} | |
/** | |
* Set the value of type using a known enumeration. | |
* | |
* @param newType The new value. | |
*/ | |
- (void) setKnownType: (enum ENUNCIATESTRUCTURESHouseType) newType | |
{ | |
QName *qname = convertKnownENUNCIATESTRUCTURESHouseType(newType); | |
if (qname) { | |
[self setType: qname]; | |
} | |
else { | |
[NSException raise: @"UnknownQNameEnum" | |
format: @"Not a known QName enum."]; | |
} | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) base | |
{ | |
return _base; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setBase: (ENUNCIATENS0Rectangle *) newBase | |
{ | |
[newBase retain]; | |
[_base release]; | |
_base = newBase; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Triangle *) roof | |
{ | |
return _roof; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setRoof: (ENUNCIATENS0Triangle *) newRoof | |
{ | |
[newRoof retain]; | |
[_roof release]; | |
_roof = newRoof; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Rectangle *) door | |
{ | |
return _door; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDoor: (ENUNCIATENS0Rectangle *) newDoor | |
{ | |
[newDoor retain]; | |
[_door release]; | |
_door = newDoor; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (ENUNCIATENS0Circle *) doorKnob | |
{ | |
return _doorKnob; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDoorKnob: (ENUNCIATENS0Circle *) newDoorKnob | |
{ | |
[newDoorKnob retain]; | |
[_doorKnob release]; | |
_doorKnob = newDoorKnob; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) windows | |
{ | |
return _windows; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWindows: (NSArray *) newWindows | |
{ | |
[newWindows retain]; | |
[_windows release]; | |
_windows = newWindows; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSDate *) constructedDate | |
{ | |
return _constructedDate; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setConstructedDate: (NSDate *) newConstructedDate | |
{ | |
[newConstructedDate retain]; | |
[_constructedDate release]; | |
_constructedDate = newConstructedDate; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (QName *) style | |
{ | |
return _style; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStyle: (QName *) newStyle | |
{ | |
[newStyle retain]; | |
[_style release]; | |
_style = newStyle; | |
} | |
/** | |
* Get the associated enum for style, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATESTRUCTURESHouseStyle) knownStyle | |
{ | |
return getKnownENUNCIATESTRUCTURESHouseStyle([self style]); | |
} | |
/** | |
* Set the value of style using a known enumeration. | |
* | |
* @param newStyle The new value. | |
*/ | |
- (void) setKnownStyle: (enum ENUNCIATESTRUCTURESHouseStyle) newStyle | |
{ | |
QName *qname = convertKnownENUNCIATESTRUCTURESHouseStyle(newStyle); | |
if (qname) { | |
[self setStyle: qname]; | |
} | |
else { | |
[NSException raise: @"UnknownQNameEnum" | |
format: @"Not a known QName enum."]; | |
} | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSURL *) color | |
{ | |
return _color; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setColor: (NSURL *) newColor | |
{ | |
[newColor retain]; | |
[_color release]; | |
_color = newColor; | |
} | |
/** | |
* Get the associated enum for color, if it's a known type. | |
* | |
* @return The known enum, or -1 if not known. | |
*/ | |
- (enum ENUNCIATESTRUCTURESHouseColor) knownColor | |
{ | |
return getKnownENUNCIATESTRUCTURESHouseColor([self color]); | |
} | |
/** | |
* Set the value of color using a known enumeration. | |
* | |
* @param newColor The new value. | |
*/ | |
- (void) setKnownColor: (enum ENUNCIATESTRUCTURESHouseColor) newColor | |
{ | |
NSURL *qname = convertKnownENUNCIATESTRUCTURESHouseColor(newColor); | |
if (qname) { | |
[self setColor: qname]; | |
} | |
else { | |
[NSException raise: @"UnknownQNameEnum" | |
format: @"Not a known QName enum."]; | |
} | |
} | |
- (void) dealloc | |
{ | |
[self setType: nil]; | |
[self setBase: nil]; | |
[self setRoof: nil]; | |
[self setDoor: nil]; | |
[self setDoorKnob: nil]; | |
[self setWindows: nil]; | |
[self setConstructedDate: nil]; | |
[self setStyle: nil]; | |
[self setColor: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATESTRUCTURESHouse *_eNUNCIATESTRUCTURESHouse; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATESTRUCTURESHouse = (ENUNCIATESTRUCTURESHouse *) [ENUNCIATESTRUCTURESHouse readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATESTRUCTURESHouse; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATESTRUCTURESHouse */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATESTRUCTURESHouse (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATESTRUCTURESHouse (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATESTRUCTURESHouse (JAXB) | |
/** | |
* Read an instance of ENUNCIATESTRUCTURESHouse from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATESTRUCTURESHouse defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATESTRUCTURESHouse *_eNUNCIATESTRUCTURESHouse = [[ENUNCIATESTRUCTURESHouse alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATESTRUCTURESHouse initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATESTRUCTURESHouse = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATESTRUCTURESHouse autorelease]; | |
return _eNUNCIATESTRUCTURESHouse; | |
} | |
/** | |
* Initialize this instance of ENUNCIATESTRUCTURESHouse according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATESTRUCTURESHouse to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATESTRUCTURESHouse from an XML reader. The element to be read is | |
* "{http://c.enunciate.codehaus.org/structures}house". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATESTRUCTURESHouse. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATESTRUCTURESHouse *_house = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element {http://c.enunciate.codehaus.org/structures}house."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "house", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlStrcmp(BAD_CAST "http://c.enunciate.codehaus.org/structures", xmlTextReaderConstNamespaceUri(reader)) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {http://c.enunciate.codehaus.org/structures}house."); | |
#endif | |
_house = (ENUNCIATESTRUCTURESHouse *)[ENUNCIATESTRUCTURESHouse readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {http://c.enunciate.codehaus.org/structures}house."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATESTRUCTURESHouse. Expected element {http://c.enunciate.codehaus.org/structures}house. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATESTRUCTURESHouse. Expected element {http://c.enunciate.codehaus.org/structures}house. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _house; | |
} | |
/** | |
* Writes this ENUNCIATESTRUCTURESHouse to XML under element name "{http://c.enunciate.codehaus.org/structures}house". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _house The House to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATESTRUCTURESHouse to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, BAD_CAST "structures", BAD_CAST "house", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {http://c.enunciate.codehaus.org/structures}house. XML writer status: %i\n", rc]; | |
} | |
if (writeNs) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing namespaces for start element {http://c.enunciate.codehaus.org/structures}house..."); | |
#endif | |
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:structures", BAD_CAST "http://c.enunciate.codehaus.org/structures"); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing attribute 'xmlns:structures' on '{http://c.enunciate.codehaus.org/structures}house'. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote namespaces for start element {http://c.enunciate.codehaus.org/structures}house..."); | |
#endif | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {http://c.enunciate.codehaus.org/structures}house for root element {http://c.enunciate.codehaus.org/structures}house..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {http://c.enunciate.codehaus.org/structures}house for root element {http://c.enunciate.codehaus.org/structures}house..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {http://c.enunciate.codehaus.org/structures}house. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
if ((xmlStrcmp(BAD_CAST "type", xmlTextReaderConstLocalName(reader)) == 0) && (xmlTextReaderConstNamespaceUri(reader) == NULL)) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read attribute {}type..."); | |
#endif | |
[self setType: (QName*) [QName readXMLType: reader]]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read attribute {}type..."); | |
#endif | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "base", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}base of type {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}base of type {}rectangle."); | |
#endif | |
[self setBase: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "roof", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
status = 1; | |
if (xmlTextReaderMoveToAttributeNs(reader, BAD_CAST "nil", BAD_CAST "http://www.w3.org/2001/XMLSchema-instance")) { | |
if (xmlStrcmp(BAD_CAST "true", xmlTextReaderConstValue(reader)) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Choice {}roof was nil according to the xsi:nil attribute."); | |
#endif | |
__child = nil; | |
status = 0; | |
} | |
} | |
xmlTextReaderMoveToElement(reader); //move back to the element | |
if (status) { //if not "nil"... | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}roof of type {}triangle."); | |
#endif | |
__child = [ENUNCIATENS0Triangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}roof of type {}triangle."); | |
#endif | |
} //end "if not nil" clause | |
else if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
//if it's not the empty element, skip it because it's nil. | |
xmlTextReaderSkipElement(reader); | |
} | |
[self setRoof: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "door", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}door of type {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}door of type {}rectangle."); | |
#endif | |
[self setDoor: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "doorKnob", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}doorKnob of type {}circle."); | |
#endif | |
__child = [ENUNCIATENS0Circle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}doorKnob of type {}circle."); | |
#endif | |
[self setDoorKnob: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "windows", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Unwrapping wrapper element {}windows..."); | |
#endif | |
//start wrapper element "{}windows" | |
depth = xmlTextReaderDepth(reader); | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
while (xmlTextReaderDepth(reader) > depth) { | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to next wrapped child element."]; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "windows", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}windows of type {}rectangle."); | |
#endif | |
__child = [ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}windows of type {}rectangle."); | |
#endif | |
if ([self windows]) { | |
[self setWindows: [[self windows] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setWindows: [NSArray arrayWithObject: __child]]; | |
} | |
continue; //continue "while in wrapper element" loop | |
} //end "if choice" | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully unwrapped wrapper element {}windows..."); | |
#endif | |
} // end "while in wrapper element" loop | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to end wrapper element."]; | |
} | |
} //end "if empty element" clause | |
else { | |
//we've got an empty wrapper element; see if it's nil. | |
if (xmlTextReaderMoveToAttributeNs(reader, BAD_CAST "nil", BAD_CAST "http://www.w3.org/2001/XMLSchema-instance")) { | |
if (xmlStrcmp(BAD_CAST "true", xmlTextReaderConstValue(reader)) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"wrapper {}windows was nil according to the xsi:nil attribute."); | |
#endif | |
__child = nil; | |
} | |
else { | |
__child = [NSArray array]; | |
} | |
} | |
else { | |
__child = [NSArray array]; | |
} | |
xmlTextReaderMoveToElement(reader); //move back to the element | |
[self setWindows: (NSArray*) __child]; | |
} | |
return YES; | |
} // end "if wrapper element" clause | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "constructedDate", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}constructedDate of type {http://www.w3.org/2001/XMLSchema}dateTime."); | |
#endif | |
__child = [NSDate readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}constructedDate of type {http://www.w3.org/2001/XMLSchema}dateTime."); | |
#endif | |
[self setConstructedDate: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "style", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}style of type {http://www.w3.org/2001/XMLSchema}QName."); | |
#endif | |
__child = [QName readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}style of type {http://www.w3.org/2001/XMLSchema}QName."); | |
#endif | |
[self setStyle: __child]; | |
return YES; | |
} //end "if choice" | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "color", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}color of type {http://www.w3.org/2001/XMLSchema}string."); | |
#endif | |
__child = [NSURL readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}color of type {http://www.w3.org/2001/XMLSchema}string."); | |
#endif | |
[self setColor: __child]; | |
return YES; | |
} //end "if choice" | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
if ([self type]) { | |
if (([[[self type] prefix] length] == 0) && | |
([[[self type] namespaceURI] length] > 0)) { | |
status = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:typeNS", BAD_CAST [[[self type] namespaceURI] UTF8String]); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing namespace attribute xmlns:typeNS."]; | |
} | |
[[self type] setPrefix: @"typeNS"]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
else { | |
NSLog(@"No attempt will be made to write xmlns attribute for QName because either it's the empty namespace, or the prefix is already defined, implying that the xmlns attribute is already written."); | |
} | |
#endif | |
status = xmlTextWriterStartAttributeNS(writer, NULL, BAD_CAST "type", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start attribute {}type."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing attribute {}type..."); | |
#endif | |
[[self type] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote attribute {}type..."); | |
#endif | |
status = xmlTextWriterEndAttribute(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end attribute {}type."]; | |
} | |
} | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if ([self base]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "base", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}base."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}base..."); | |
#endif | |
[[self base] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}base..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}base."]; | |
} | |
} | |
if ([self roof]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "roof", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}roof."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}roof..."); | |
#endif | |
[[self roof] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}roof..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}roof."]; | |
} | |
} | |
if ([self door]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "door", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}door."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}door..."); | |
#endif | |
[[self door] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}door..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}door."]; | |
} | |
} | |
if ([self doorKnob]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "doorKnob", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}doorKnob."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}doorKnob..."); | |
#endif | |
[[self doorKnob] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}doorKnob..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}doorKnob."]; | |
} | |
} | |
if ([self windows]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "windows", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start wrapper element {}windows."]; | |
} | |
__enumerator = [[self windows] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "windows", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}windows."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}windows..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}windows..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}windows."]; | |
} | |
} //end item iterator. | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end wrapper element {}windows."]; | |
} | |
} | |
if ([self constructedDate]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "constructedDate", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}constructedDate."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}constructedDate..."); | |
#endif | |
[[self constructedDate] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}constructedDate..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}constructedDate."]; | |
} | |
} | |
if ([self style]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "style", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}style."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}style..."); | |
#endif | |
if (([[[self style] prefix] length] == 0) && | |
([[[self style] namespaceURI] length] > 0)) { | |
status = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns:styleNS", BAD_CAST [[[self style] namespaceURI] UTF8String]); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing namespace attribute xmlns:styleNS."]; | |
} | |
[[self style] setPrefix: @"styleNS"]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
else { | |
NSLog(@"No attempt will be made to write xmlns attribute for QName because either it's the empty namespace, or the prefix is already defined, implying that the xmlns attribute is already written."); | |
} | |
#endif | |
[[self style] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}style..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}style."]; | |
} | |
} | |
if ([self color]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "color", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}color."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}color..."); | |
#endif | |
[[self color] writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}color..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}color."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATESTRUCTURESHouse (JAXB) */ | |
#endif /* DEF_ENUNCIATESTRUCTURESHouse_M */ | |
#ifndef DEF_ENUNCIATENS0Color_M | |
#define DEF_ENUNCIATENS0Color_M | |
/** | |
* Reads a Color from XML. The reader is assumed to be at the start element. | |
* | |
* @param reader The XML reader. | |
* @return The Color, or NULL if unable to be read. | |
*/ | |
static enum ENUNCIATENS0Color *xmlTextReaderReadENUNCIATENS0ColorType(xmlTextReaderPtr reader) | |
{ | |
xmlChar *enumValue = xmlTextReaderReadEntireNodeValue(reader); | |
enum ENUNCIATENS0Color *value = calloc(1, sizeof(enum ENUNCIATENS0Color)); | |
if (enumValue != NULL) { | |
if (xmlStrcmp(enumValue, BAD_CAST "RED") == 0) { | |
*value = ENUNCIATE_NS0_COLOR_RED; | |
free(enumValue); | |
return value; | |
} | |
if (xmlStrcmp(enumValue, BAD_CAST "YELLOW") == 0) { | |
*value = ENUNCIATE_NS0_COLOR_YELLOW; | |
free(enumValue); | |
return value; | |
} | |
if (xmlStrcmp(enumValue, BAD_CAST "GREEN") == 0) { | |
*value = ENUNCIATE_NS0_COLOR_GREEN; | |
free(enumValue); | |
return value; | |
} | |
if (xmlStrcmp(enumValue, BAD_CAST "BLUE") == 0) { | |
*value = ENUNCIATE_NS0_COLOR_BLUE; | |
free(enumValue); | |
return value; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read enum value failed: %s doesn't match an enum value.", enumValue); | |
#endif | |
} | |
#if DEBUG_ENUNCIATE | |
else { | |
NSLog(@"Attempt to read enum value failed: NULL value."); | |
} | |
#endif | |
return NULL; | |
} | |
/** | |
* Utility method for getting the enum value for a string. | |
* | |
* @param _color The string to format. | |
* @return The enum value or NULL on error. | |
*/ | |
static enum ENUNCIATENS0Color *formatStringToENUNCIATENS0ColorType(NSString *_color) | |
{ | |
enum ENUNCIATENS0Color *value = calloc(1, sizeof(enum ENUNCIATENS0Color)); | |
value = NULL; | |
if ([@"RED" isEqualToString:_color]) { | |
*value = ENUNCIATE_NS0_COLOR_RED; | |
} | |
if ([@"YELLOW" isEqualToString:_color]) { | |
*value = ENUNCIATE_NS0_COLOR_YELLOW; | |
} | |
if ([@"GREEN" isEqualToString:_color]) { | |
*value = ENUNCIATE_NS0_COLOR_GREEN; | |
} | |
if ([@"BLUE" isEqualToString:_color]) { | |
*value = ENUNCIATE_NS0_COLOR_BLUE; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read enum value failed: %s doesn't match an enum value.", _color); | |
#endif | |
return value; | |
} | |
/** | |
* Writes a Color to XML. | |
* | |
* @param writer The XML writer. | |
* @param _color The Color to write. | |
* @return The bytes written (may be 0 in case of buffering) or -1 in case of error. | |
*/ | |
static int xmlTextWriterWriteENUNCIATENS0ColorType(xmlTextWriterPtr writer, enum ENUNCIATENS0Color *_color) | |
{ | |
switch (*_color) { | |
case ENUNCIATE_NS0_COLOR_RED: | |
return xmlTextWriterWriteString(writer, BAD_CAST "RED"); | |
case ENUNCIATE_NS0_COLOR_YELLOW: | |
return xmlTextWriterWriteString(writer, BAD_CAST "YELLOW"); | |
case ENUNCIATE_NS0_COLOR_GREEN: | |
return xmlTextWriterWriteString(writer, BAD_CAST "GREEN"); | |
case ENUNCIATE_NS0_COLOR_BLUE: | |
return xmlTextWriterWriteString(writer, BAD_CAST "BLUE"); | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to write enum value (no valid value found)."); | |
#endif | |
return -1; | |
} | |
/** | |
* Utility method for getting the string value of Color. | |
* | |
* @param _color The Color to format. | |
* @return The string value or NULL on error. | |
*/ | |
static NSString *formatENUNCIATENS0ColorTypeToString(enum ENUNCIATENS0Color *_color) | |
{ | |
switch (*_color) { | |
case ENUNCIATE_NS0_COLOR_RED: | |
return @"RED"; | |
case ENUNCIATE_NS0_COLOR_YELLOW: | |
return @"YELLOW"; | |
case ENUNCIATE_NS0_COLOR_GREEN: | |
return @"GREEN"; | |
case ENUNCIATE_NS0_COLOR_BLUE: | |
return @"BLUE"; | |
default: | |
return NULL; | |
} | |
return NULL; | |
} | |
#endif /* DEF_ENUNCIATENS0Color_M */ | |
#ifndef DEF_ENUNCIATENS0Rectangle_M | |
#define DEF_ENUNCIATENS0Rectangle_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Rectangle | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) width | |
{ | |
return _width; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setWidth: (int) newWidth | |
{ | |
_width = newWidth; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) height | |
{ | |
return _height; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setHeight: (int) newHeight | |
{ | |
_height = newHeight; | |
} | |
- (void) dealloc | |
{ | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATENS0Rectangle *_eNUNCIATENS0Rectangle; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATENS0Rectangle = (ENUNCIATENS0Rectangle *) [ENUNCIATENS0Rectangle readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATENS0Rectangle; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATENS0Rectangle */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Rectangle (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATENS0Rectangle (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Rectangle (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Rectangle from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Rectangle defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Rectangle *_eNUNCIATENS0Rectangle = [[ENUNCIATENS0Rectangle alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Rectangle initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Rectangle = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Rectangle autorelease]; | |
return _eNUNCIATENS0Rectangle; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Rectangle according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Rectangle to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATENS0Rectangle from an XML reader. The element to be read is | |
* "rectangle". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATENS0Rectangle. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATENS0Rectangle *_rectangle = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element rectangle."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "rectangle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {}rectangle."); | |
#endif | |
_rectangle = (ENUNCIATENS0Rectangle *)[ENUNCIATENS0Rectangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {}rectangle."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Rectangle. Expected element rectangle. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Rectangle. Expected element rectangle. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _rectangle; | |
} | |
/** | |
* Writes this ENUNCIATENS0Rectangle to XML under element name "rectangle". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _rectangle The Rectangle to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATENS0Rectangle to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "rectangle", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {}rectangle. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {}rectangle for root element {}rectangle..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {}rectangle for root element {}rectangle..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {}rectangle. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "width", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setWidth: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "height", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setHeight: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "width", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}width."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}width..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_width); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}width..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}width."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}width."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "height", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}height."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}height..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_height); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}height..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}height."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}height."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATENS0Rectangle (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Rectangle_M */ | |
#ifndef DEF_ENUNCIATENS0Triangle_M | |
#define DEF_ENUNCIATENS0Triangle_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Triangle | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) base | |
{ | |
return _base; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setBase: (int) newBase | |
{ | |
_base = newBase; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) height | |
{ | |
return _height; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setHeight: (int) newHeight | |
{ | |
_height = newHeight; | |
} | |
- (void) dealloc | |
{ | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATENS0Triangle *_eNUNCIATENS0Triangle; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATENS0Triangle = (ENUNCIATENS0Triangle *) [ENUNCIATENS0Triangle readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATENS0Triangle; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATENS0Triangle */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Triangle (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATENS0Triangle (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Triangle (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Triangle from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Triangle defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Triangle *_eNUNCIATENS0Triangle = [[ENUNCIATENS0Triangle alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Triangle initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Triangle = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Triangle autorelease]; | |
return _eNUNCIATENS0Triangle; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Triangle according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Triangle to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATENS0Triangle from an XML reader. The element to be read is | |
* "triangle". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATENS0Triangle. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATENS0Triangle *_triangle = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element triangle."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "triangle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {}triangle."); | |
#endif | |
_triangle = (ENUNCIATENS0Triangle *)[ENUNCIATENS0Triangle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {}triangle."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Triangle. Expected element triangle. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Triangle. Expected element triangle. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _triangle; | |
} | |
/** | |
* Writes this ENUNCIATENS0Triangle to XML under element name "triangle". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _triangle The Triangle to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATENS0Triangle to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "triangle", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {}triangle. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {}triangle for root element {}triangle..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {}triangle for root element {}triangle..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {}triangle. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "base", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setBase: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "height", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setHeight: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "base", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}base."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}base..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_base); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}base..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}base."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}base."]; | |
} | |
} | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "height", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}height."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}height..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_height); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}height..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}height."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}height."]; | |
} | |
} | |
} | |
@end /* implementation ENUNCIATENS0Triangle (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Triangle_M */ | |
#ifndef DEF_ENUNCIATENS0LineStyle_M | |
#define DEF_ENUNCIATENS0LineStyle_M | |
/** | |
* Reads a LineStyle from XML. The reader is assumed to be at the start element. | |
* | |
* @param reader The XML reader. | |
* @return The LineStyle, or NULL if unable to be read. | |
*/ | |
static enum ENUNCIATENS0LineStyle *xmlTextReaderReadENUNCIATENS0LineStyleType(xmlTextReaderPtr reader) | |
{ | |
xmlChar *enumValue = xmlTextReaderReadEntireNodeValue(reader); | |
enum ENUNCIATENS0LineStyle *value = calloc(1, sizeof(enum ENUNCIATENS0LineStyle)); | |
if (enumValue != NULL) { | |
if (xmlStrcmp(enumValue, BAD_CAST "1") == 0) { | |
*value = ENUNCIATE_NS0_LINESTYLE_SOLID; | |
free(enumValue); | |
return value; | |
} | |
if (xmlStrcmp(enumValue, BAD_CAST "2") == 0) { | |
*value = ENUNCIATE_NS0_LINESTYLE_DOTTED; | |
free(enumValue); | |
return value; | |
} | |
if (xmlStrcmp(enumValue, BAD_CAST "3") == 0) { | |
*value = ENUNCIATE_NS0_LINESTYLE_DASHED; | |
free(enumValue); | |
return value; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read enum value failed: %s doesn't match an enum value.", enumValue); | |
#endif | |
} | |
#if DEBUG_ENUNCIATE | |
else { | |
NSLog(@"Attempt to read enum value failed: NULL value."); | |
} | |
#endif | |
return NULL; | |
} | |
/** | |
* Utility method for getting the enum value for a string. | |
* | |
* @param _lineStyle The string to format. | |
* @return The enum value or NULL on error. | |
*/ | |
static enum ENUNCIATENS0LineStyle *formatStringToENUNCIATENS0LineStyleType(NSString *_lineStyle) | |
{ | |
enum ENUNCIATENS0LineStyle *value = calloc(1, sizeof(enum ENUNCIATENS0LineStyle)); | |
value = NULL; | |
if ([@"1" isEqualToString:_lineStyle]) { | |
*value = ENUNCIATE_NS0_LINESTYLE_SOLID; | |
} | |
if ([@"2" isEqualToString:_lineStyle]) { | |
*value = ENUNCIATE_NS0_LINESTYLE_DOTTED; | |
} | |
if ([@"3" isEqualToString:_lineStyle]) { | |
*value = ENUNCIATE_NS0_LINESTYLE_DASHED; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read enum value failed: %s doesn't match an enum value.", _lineStyle); | |
#endif | |
return value; | |
} | |
/** | |
* Writes a LineStyle to XML. | |
* | |
* @param writer The XML writer. | |
* @param _lineStyle The LineStyle to write. | |
* @return The bytes written (may be 0 in case of buffering) or -1 in case of error. | |
*/ | |
static int xmlTextWriterWriteENUNCIATENS0LineStyleType(xmlTextWriterPtr writer, enum ENUNCIATENS0LineStyle *_lineStyle) | |
{ | |
switch (*_lineStyle) { | |
case ENUNCIATE_NS0_LINESTYLE_SOLID: | |
return xmlTextWriterWriteString(writer, BAD_CAST "1"); | |
case ENUNCIATE_NS0_LINESTYLE_DOTTED: | |
return xmlTextWriterWriteString(writer, BAD_CAST "2"); | |
case ENUNCIATE_NS0_LINESTYLE_DASHED: | |
return xmlTextWriterWriteString(writer, BAD_CAST "3"); | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to write enum value (no valid value found)."); | |
#endif | |
return -1; | |
} | |
/** | |
* Utility method for getting the string value of LineStyle. | |
* | |
* @param _lineStyle The LineStyle to format. | |
* @return The string value or NULL on error. | |
*/ | |
static NSString *formatENUNCIATENS0LineStyleTypeToString(enum ENUNCIATENS0LineStyle *_lineStyle) | |
{ | |
switch (*_lineStyle) { | |
case ENUNCIATE_NS0_LINESTYLE_SOLID: | |
return @"1"; | |
case ENUNCIATE_NS0_LINESTYLE_DOTTED: | |
return @"2"; | |
case ENUNCIATE_NS0_LINESTYLE_DASHED: | |
return @"3"; | |
default: | |
return NULL; | |
} | |
return NULL; | |
} | |
#endif /* DEF_ENUNCIATENS0LineStyle_M */ | |
#ifndef DEF_ENUNCIATENS0Circle_M | |
#define DEF_ENUNCIATENS0Circle_M | |
/** | |
* @author Ryan Heaton | |
*/ | |
@implementation ENUNCIATENS0Circle | |
/** | |
* (no documentation provided) | |
*/ | |
- (int) radius | |
{ | |
return _radius; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setRadius: (int) newRadius | |
{ | |
_radius = newRadius; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) dots | |
{ | |
return _dots; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setDots: (NSArray *) newDots | |
{ | |
[newDots retain]; | |
[_dots release]; | |
_dots = newDots; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) stars | |
{ | |
return _stars; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setStars: (NSArray *) newStars | |
{ | |
[newStars retain]; | |
[_stars release]; | |
_stars = newStars; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (NSArray *) palette | |
{ | |
return _palette; | |
} | |
/** | |
* (no documentation provided) | |
*/ | |
- (void) setPalette: (NSArray *) newPalette | |
{ | |
[newPalette retain]; | |
[_palette release]; | |
_palette = newPalette; | |
} | |
- (void) dealloc | |
{ | |
[self setDots: nil]; | |
[self setStars: nil]; | |
[self setPalette: nil]; | |
[super dealloc]; | |
} | |
//documentation inherited. | |
+ (id<EnunciateXML>) readFromXML: (NSData *) xml | |
{ | |
ENUNCIATENS0Circle *_eNUNCIATENS0Circle; | |
xmlTextReaderPtr reader = xmlReaderForMemory([xml bytes], [xml length], NULL, NULL, 0); | |
if (reader == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error instantiating an XML reader."]; | |
return nil; | |
} | |
_eNUNCIATENS0Circle = (ENUNCIATENS0Circle *) [ENUNCIATENS0Circle readXMLElement: reader]; | |
xmlFreeTextReader(reader); //free the reader | |
return _eNUNCIATENS0Circle; | |
} | |
//documentation inherited. | |
- (NSData *) writeToXML | |
{ | |
xmlBufferPtr buf; | |
xmlTextWriterPtr writer; | |
int rc; | |
NSData *data; | |
buf = xmlBufferCreate(); | |
if (buf == NULL) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML buffer."]; | |
return nil; | |
} | |
writer = xmlNewTextWriterMemory(buf, 0); | |
if (writer == NULL) { | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error creating an XML writer."]; | |
return nil; | |
} | |
rc = xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML start document."]; | |
return nil; | |
} | |
NS_DURING | |
{ | |
[self writeXMLElement: writer]; | |
} | |
NS_HANDLER | |
{ | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
rc = xmlTextWriterEndDocument(writer); | |
if (rc < 0) { | |
xmlFreeTextWriter(writer); | |
xmlBufferFree(buf); | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing XML end document."]; | |
return nil; | |
} | |
xmlFreeTextWriter(writer); | |
data = [NSData dataWithBytes: buf->content length: buf->use]; | |
xmlBufferFree(buf); | |
return data; | |
} | |
@end /* implementation ENUNCIATENS0Circle */ | |
/** | |
* Internal, private interface for JAXB reading and writing. | |
*/ | |
@interface ENUNCIATENS0Circle (JAXB) <JAXBReading, JAXBWriting, JAXBType, JAXBElement> | |
@end /*interface ENUNCIATENS0Circle (JAXB)*/ | |
/** | |
* Internal, private implementation for JAXB reading and writing. | |
*/ | |
@implementation ENUNCIATENS0Circle (JAXB) | |
/** | |
* Read an instance of ENUNCIATENS0Circle from an XML reader. | |
* | |
* @param reader The reader. | |
* @return An instance of ENUNCIATENS0Circle defined by the XML reader. | |
*/ | |
+ (id<JAXBType>) readXMLType: (xmlTextReaderPtr) reader | |
{ | |
ENUNCIATENS0Circle *_eNUNCIATENS0Circle = [[ENUNCIATENS0Circle alloc] init]; | |
NS_DURING | |
{ | |
[_eNUNCIATENS0Circle initWithReader: reader]; | |
} | |
NS_HANDLER | |
{ | |
_eNUNCIATENS0Circle = nil; | |
[localException raise]; | |
} | |
NS_ENDHANDLER | |
[_eNUNCIATENS0Circle autorelease]; | |
return _eNUNCIATENS0Circle; | |
} | |
/** | |
* Initialize this instance of ENUNCIATENS0Circle according to | |
* the XML being read from the reader. | |
* | |
* @param reader The reader. | |
*/ | |
- (id) initWithReader: (xmlTextReaderPtr) reader | |
{ | |
return [super initWithReader: reader]; | |
} | |
/** | |
* Write the XML for this instance of ENUNCIATENS0Circle to the writer. | |
* Note that since we're only writing the XML type, | |
* No start/end element will be written. | |
* | |
* @param reader The reader. | |
*/ | |
- (void) writeXMLType: (xmlTextWriterPtr) writer | |
{ | |
[super writeXMLType:writer]; | |
} | |
/** | |
* Reads a ENUNCIATENS0Circle from an XML reader. The element to be read is | |
* "circle". | |
* | |
* @param reader The XML reader. | |
* @return The ENUNCIATENS0Circle. | |
*/ | |
+ (id<JAXBElement>) readXMLElement: (xmlTextReaderPtr) reader { | |
int status; | |
ENUNCIATENS0Circle *_circle = nil; | |
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) { | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
if (status < 1) { | |
[NSException raise: @"XMLReadError" | |
format: @"Error advancing the reader to start element circle."]; | |
} | |
} | |
if (xmlStrcmp(BAD_CAST "circle", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read root element {}circle."); | |
#endif | |
_circle = (ENUNCIATENS0Circle *)[ENUNCIATENS0Circle readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Successfully read root element {}circle."); | |
#endif | |
} | |
else { | |
if (xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Circle. Expected element circle. Current element: {}%s", xmlTextReaderConstLocalName(reader)]; | |
} | |
else { | |
[NSException raise: @"XMLReadError" | |
format: @"Unable to read ENUNCIATENS0Circle. Expected element circle. Current element: {%s}%s\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader)]; | |
} | |
} | |
return _circle; | |
} | |
/** | |
* Writes this ENUNCIATENS0Circle to XML under element name "circle". | |
* The namespace declarations for the element will be written. | |
* | |
* @param writer The XML writer. | |
* @param _circle The Circle to write. | |
* @return 1 if successful, 0 otherwise. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer | |
{ | |
[self writeXMLElement: writer writeNamespaces: YES]; | |
} | |
/** | |
* Writes this ENUNCIATENS0Circle to an XML writer. | |
* | |
* @param writer The writer. | |
* @param writeNs Whether to write the namespaces for this element to the xml writer. | |
*/ | |
- (void) writeXMLElement: (xmlTextWriterPtr) writer writeNamespaces: (BOOL) writeNs | |
{ | |
int rc = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "circle", NULL); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start element {}circle. XML writer status: %i\n", rc]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing type {}circle for root element {}circle..."); | |
#endif | |
[self writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote type {}circle for root element {}circle..."); | |
#endif | |
rc = xmlTextWriterEndElement(writer); | |
if (rc < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end element {}circle. XML writer status: %i\n", rc]; | |
} | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
void *_child_accessor; | |
if ([super readJAXBAttribute: reader]) { | |
return YES; | |
} | |
return NO; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBValue: (xmlTextReaderPtr) reader | |
{ | |
return [super readJAXBValue: reader]; | |
} | |
//documentation inherited. | |
- (BOOL) readJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
id __child; | |
void *_child_accessor; | |
int status, depth; | |
if ([super readJAXBChildElement: reader]) { | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "radius", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
_child_accessor = xmlTextReaderReadIntType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
[self setRadius: *((int*) _child_accessor)]; | |
free(_child_accessor); | |
return YES; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "dots", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Unwrapping wrapper element {}dots..."); | |
#endif | |
//start wrapper element "{}dots" | |
depth = xmlTextReaderDepth(reader); | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
while (xmlTextReaderDepth(reader) > depth) { | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to next wrapped child element."]; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "dot", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}dot of type {}dot."); | |
#endif | |
__child = [ENUNCIATENS0Dot readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}dot of type {}dot."); | |
#endif | |
if ([self dots]) { | |
[self setDots: [[self dots] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setDots: [NSArray arrayWithObject: __child]]; | |
} | |
continue; //continue "while in wrapper element" loop | |
} //end "if choice" | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully unwrapped wrapper element {}dots..."); | |
#endif | |
} // end "while in wrapper element" loop | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to end wrapper element."]; | |
} | |
} //end "if empty element" clause | |
else { | |
__child = [NSArray array]; | |
[self setDots: (NSArray*) __child]; | |
} | |
return YES; | |
} // end "if wrapper element" clause | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "stars", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
if (xmlTextReaderIsEmptyElement(reader) == 0) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Unwrapping wrapper element {}stars..."); | |
#endif | |
//start wrapper element "{}stars" | |
depth = xmlTextReaderDepth(reader); | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
while (xmlTextReaderDepth(reader) > depth) { | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to next wrapped child element."]; | |
} | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "star", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}star of type {}dot."); | |
#endif | |
__child = [ENUNCIATENS0Dot readXMLType: reader]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}star of type {}dot."); | |
#endif | |
if ([self stars]) { | |
[self setStars: [[self stars] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setStars: [NSArray arrayWithObject: __child]]; | |
} | |
continue; //continue "while in wrapper element" loop | |
} //end "if choice" | |
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully unwrapped wrapper element {}stars..."); | |
#endif | |
} // end "while in wrapper element" loop | |
if (status < 1) { | |
//panic: XML read error. | |
[NSException raise: @"XMLReadError" | |
format: @"Failure to advance to end wrapper element."]; | |
} | |
} //end "if empty element" clause | |
else { | |
__child = [NSArray array]; | |
[self setStars: (NSArray*) __child]; | |
} | |
return YES; | |
} // end "if wrapper element" clause | |
if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT | |
&& xmlStrcmp(BAD_CAST "palette", xmlTextReaderConstLocalName(reader)) == 0 | |
&& xmlTextReaderConstNamespaceUri(reader) == NULL) { | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"Attempting to read choice {}palette of type {}color."); | |
#endif | |
_child_accessor = xmlTextReaderReadENUNCIATENS0ColorType(reader); | |
if (_child_accessor == NULL) { | |
//panic: unable to return the value for some reason. | |
[NSException raise: @"XMLReadError" | |
format: @"Error reading element value."]; | |
} | |
__child = [NSValue value: _child_accessor withObjCType: @encode(enum ENUNCIATENS0Color)]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully read choice {}palette of type {}color."); | |
#endif | |
if ([self palette]) { | |
[self setPalette: [[self palette] arrayByAddingObject: __child]]; | |
} | |
else { | |
[self setPalette: [NSArray arrayWithObject: __child]]; | |
} | |
return YES; | |
} //end "if choice" | |
return NO; | |
} | |
//documentation inherited. | |
- (int) readUnknownJAXBChildElement: (xmlTextReaderPtr) reader | |
{ | |
return [super readUnknownJAXBChildElement: reader]; | |
} | |
//documentation inherited. | |
- (void) readUnknownJAXBAttribute: (xmlTextReaderPtr) reader | |
{ | |
[super readUnknownJAXBAttribute: reader]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBAttributes: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
[super writeJAXBAttributes: writer]; | |
} | |
//documentation inherited. | |
- (void) writeJAXBValue: (xmlTextWriterPtr) writer | |
{ | |
[super writeJAXBValue: writer]; | |
} | |
/** | |
* Method for writing the child elements. | |
* | |
* @param writer The writer. | |
*/ | |
- (void) writeJAXBChildElements: (xmlTextWriterPtr) writer | |
{ | |
int status; | |
id __item; | |
id __item_copy; | |
NSEnumerator *__enumerator; | |
[super writeJAXBChildElements: writer]; | |
if (YES) { //always write the primitive element... | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "radius", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}radius."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}radius..."); | |
#endif | |
status = xmlTextWriterWriteIntType(writer, &_radius); | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}radius..."); | |
#endif | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}radius."]; | |
} | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}radius."]; | |
} | |
} | |
if ([self dots]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "dots", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start wrapper element {}dots."]; | |
} | |
__enumerator = [[self dots] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "dot", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}dot."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}dot..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}dot..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}dot."]; | |
} | |
} //end item iterator. | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end wrapper element {}dots."]; | |
} | |
} | |
if ([self stars]) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "stars", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start wrapper element {}stars."]; | |
} | |
__enumerator = [[self stars] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "star", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}star."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}star..."); | |
#endif | |
[__item writeXMLType: writer]; | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}star..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}star."]; | |
} | |
} //end item iterator. | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end wrapper element {}stars."]; | |
} | |
} | |
if ([self palette]) { | |
__enumerator = [[self palette] objectEnumerator]; | |
while ( (__item = [__enumerator nextObject]) ) { | |
status = xmlTextWriterStartElementNS(writer, NULL, BAD_CAST "palette", NULL); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing start child element {}palette."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"writing element {}palette..."); | |
#endif | |
__item_copy = malloc(sizeof(enum ENUNCIATENS0Color)); | |
[((NSValue *)__item) getValue:__item_copy]; | |
status = xmlTextWriterWriteENUNCIATENS0ColorType(writer, ((enum ENUNCIATENS0Color*) __item_copy)); | |
free(__item_copy); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing child element {}palette."]; | |
} | |
#if DEBUG_ENUNCIATE > 1 | |
NSLog(@"successfully wrote element {}palette..."); | |
#endif | |
status = xmlTextWriterEndElement(writer); | |
if (status < 0) { | |
[NSException raise: @"XMLWriteError" | |
format: @"Error writing end child element {}palette."]; | |
} | |
} //end item iterator. | |
} | |
} | |
@end /* implementation ENUNCIATENS0Circle (JAXB) */ | |
#endif /* DEF_ENUNCIATENS0Circle_M */ | |
#ifndef DEF_ENUNCIATENS1BusType_M | |
#define DEF_ENUNCIATENS1BusType_M | |
/** | |
* Gets the known BusType for a QName. | |
* | |
* @param qname The QName | |
* @return The BusType, or -1 if unable to be read. | |
*/ | |
static enum ENUNCIATENS1BusType getKnownENUNCIATENS1BusType(QName *qname) | |
{ | |
if (qname) { | |
if (([[qname namespaceURI] length] == 0) | |
&& ([@"charter" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_NS1_BUSTYPE_CHARTER; | |
} | |
if (([[qname namespaceURI] length] == 0) | |
&& ([@"school" isEqualToString:[qname localPart] ])) { | |
return ENUNCIATE_NS1_BUSTYPE_SCHOOL; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: qname {%@}%@ doesn't match an enum value: returning null.", [qname namespaceURI], [qname localPart]); | |
#endif | |
return -1; | |
} | |
else { | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Attempt to read known qname value failed: nil value."); | |
#endif | |
return -1; | |
} | |
} | |
/** | |
* Convert a known BusType to a QName. | |
* | |
* @param _busType The known BusType. | |
* @return The QName, or nil if an unknown enum constant. | |
*/ | |
static QName *convertKnownENUNCIATENS1BusType(enum ENUNCIATENS1BusType _busType) | |
{ | |
QName *qname; | |
switch (_busType) { | |
case ENUNCIATE_NS1_BUSTYPE_CHARTER: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @""]; | |
[qname setLocalPart: @"charter"]; | |
[qname setPrefix: @"ns1"]; | |
[qname autorelease]; | |
return qname; | |
case ENUNCIATE_NS1_BUSTYPE_SCHOOL: | |
qname = [[QName alloc] init]; | |
[qname setNamespaceURI: @""]; | |
[qname setLocalPart: @"school"]; | |
[qname setPrefix: @"ns1"]; | |
[qname autorelease]; | |
return qname; | |
} | |
#if DEBUG_ENUNCIATE | |
NSLog(@"Unable to write enum value (no valid value found)."); | |
#endif | |
return nil; | |
} | |
#endif /* DEF_ENUNCIATENS1BusType_M */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment