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

📄 elementstack.cpp

📁 Windows CE 6.0 Server 源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        CElement * pele;

        pele = m_AttributeList.RemoveHead();
        delete pele;
    }
} 


/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStackEntry::Init()
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStackEntry::Init(void)
{
    HRESULT hr;

    CHK(CElement::Init());
    CHK (allocateAndCopy(&m_pcDefaultNamespace, g_pwstrEmpty));
    
Cleanup:
    ASSERT(hr == S_OK);
    return hr;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStackEntry::setDefaultNamespace(const WCHAR *pcText)
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStackEntry::setDefaultNamespace(const WCHAR *pcText)
{
    return  (allocateAndCopy(&m_pcDefaultNamespace, pcText));
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStackEntry::AddAttribute(    WCHAR * prefix, WCHAR * ns, WCHAR * name, WCHAR * value)
//
//  parameters: All information to add an Attribute, prefix, namespace, name 
//                and value
//
//  description:Function adds the information to the element stack, all needed
//                namespace handling operations will happen during the ouput 
//                generation
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStackEntry::AddAttribute(
        WCHAR * prefix, 
        WCHAR * ns, 
        WCHAR * name, 
        WCHAR * value)
{
    HRESULT hr;
    CAutoP<CElement>    pele(NULL);

    pele = new CElement();

    CHK_BOOL (pele != NULL, E_OUTOFMEMORY);

    CHK (pele->Init());
    CHK (pele->setPrefix(prefix));
    CHK (pele->setURI(ns));
    CHK (pele->setName(name));
    CHK (pele->setValue(value));

    m_AttributeList.InsertTail(pele.PvReturn());
    
Cleanup:
    ASSERT(hr == S_OK);
    return hr;
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStackEntry::FixNamespace(CNamespaceHelper * pnsh)
//
//  parameters: Handler to the current namespace context
//
//  description:
//            This functions looks at the current element and makes adjustments
//            to the contained namespace information in this element and all
//            attributes attached to the element.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStackEntry::FixNamespace(CNamespaceHelper * pnsh)
{
    HRESULT     hr = S_OK;
    CElement*    pEle;    

    CHK (CElement::FixNamespace(m_pcDefaultNamespace, pnsh));

    pEle = m_AttributeList.getHead();

    while (pEle)
        {
        CHK(pEle->FixNamespace(NULL, pnsh));
        pEle = m_AttributeList.next(pEle);
        }

Cleanup:
    ASSERT (hr == S_OK);
    return hr;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStackEntry::FlushElement(CSoapSerializer *pSoapSerializer)
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStackEntry::FlushElement(CSoapSerializer *pSoapSerializer)
{
    HRESULT hr = S_OK;
    CElement*    pEle;    
    
    if (m_IsSerialized)
        return S_OK;


    CHK (CElement::FlushElementContents(pSoapSerializer));
    
    pEle = m_AttributeList.RemoveHead();

    while (pEle)
        {
        CHK(pEle->FlushAttributeContents(pSoapSerializer));
        delete pEle;
        pEle = m_AttributeList.RemoveHead();
        }


    setIsSerialized();
    
Cleanup:
    ASSERT (hr == S_OK);
    return hr;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::CElementStack()
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
CElementStack::CElementStack()
{
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::~CElementStack()
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
CElementStack::~CElementStack()
{
    HRESULT hr;

    hr = reset();
    ASSERT (hr == S_OK);
    return;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::reset()
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStack::reset(void)
{
    HRESULT hr = S_OK;

    while (!m_ElementStack.IsEmpty())
    {
        CElementStackEntry    * pele;

        pele = Pop();
        delete pele;
    }
    
    ASSERT (hr == S_OK);
    return hr;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::Push(CElementStackEntry * pele)
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void CElementStack::Push(CElementStackEntry * pele)
{
#ifndef UNDER_CE
    return (m_ElementStack.InsertHead(pele));
#else
    //cant return w/ void
    m_ElementStack.InsertHead(pele);
#endif
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::Pop()
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
CElementStackEntry* CElementStack::Pop(void)
{
    return (m_ElementStack.RemoveHead());
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::Peek()
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
CElementStackEntry* CElementStack::Peek(void) const
{
    return (m_ElementStack.getHead());
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  function: CElementStack::AddAttribute(WCHAR * prefix, WCHAR * ns, WCHAR * name, WCHAR * value)
//
//  parameters: 
//
//
//  description:
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
HRESULT CElementStack::AddAttribute(WCHAR * prefix, WCHAR * ns, WCHAR * name, WCHAR * value)
{
    CElementStackEntry * pele;

    pele = m_ElementStack.getHead();
    if (pele)
        return pele->AddAttribute(prefix, ns, name, value);

    return E_FAIL;
}



// End Of File




⌨️ 快捷键说明

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