xmlccf.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:6k
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: RCSL 1.0
- *
- * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
- *
- * The contents of this file, and the files included with this file, are
- * subject to the current version of RealNetworks Community Source License
- * Version 1.0 (the "License"). You may not use this file except in
- * compliance with the License executed by both you and RealNetworks. You
- * may obtain a copy of the License at
- * http://www.helixcommunity.org/content/rcsl. You may also obtain a
- * copy of the License by contacting RealNetworks directly. Please see the
- * License for the rights, obligations and limitations governing use of the
- * contents of the file.
- *
- * This file is part of the Helix DNA Technology. RealNetworks is the
- * developer of the Original Code and owns the copyrights in the portions
- * it created.
- *
- * This file, and the files included with this file, is distributed and made
- * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- *
- * Technology Compatibility Kit Test Suite(s) Location:
- * http://www.helixcommunity.org/content/tck
- *
- * Contributor(s):
- *
- * ***** END LICENSE BLOCK ***** */
- // $Id: xmlccf.cpp,v 1.5 2003/09/03 15:41:41 ehyche Exp $
- /****************************************************************************
- * hxxml plugin
- */
- #define INITGUID 1
- #include "hxcom.h"
- #include "hxtypes.h"
- #include "ihxpckts.h"
- #include "hxplugn.h"
- #include "hxcomm.h"
- #include "hxxml.h"
- #include "hxver.h"
- #include "hxerror.h"
- #include "hxassert.h"
- #include "hxperf.h"
- #undef INITGUID
- #ifdef _DEBUG
- #undef HX_THIS_FILE
- static const char HX_THIS_FILE[] = __FILE__;
- #endif
- #include "xmlparse.h"
- #include "expatprs.h"
- #include "xmlccf.h"
- #include "hxxml.ver"
- #if !defined(_SYMBIAN)
- HX_ENABLE_CHECKPOINTS_FOR_MODULE( "Rnxmllib", "RnxmllibPerf.log" )
- #endif
- /****************************************************************************
- *
- * Function:
- *
- * HXCreateInstance()
- *
- * Purpose:
- *
- * Function implemented by all plugin DLL's to create an instance of
- * any of the objects supported by the DLL. This method is similar to
- * Window's CoCreateInstance() in its purpose, except that it only
- * creates objects from this plugin DLL.
- *
- * NOTE: Aggregation is never used. Therefore and outer unknown is
- * not passed to this function, and you do not need to code for this
- * situation.
- *
- */
- STDAPI ENTRYPOINT(HXCREATEINSTANCE)(IUnknown** /*OUT*/ ppIUnknown)
- {
- *ppIUnknown = (IUnknown*)(IHXPlugin*)new HXXMLCCFPlugin();
- if (*ppIUnknown)
- {
- (*ppIUnknown)->AddRef();
- return HXR_OK;
- }
- return HXR_OUTOFMEMORY;
- }
- /****************************************************************************
- *
- * Function:
- *
- * CanUnload2()
- *
- * Purpose:
- *
- * Function implemented by all plugin DLL's. If it returns HXR_OK,
- * then the pluginhandler can unload the DLL.
- *
- */
- STDAPI ENTRYPOINT(CanUnload2)(void)
- {
- return (CHXBaseCountingObject::ObjectsActive() > 0 ? HXR_FAIL : HXR_OK );
- }
- /****************************************************************************
- *
- * Function:
- *
- * CanUnload()
- *
- * Purpose:
- *
- * Function implemented by all plugin DLL's if it returns HXR_OK
- * then the pluginhandler can unload the DLL
- *
- */
- STDAPI ENTRYPOINT(CanUnload)(void)
- {
- return ENTRYPOINT(CanUnload2)();
- }
- HXXMLCCFPlugin::HXXMLCCFPlugin()
- : m_lRefCount(0)
- , m_pContext(NULL)
- , m_pClassFactory(NULL)
- {
- }
- HXXMLCCFPlugin::~HXXMLCCFPlugin()
- {
- HX_RELEASE(m_pContext);
- HX_RELEASE(m_pClassFactory);
- }
- /************************************************************************
- * IUnknown COM Interface Methods ref: hxcom.h
- */
- STDMETHODIMP
- HXXMLCCFPlugin::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = (IHXPlugin*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXPlugin))
- {
- AddRef();
- *ppvObj = (IHXPlugin*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXCommonClassFactory))
- {
- AddRef();
- *ppvObj = (IHXCommonClassFactory*)this;
- return HXR_OK;
- }
- *ppvObj = 0;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(UINT32)
- HXXMLCCFPlugin::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(UINT32)
- HXXMLCCFPlugin::Release()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- /************************************************************************
- * IHXPlugin Interface Methods ref: hxplugn.h
- */
- STDMETHODIMP
- HXXMLCCFPlugin::GetPluginInfo(
- REF(BOOL) bLoadMultiple,
- REF(const char*) pDescription,
- REF(const char*) pCopyright,
- REF(const char*) pMoreInfoURL,
- REF(UINT32) versionNumber
- )
- {
- bLoadMultiple = TRUE;
- pDescription = "RealNetworks XML Parser Plugin";
- pCopyright = HXVER_COPYRIGHT;
- pMoreInfoURL = HXVER_MOREINFO;
- versionNumber = TARVER_ULONG32_VERSION;
- return HXR_OK;
- }
- STDMETHODIMP
- HXXMLCCFPlugin::InitPlugin(IUnknown* pHXCore)
- {
- HX_RELEASE(m_pContext);
- m_pContext = pHXCore;
- m_pContext->AddRef();
- return HXR_OK;
- }
- /* IHXCommonClassFactory */
- STDMETHODIMP
- HXXMLCCFPlugin::CreateInstance( REFCLSID /*IN*/ rclsid,
- void** /*OUT*/ ppUnknown)
- {
- if (IsEqualCLSID(rclsid, CLSID_IHXXMLParser))
- {
- *ppUnknown = (IUnknown*)(IHXXMLParser*)(new HXExpatXMLParser(m_pContext));
- ((IUnknown*)*ppUnknown)->AddRef();
- return HXR_OK;
- }
- *ppUnknown = NULL;
- return HXR_NOINTERFACE;
- }
-
- STDMETHODIMP
- HXXMLCCFPlugin::CreateInstanceAggregatable(
- REFCLSID /*IN*/ rclsid,
- REF(IUnknown*) /*OUT*/ ppUnknown,
- IUnknown* /*IN*/ pUnkOuter)
- {
- return HXR_NOINTERFACE;
- }