10#ifdef __MINGW64_VERSION_MAJOR
18# define LIBXML_ATTR_FORMAT( fmt, args )
21#include "libxml/parser.h"
22#include "libxml/xmlwriter.h"
25#include "attributes.h"
29#define XML_NODE_START 1
30#define XML_NODE_TEXT 3
35#define xml_onlyNodes(n) \
36 if (((n)==NULL) || ((n)->type!=XML_NODE_START)) \
40#define xml_isNode(n,s) \
41 ((n!=NULL) && ((n)->type==XML_NODE_START) && \
42 (strcmp((char*)(n)->name,s)==0))
45#define xml_nextNode(n) \
46 ((n!=NULL) && ((n = n->next) != NULL))
49#define xml_raw(n) ((char*)(n)->children->content)
50#define xml_get(n) (((n)->children == NULL) ? NULL : (char*)(n)->children->content)
51#define xml_getInt(n) ((xml_get(n) == NULL) ? 0 : strtol( xml_raw(n), NULL, 10 ))
52#define xml_getUInt(n) ((xml_get(n) == NULL) ? 0 : strtoul( xml_raw(n), NULL, 10 ))
53#define xml_getLong(n) ((xml_get(n) == NULL) ? 0 : strtoll( xml_raw(n), NULL, 10 ))
54#define xml_getULong(n) ((xml_get(n) == NULL) ? 0 : strtoull( xml_raw(n), NULL, 10 ))
55#define xml_getFloat(n) ((xml_get(n) == NULL) ? 0. : strtod( xml_raw(n), NULL ))
56#define xml_getStrd(n) ((xml_get(n) == NULL) ? NULL : strdup(xml_raw(n)))
61#define xmlr_int(n,s,i) \
62 {if (xml_isNode(n,s)) { \
63 i = xml_getInt(n); continue; }}
64#define xmlr_uint(n,s,i) \
65 {if (xml_isNode(n,s)) { \
66 i = xml_getUInt(n); continue; }}
67#define xmlr_long(n,s,l) \
68 {if (xml_isNode(n,s)) { \
69 l = xml_getLong(n); continue; }}
70#define xmlr_ulong(n,s,l) \
71 {if (xml_isNode(n,s)) { \
72 l = xml_getULong(n); continue; }}
73#define xmlr_float(n,s,f) \
74 {if (xml_isNode(n,s)) { \
75 f = xml_getFloat(n); continue; }}
76#define xmlr_floatR(n,s,f) \
77 {if (xml_isNode(n,s)) { \
78 f = xml_getFloat(n); return 0; }}
79#define xmlr_str(n,s,str) \
80 {if (xml_isNode(n,s)) { \
81 str = xml_get(n); continue; }}
82#define xmlr_strd(n,s,str) \
83 {if (xml_isNode(n,s)) { \
85 WARN("Node '%s' already loaded and being replaced from '%s' to '%s'", \
86 s, str, xml_raw(n) ); } \
87 str = ((xml_get(n) == NULL) ? NULL : strdup(xml_raw(n))); continue; }}
93static inline char* nxml_trace_strdup(
void* ptr )
95 void *pointer_from_libxml2 = ptr;
96 char *ret = (ptr == NULL) ? NULL : strdup(ptr);
97 free( pointer_from_libxml2 );
101#define nxml_trace_strdup(ptr) ((char*) (ptr))
105#define xmlr_attr_strd(n,s,a) a = nxml_trace_strdup( xmlGetProp( n, (xmlChar*)s ) )
108#define xmlr_attr_int_def(n,s,a,def) do {xmlr_attr_strd(n,s,char*T); a = T==NULL?def: strtol( T, NULL, 10); free(T);} while(0)
109#define xmlr_attr_uint_def(n,s,a,def) do {xmlr_attr_strd(n,s,char*T); a = T==NULL?def: strtoul( T, NULL, 10); free(T);} while(0)
110#define xmlr_attr_long_def(n,s,a,def) do {xmlr_attr_strd(n,s,char*T); a = T==NULL?def: strtoll( T, NULL, 10); free(T);} while(0)
111#define xmlr_attr_ulong_def(n,s,a,def) do {xmlr_attr_strd(n,s,char*T); a = T==NULL?def:strtoull( T, NULL, 10); free(T);} while(0)
112#define xmlr_attr_float_def(n,s,a,def) do {xmlr_attr_strd(n,s,char*T); a = T==NULL?def: strtod( T, NULL ); free(T);} while(0)
114#define xmlr_attr_int(n,s,a) xmlr_attr_int_def(n,s,a,0)
115#define xmlr_attr_uint(n,s,a) xmlr_attr_uint_def(n,s,a,0)
116#define xmlr_attr_long(n,s,a) xmlr_attr_long_def(n,s,a,0)
117#define xmlr_attr_ulong(n,s,a) xmlr_attr_ulong_def(n,s,a,0)
118#define xmlr_attr_float(n,s,a) xmlr_attr_float_def(n,s,a,0.)
120#define xmlr_attr_int_opt(n,s,a) xmlr_attr_int_def(n,s,a,a)
121#define xmlr_attr_uint_opt(n,s,a) xmlr_attr_uint_def(n,s,a,a)
122#define xmlr_attr_long_opt(n,s,a) xmlr_attr_long_def(n,s,a,a)
123#define xmlr_attr_ulong_opt(n,s,a) xmlr_attr_ulong_def(n,s,a,a)
124#define xmlr_attr_float_opt(n,s,a) xmlr_attr_float_def(n,s,a,a)
130#define xmlw_startElem(w,str) \
131do {if (xmlTextWriterStartElement(w,(xmlChar*)str) < 0) { \
132 ERR("xmlw: unable to create start element"); return -1; } } while (0)
133#define xmlw_endElem(w) \
134do {if (xmlTextWriterEndElement(w) < 0) { \
135 ERR("xmlw: unable to create end element"); return -1; } } while (0)
137#define xmlw_elemEmpty(w,n) \
138do { xmlw_startElem(w,n); xmlw_endElem(w); } while (0)
139#define xmlw_elem(w,n,str,...) \
140do { if (xmlTextWriterWriteFormatElement(w,(xmlChar*)n, \
141 str, ## __VA_ARGS__) < 0) { \
142 ERR("xmlw: unable to write format element"); return -1; } } while (0)
143#define xmlw_raw(w,b,l) \
144do {if (xmlTextWriterWriteRawLen(w,(xmlChar*)b,l) < 0) { \
145 ERR("xmlw: unable to write raw element"); return -1; } } while (0)
146#define xmlw_attr(w,str,...) \
147do {if (xmlTextWriterWriteFormatAttribute(w,(xmlChar*)str, \
148 ## __VA_ARGS__) < 0) { \
149 ERR("xmlw: unable to write element attribute"); return -1; } } while (0)
150#define xmlw_str(w,str,...) \
151do {if (xmlTextWriterWriteFormatString(w,str, ## __VA_ARGS__) < 0) { \
152 ERR("xmlw: unable to write element data"); return -1; } } while (0)
154#define xmlw_start(w) \
155do {if (xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) { \
156 ERR("xmlw: unable to start document"); return -1; } } while (0)
157#define xmlw_done(w) \
158do {if (xmlTextWriterEndDocument(w) < 0) { \
159 ERR("xmlw: unable to end document"); return -1; } } while (0)
166 const char *path,
int defsx,
int defsy,
167 const unsigned int flags );
168int xml_parseTime( xmlNodePtr node, time_t *t );
174int xmlw_saveTime( xmlTextWriterPtr writer,
const char *name, time_t t );
glTexture * xml_parseTexture(xmlNodePtr node, const char *path, int defsx, int defsy, const unsigned int flags)
Parses a texture handling the sx and sy elements.
void xmlw_setParams(xmlTextWriterPtr writer)
Sets up the standard xml write parameters.
xmlDocPtr xml_parsePhysFS(const char *filename)
Analogous to xmlParseMemory/xmlParseFile.
Abstraction for rendering sprite sheets.