⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldatarecordparser.h

📁 一个WinCE6。0下的IP phone的源代码
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#ifndef _XMLENTITYPARSER_H_20386833_ // To prevent multiple #includes
#define _XMLENTITYPARSER_H_20386833_

#include <windows.h>
#include "string.hxx"
#include "vector.hxx"
#include "msxml2.h"
#include "DataRecord.h"

#define MAX_DATARECORD_PROPERTIES 7

class CXMLDataRecordParser : 
    public ISAXContentHandler
{
public:
    //constructor-destructor
    CXMLDataRecordParser();
    virtual ~CXMLDataRecordParser();

public:
    //public interface

    //this keyword indicates that a new datarecord will be created when found
    HRESULT     SetNewDataRecordKeyword     (const WCHAR *c_wszNewDataRecord);

    //this property will be stored in the current datarecord at the specified index
    HRESULT     SetDataRecordPropertyKeyword(INT idxProperty, const WCHAR *c_wszProperty);

    //parse an XML string and put the results in the datarecord list
    HRESULT     Parse(BSTR bstrXML, RefCountedDataRecordList  *pDataRecordList);

    HRESULT     ClearMapping();
    
public:    
    //IUnknown implementation
    
    //Not a real COM object - fake addref and release
    virtual  ULONG   STDMETHODCALLTYPE   AddRef();  
    virtual  ULONG   STDMETHODCALLTYPE   Release(); 
    
    virtual  HRESULT STDMETHODCALLTYPE   QueryInterface(
        REFIID refiid, 
        VOID** ppvObject
        );
    
public:
    //ISAXContentHandler implementation

    //Actually implemented in .cpp
    virtual HRESULT STDMETHODCALLTYPE   characters(
        const WCHAR *pwchChars         ,
        INT          cchChars
        );

    virtual HRESULT STDMETHODCALLTYPE   startElement(
        const WCHAR *pwchNamespaceUri  , 
        INT          cchNamespaceUri   , 
        const WCHAR *pwchLocalName     , 
        INT          cchLocalName      ,
        const WCHAR *pwchQName         ,
        INT          cchQName          ,
        ISAXAttributes* pAttributes
        );

    virtual HRESULT STDMETHODCALLTYPE   endElement(
        const WCHAR *pwchNamespaceURI  ,
        INT          cchNamespaceURI   ,
        const WCHAR *pwchLocalName     ,
        INT          cchLocalName      ,
        const WCHAR *pwchQName         ,
        INT          cchQName
        );
    
public:
    //do nothing - return S_OK

    virtual HRESULT STDMETHODCALLTYPE   endDocument() 
    { 
        return S_OK; 
    }

    virtual HRESULT STDMETHODCALLTYPE   startDocument()
    {
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE   ignorableWhitespace(
        const WCHAR *pwchChars         ,
        INT          cchChars
        )
    {
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE   endPrefixMapping(
        const WCHAR *pwchPrefix        ,
        INT          cchPrefix
        )
    {
        return S_OK;
    }
        

    virtual HRESULT STDMETHODCALLTYPE   startPrefixMapping(
        const WCHAR *pwchPrefix        ,
        INT          cchPrefix         ,
        const WCHAR *pwchURI           ,
        INT          cchURI
        )
    {
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE   processingInstruction(
        const WCHAR *pwchTarget        ,
        INT          cchTarget         ,
        const WCHAR *pwchData          ,
        INT          cchData
        )
    {
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE   putDocumentLocator(
        ISAXLocator *piLocator
        )
    {
        return S_OK;
    }

    virtual HRESULT STDMETHODCALLTYPE   skippedEntity(
        const WCHAR *pwchName,
        INT          cchName
        )
    {
        return S_OK;
    }

private:
    //private functions
    HRESULT CreateNewDataRecord();
    HRESULT CommitCurrentDataRecord();
    HRESULT AddPropertyToCurrentDataRecord(const WCHAR * pwchProperty, INT cchProperty);
    
private:
    INT                    m_cRefs;
    
    ce::wstring            m_wstrNewDataRecordName;
    ce::wstring            m_wstrPropertyMapping[MAX_DATARECORD_PROPERTIES];

    INT                    m_idxCurrentParsingItem;
    DataRecord                *m_pCurrentDataRecord;
    RefCountedDataRecordList  *m_pDataRecordList;

    ISAXXMLReader *m_piXMLReader;
};

#endif // !defined _XMLENTITYPARSER_H_20386833_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -