2 * XML Parser 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
24 #include "xmlparser.h"
26 typedef struct _xmlparser
28 IXMLParser IXMLParser_iface
;
29 IXMLNodeFactory
*nodefactory
;
36 static inline xmlparser
*impl_from_IXMLParser( IXMLParser
*iface
)
38 return CONTAINING_RECORD(iface
, xmlparser
, IXMLParser_iface
);
41 /*** IUnknown methods ***/
42 static HRESULT WINAPI
xmlparser_QueryInterface(IXMLParser
* iface
, REFIID riid
, void **ppvObject
)
44 xmlparser
*This
= impl_from_IXMLParser( iface
);
45 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
47 if ( IsEqualGUID( riid
, &IID_IXMLParser
) ||
48 IsEqualGUID( riid
, &IID_IXMLNodeSource
) ||
49 IsEqualGUID( riid
, &IID_IUnknown
) )
55 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
60 IXMLParser_AddRef(iface
);
64 static ULONG WINAPI
xmlparser_AddRef(IXMLParser
* iface
)
66 xmlparser
*This
= impl_from_IXMLParser( iface
);
67 ULONG ref
= InterlockedIncrement( &This
->ref
);
68 TRACE("(%p)->(%d)\n", This
, ref
);
72 static ULONG WINAPI
xmlparser_Release(IXMLParser
* iface
)
74 xmlparser
*This
= impl_from_IXMLParser( iface
);
75 ULONG ref
= InterlockedDecrement( &This
->ref
);
77 TRACE("(%p)->(%d)\n", This
, ref
);
81 IUnknown_Release(This
->input
);
84 IXMLNodeFactory_Release(This
->nodefactory
);
92 /*** IXMLNodeSource methods ***/
93 static HRESULT WINAPI
xmlparser_SetFactory(IXMLParser
*iface
, IXMLNodeFactory
*pNodeFactory
)
95 xmlparser
*This
= impl_from_IXMLParser( iface
);
97 TRACE("(%p %p)\n", This
, pNodeFactory
);
100 IXMLNodeFactory_Release(This
->nodefactory
);
102 This
->nodefactory
= pNodeFactory
;
103 if(This
->nodefactory
)
104 IXMLNodeFactory_AddRef(This
->nodefactory
);
109 static HRESULT WINAPI
xmlparser_GetFactory(IXMLParser
*iface
, IXMLNodeFactory
**ppNodeFactory
)
111 xmlparser
*This
= impl_from_IXMLParser( iface
);
113 TRACE("(%p, %p)\n", This
, ppNodeFactory
);
118 *ppNodeFactory
= This
->nodefactory
;
121 IXMLNodeFactory_AddRef(*ppNodeFactory
);
126 static HRESULT WINAPI
xmlparser_Abort(IXMLParser
*iface
, BSTR bstrErrorInfo
)
128 xmlparser
*This
= impl_from_IXMLParser( iface
);
130 FIXME("(%p, %s)\n", This
, debugstr_w(bstrErrorInfo
));
135 static ULONG WINAPI
xmlparser_GetLineNumber(IXMLParser
*iface
)
137 xmlparser
*This
= impl_from_IXMLParser( iface
);
139 FIXME("(%p)\n", This
);
144 static ULONG WINAPI
xmlparser_GetLinePosition(IXMLParser
*iface
)
146 xmlparser
*This
= impl_from_IXMLParser( iface
);
148 FIXME("(%p)\n", This
);
153 static ULONG WINAPI
xmlparser_GetAbsolutePosition(IXMLParser
*iface
)
155 xmlparser
*This
= impl_from_IXMLParser( iface
);
157 FIXME("(%p)\n", This
);
162 static HRESULT WINAPI
xmlparser_GetLineBuffer(IXMLParser
*iface
, const WCHAR
**ppBuf
,
163 ULONG
*len
, ULONG
*startPos
)
165 xmlparser
*This
= impl_from_IXMLParser( iface
);
167 FIXME("(%p %p %p %p)\n", This
, ppBuf
, len
, startPos
);
172 static HRESULT WINAPI
xmlparser_GetLastError(IXMLParser
*iface
)
174 xmlparser
*This
= impl_from_IXMLParser( iface
);
176 FIXME("(%p)\n", This
);
181 static HRESULT WINAPI
xmlparser_GetErrorInfo(IXMLParser
*iface
, BSTR
*pErrorInfo
)
183 xmlparser
*This
= impl_from_IXMLParser( iface
);
185 FIXME("(%p %p)\n", This
, pErrorInfo
);
190 static ULONG WINAPI
xmlparser_GetFlags(IXMLParser
*iface
)
192 xmlparser
*This
= impl_from_IXMLParser( iface
);
194 TRACE("(%p)\n", This
);
199 static HRESULT WINAPI
xmlparser_GetURL(IXMLParser
*iface
, const WCHAR
**ppBuf
)
201 xmlparser
*This
= impl_from_IXMLParser( iface
);
203 FIXME("(%p %p)\n", This
, ppBuf
);
208 /*** IXMLParser methods ***/
209 static HRESULT WINAPI
xmlparser_SetURL(IXMLParser
*iface
,const WCHAR
*pszBaseUrl
,
210 const WCHAR
*relativeUrl
, BOOL async
)
212 xmlparser
*This
= impl_from_IXMLParser( iface
);
214 FIXME("(%p %s %s %d)\n", This
, debugstr_w(pszBaseUrl
), debugstr_w(relativeUrl
), async
);
219 static HRESULT WINAPI
xmlparser_Load(IXMLParser
*iface
, BOOL bFullyAvailable
,
220 IMoniker
*pMon
, LPBC pBC
, DWORD dwMode
)
222 xmlparser
*This
= impl_from_IXMLParser( iface
);
224 FIXME("(%p %d %p %p %d)\n", This
, bFullyAvailable
, pMon
, pBC
, dwMode
);
229 static HRESULT WINAPI
xmlparser_SetInput(IXMLParser
*iface
, IUnknown
*pStm
)
231 xmlparser
*This
= impl_from_IXMLParser( iface
);
233 TRACE("(%p %p)\n", This
, pStm
);
239 IUnknown_Release(This
->input
);
242 IUnknown_AddRef(This
->input
);
247 static HRESULT WINAPI
xmlparser_PushData(IXMLParser
*iface
, const char *pData
,
248 ULONG nChars
, BOOL fLastBuffer
)
250 xmlparser
*This
= impl_from_IXMLParser( iface
);
252 FIXME("(%p %s %d %d)\n", This
, debugstr_a(pData
), nChars
, fLastBuffer
);
257 static HRESULT WINAPI
xmlparser_LoadDTD(IXMLParser
*iface
, const WCHAR
*baseUrl
,
258 const WCHAR
*relativeUrl
)
260 xmlparser
*This
= impl_from_IXMLParser( iface
);
262 FIXME("(%p %s %s)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
));
267 static HRESULT WINAPI
xmlparser_LoadEntity(IXMLParser
*iface
, const WCHAR
*baseUrl
,
268 const WCHAR
*relativeUrl
, BOOL fpe
)
270 xmlparser
*This
= impl_from_IXMLParser( iface
);
272 FIXME("(%p %s %s %d)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
), fpe
);
277 static HRESULT WINAPI
xmlparser_ParseEntity(IXMLParser
*iface
, const WCHAR
*text
,
280 xmlparser
*This
= impl_from_IXMLParser( iface
);
282 FIXME("(%p %s %d %d)\n", This
, debugstr_w(text
), len
, fpe
);
287 static HRESULT WINAPI
xmlparser_ExpandEntity(IXMLParser
*iface
, const WCHAR
*text
,
290 xmlparser
*This
= impl_from_IXMLParser( iface
);
292 FIXME("(%p %s %d)\n", This
, debugstr_w(text
), len
);
297 static HRESULT WINAPI
xmlparser_SetRoot(IXMLParser
*iface
, PVOID pRoot
)
299 xmlparser
*This
= impl_from_IXMLParser( iface
);
301 FIXME("(%p %p)\n", This
, pRoot
);
306 static HRESULT WINAPI
xmlparser_GetRoot( IXMLParser
*iface
, PVOID
*ppRoot
)
308 xmlparser
*This
= impl_from_IXMLParser( iface
);
310 FIXME("(%p %p)\n", This
, ppRoot
);
315 static HRESULT WINAPI
xmlparser_Run(IXMLParser
*iface
, LONG chars
)
317 xmlparser
*This
= impl_from_IXMLParser( iface
);
319 FIXME("(%p %d)\n", This
, chars
);
324 static HRESULT WINAPI
xmlparser_GetParserState(IXMLParser
*iface
)
326 xmlparser
*This
= impl_from_IXMLParser( iface
);
328 FIXME("(%p)\n", This
);
333 static HRESULT WINAPI
xmlparser_Suspend(IXMLParser
*iface
)
335 xmlparser
*This
= impl_from_IXMLParser( iface
);
337 FIXME("(%p)\n", This
);
342 static HRESULT WINAPI
xmlparser_Reset(IXMLParser
*iface
)
344 xmlparser
*This
= impl_from_IXMLParser( iface
);
346 FIXME("(%p)\n", This
);
351 static HRESULT WINAPI
xmlparser_SetFlags(IXMLParser
*iface
, ULONG flags
)
353 xmlparser
*This
= impl_from_IXMLParser( iface
);
355 TRACE("(%p %d)\n", This
, flags
);
362 static HRESULT WINAPI
xmlparser_SetSecureBaseURL(IXMLParser
*iface
, const WCHAR
*baseUrl
)
364 xmlparser
*This
= impl_from_IXMLParser( iface
);
366 FIXME("(%p %s)\n", This
, debugstr_w(baseUrl
));
371 static HRESULT WINAPI
xmlparser_GetSecureBaseURL( IXMLParser
*iface
, const WCHAR
**ppBuf
)
373 xmlparser
*This
= impl_from_IXMLParser( iface
);
375 FIXME("(%p %p)\n", This
, ppBuf
);
381 static const struct IXMLParserVtbl xmlparser_vtbl
=
383 xmlparser_QueryInterface
,
386 xmlparser_SetFactory
,
387 xmlparser_GetFactory
,
389 xmlparser_GetLineNumber
,
390 xmlparser_GetLinePosition
,
391 xmlparser_GetAbsolutePosition
,
392 xmlparser_GetLineBuffer
,
393 xmlparser_GetLastError
,
394 xmlparser_GetErrorInfo
,
402 xmlparser_LoadEntity
,
403 xmlparser_ParseEntity
,
404 xmlparser_ExpandEntity
,
408 xmlparser_GetParserState
,
412 xmlparser_SetSecureBaseURL
,
413 xmlparser_GetSecureBaseURL
416 HRESULT
XMLParser_create(IUnknown
* pUnkOuter
, void**ppObj
)
420 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
423 FIXME("support aggregation, outer\n");
425 This
= heap_alloc( sizeof(xmlparser
) );
427 return E_OUTOFMEMORY
;
429 This
->IXMLParser_iface
.lpVtbl
= &xmlparser_vtbl
;
430 This
->nodefactory
= NULL
;
435 *ppObj
= &This
->IXMLParser_iface
;
437 TRACE("returning iface %p\n", *ppObj
);