2 * IXmlWriter implementation
4 * Copyright 2011 Alistair Leslie-Hughes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "xmllite_private.h"
23 typedef struct _xmlwriter
25 IXmlWriter IXmlWriter_iface
;
29 static inline xmlwriter
*impl_from_IXmlWriter(IXmlWriter
*iface
)
31 return CONTAINING_RECORD(iface
, xmlwriter
, IXmlWriter_iface
);
34 static HRESULT WINAPI
xmlwriter_QueryInterface(IXmlWriter
*iface
, REFIID riid
, void **ppvObject
)
36 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
38 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
40 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
41 IsEqualGUID(riid
, &IID_IXmlWriter
))
46 IXmlWriter_AddRef(iface
);
51 static ULONG WINAPI
xmlwriter_AddRef(IXmlWriter
*iface
)
53 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
55 return InterlockedIncrement(&This
->ref
);
58 static ULONG WINAPI
xmlwriter_Release(IXmlWriter
*iface
)
60 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
65 ref
= InterlockedDecrement(&This
->ref
);
68 HeapFree(GetProcessHeap(), 0, This
);
74 /*** IXmlWriter methods ***/
75 static HRESULT WINAPI
xmlwriter_SetOutput(IXmlWriter
*iface
, IUnknown
*pOutput
)
77 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
79 FIXME("%p %p\n", This
, pOutput
);
84 static HRESULT WINAPI
xmlwriter_GetProperty(IXmlWriter
*iface
, UINT nProperty
, LONG_PTR
*ppValue
)
86 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
88 FIXME("%p %u %p\n", This
, nProperty
, ppValue
);
93 static HRESULT WINAPI
xmlwriter_SetProperty(IXmlWriter
*iface
, UINT nProperty
, LONG_PTR pValue
)
95 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
97 FIXME("%p %u %lu\n", This
, nProperty
, pValue
);
102 static HRESULT WINAPI
xmlwriter_WriteAttributes(IXmlWriter
*iface
, IXmlReader
*pReader
,
103 BOOL fWriteDefaultAttributes
)
105 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
107 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
112 static HRESULT WINAPI
xmlwriter_WriteAttributeString(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
113 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
,
116 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
118 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
119 wine_dbgstr_w(pwszNamespaceUri
), wine_dbgstr_w(pwszValue
));
124 static HRESULT WINAPI
xmlwriter_WriteCData(IXmlWriter
*iface
, LPCWSTR pwszText
)
126 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
128 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszText
));
133 static HRESULT WINAPI
xmlwriter_WriteCharEntity(IXmlWriter
*iface
, WCHAR wch
)
138 static HRESULT WINAPI
xmlwriter_WriteChars(IXmlWriter
*iface
, const WCHAR
*pwch
, UINT cwch
)
140 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
142 FIXME("%p %s %d\n", This
, wine_dbgstr_w(pwch
), cwch
);
147 static HRESULT WINAPI
xmlwriter_WriteComment(IXmlWriter
*iface
, LPCWSTR pwszComment
)
152 static HRESULT WINAPI
xmlwriter_WriteDocType(IXmlWriter
*iface
, LPCWSTR pwszName
, LPCWSTR pwszPublicId
,
153 LPCWSTR pwszSystemId
, LPCWSTR pwszSubset
)
155 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
157 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszName
), wine_dbgstr_w(pwszPublicId
),
158 wine_dbgstr_w(pwszSystemId
), wine_dbgstr_w(pwszSubset
));
163 static HRESULT WINAPI
xmlwriter_WriteElementString(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
164 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
,
167 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
169 FIXME("%p %s %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
170 wine_dbgstr_w(pwszNamespaceUri
), wine_dbgstr_w(pwszValue
));
175 static HRESULT WINAPI
xmlwriter_WriteEndDocument(IXmlWriter
*iface
)
177 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
184 static HRESULT WINAPI
xmlwriter_WriteEndElement(IXmlWriter
*iface
)
186 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
193 static HRESULT WINAPI
xmlwriter_WriteEntityRef(IXmlWriter
*iface
, LPCWSTR pwszName
)
195 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
197 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszName
));
202 static HRESULT WINAPI
xmlwriter_WriteFullEndElement(IXmlWriter
*iface
)
204 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
211 static HRESULT WINAPI
xmlwriter_WriteName(IXmlWriter
*iface
, LPCWSTR pwszName
)
213 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
215 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszName
));
220 static HRESULT WINAPI
xmlwriter_WriteNmToken(IXmlWriter
*iface
, LPCWSTR pwszNmToken
)
222 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
224 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszNmToken
));
229 static HRESULT WINAPI
xmlwriter_WriteNode(IXmlWriter
*iface
, IXmlReader
*pReader
,
230 BOOL fWriteDefaultAttributes
)
232 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
234 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
239 static HRESULT WINAPI
xmlwriter_WriteNodeShallow(IXmlWriter
*iface
, IXmlReader
*pReader
,
240 BOOL fWriteDefaultAttributes
)
242 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
244 FIXME("%p %p %d\n", This
, pReader
, fWriteDefaultAttributes
);
249 static HRESULT WINAPI
xmlwriter_WriteProcessingInstruction(IXmlWriter
*iface
, LPCWSTR pwszName
,
252 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
254 FIXME("%p %s %s\n", This
, wine_dbgstr_w(pwszName
), wine_dbgstr_w(pwszText
));
259 static HRESULT WINAPI
xmlwriter_WriteQualifiedName(IXmlWriter
*iface
, LPCWSTR pwszLocalName
,
260 LPCWSTR pwszNamespaceUri
)
262 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
264 FIXME("%p %s %s\n", This
, wine_dbgstr_w(pwszLocalName
), wine_dbgstr_w(pwszNamespaceUri
));
269 static HRESULT WINAPI
xmlwriter_WriteRaw(IXmlWriter
*iface
, LPCWSTR pwszData
)
271 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
273 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszData
));
278 static HRESULT WINAPI
xmlwriter_WriteRawChars(IXmlWriter
*iface
, const WCHAR
*pwch
, UINT cwch
)
280 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
282 FIXME("%p %s %d\n", This
, wine_dbgstr_w(pwch
), cwch
);
287 static HRESULT WINAPI
xmlwriter_WriteStartDocument(IXmlWriter
*iface
, XmlStandalone standalone
)
289 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
296 static HRESULT WINAPI
xmlwriter_WriteStartElement(IXmlWriter
*iface
, LPCWSTR pwszPrefix
,
297 LPCWSTR pwszLocalName
, LPCWSTR pwszNamespaceUri
)
299 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
301 FIXME("%p %s %s %s\n", This
, wine_dbgstr_w(pwszPrefix
), wine_dbgstr_w(pwszLocalName
),
302 wine_dbgstr_w(pwszNamespaceUri
));
307 static HRESULT WINAPI
xmlwriter_WriteString(IXmlWriter
*iface
, LPCWSTR pwszText
)
309 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
311 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszText
));
316 static HRESULT WINAPI
xmlwriter_WriteSurrogateCharEntity(IXmlWriter
*iface
, WCHAR wchLow
, WCHAR wchHigh
)
318 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
320 FIXME("%p %d %d\n", This
, wchLow
, wchHigh
);
325 static HRESULT WINAPI
xmlwriter_WriteWhitespace(IXmlWriter
*iface
, LPCWSTR pwszWhitespace
)
327 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
329 FIXME("%p %s\n", This
, wine_dbgstr_w(pwszWhitespace
));
334 static HRESULT WINAPI
xmlwriter_Flush(IXmlWriter
*iface
)
336 xmlwriter
*This
= impl_from_IXmlWriter(iface
);
343 static const struct IXmlWriterVtbl xmlwriter_vtbl
=
345 xmlwriter_QueryInterface
,
349 xmlwriter_GetProperty
,
350 xmlwriter_SetProperty
,
351 xmlwriter_WriteAttributes
,
352 xmlwriter_WriteAttributeString
,
353 xmlwriter_WriteCData
,
354 xmlwriter_WriteCharEntity
,
355 xmlwriter_WriteChars
,
356 xmlwriter_WriteComment
,
357 xmlwriter_WriteDocType
,
358 xmlwriter_WriteElementString
,
359 xmlwriter_WriteEndDocument
,
360 xmlwriter_WriteEndElement
,
361 xmlwriter_WriteEntityRef
,
362 xmlwriter_WriteFullEndElement
,
364 xmlwriter_WriteNmToken
,
366 xmlwriter_WriteNodeShallow
,
367 xmlwriter_WriteProcessingInstruction
,
368 xmlwriter_WriteQualifiedName
,
370 xmlwriter_WriteRawChars
,
371 xmlwriter_WriteStartDocument
,
372 xmlwriter_WriteStartElement
,
373 xmlwriter_WriteString
,
374 xmlwriter_WriteSurrogateCharEntity
,
375 xmlwriter_WriteWhitespace
,
379 HRESULT WINAPI
CreateXmlWriter(REFIID riid
, void **pObject
, IMalloc
*pMalloc
)
383 TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid
), pObject
, pMalloc
);
385 if (pMalloc
) FIXME("custom IMalloc not supported yet\n");
387 if (!IsEqualGUID(riid
, &IID_IXmlWriter
))
389 ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid
));
393 writer
= HeapAlloc(GetProcessHeap(), 0, sizeof (*writer
));
394 if(!writer
) return E_OUTOFMEMORY
;
396 writer
->IXmlWriter_iface
.lpVtbl
= &xmlwriter_vtbl
;
399 *pObject
= &writer
->IXmlWriter_iface
;
401 TRACE("returning iface %p\n", *pObject
);