Liquid XML Data Binder 2020
In This Topic
    VouchersCol.cpp
    In This Topic
    /**********************************************************************************************
     * Copyright (c) 2001-2020 Liquid Technologies Limited. All rights reserved.
     * See www.liquid-technologies.com for product details.
     *
     * Please see products End User License Agreement for distribution permissions.
     *
     * WARNING: THIS FILE IS GENERATED
     * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten
     *
     * Generation  :  by Liquid XML Data Binder 17.0.1.9233
     * Using Schema: SimpleHierarchy.xsd
     **********************************************************************************************/
    #include "StdAfx.h" 
    #pragma warning( disable : 4786 ) 
    #pragma warning( disable : 4251 ) 
    #include "../SimpleHierarchyLib.h" 
    #include "../SimpleHierarchyLib/VouchersCol.h" 
    #include "../SimpleHierarchyLib/Vouchers.h" 
    
    // ##HAND_CODED_BLOCK_START ID="Additional Includes"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
    // Add Additional Includes here...
    
    // ##HAND_CODED_BLOCK_END ID="Additional Includes"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
    namespace SimpleHierarchyLib
    {
    
    /*
     * we don't want the users just creating these. They need to 
     * be initialize with the name of the element that they are
     * going to represent in the XML document. This information
     * requires knowledge of the schema, we are trying to 
     * prevent the user from having to know anything about that.
     */
    CVouchersCol::CVouchersCol(LPCTSTR lpctElementName, LPCTSTR lpctNamespaceUri, int minOccurs, int maxOccurs)
     : CXmlCollectionCommonBase(lpctElementName, lpctNamespaceUri, minOccurs, maxOccurs), CInstanceMonitor(_T("CVouchersCol"))
    {
    }
    
    /*
     * Adds a SimpleHierarchyLib::CVouchers to the collection
     */
    void CVouchersCol::Add(SimpleHierarchyLib::CVouchers* pCls)
    {
        SetElementName(pCls, m_elementName.c_str());
        AppendItem(pCls);
    }
    
    void CVouchersCol::AddAt(int index, SimpleHierarchyLib::CVouchers* pCls)
    {
        SetElementName(pCls, m_elementName.c_str());
        AddItemAt(index, pCls);
    }
    
    /*
     *  Create a new SimpleHierarchyLib::CVouchers object and adds it the collection
     */
    SimpleHierarchyLib::CVouchersPtr CVouchersCol::Add()
    {
        CSmartPtr<LtXmlLib18::CXmlObjectBase> spCls = SimpleHierarchyLib::CClassFactory::CreateClass(SimpleHierarchyLib::CClassFactory::ClsName_CVouchers, m_elementName.c_str());
        AppendItem(spCls);
        return dynamic_cast<SimpleHierarchyLib::CVouchers*>(spCls.Ptr());
    }
    
    /*
     * Gets a CVouchers object from the collection (0 based)
     */
    CSmartPtr<SimpleHierarchyLib::CVouchers> CVouchersCol::Item(int index) const
    {   
        return dynamic_cast<SimpleHierarchyLib::CVouchers*>(GetNodeAtIndex(index)->spObj.Ptr());
    }
    
    /*
     *  Removes the object from the collection
     */
    void CVouchersCol::Remove(SimpleHierarchyLib::CVouchers* pCls)
    {
        RemoveNode(GetNodeForItem(pCls));
    }
    
    /*
     * Gets a representation of the class as XML - Marshalls Objects to XML
     */
    void CVouchersCol::ToXml_Int(LtXmlLib18::CXmlWriter* xmlOut, bool bRegisterNamespaces, LPCTSTR lpctNamespaceUri, const LtXmlLib18::CSerializationContext& context, bool isOptionalChoice) const
    {
        ValidateCount(context);
        LtXmlLib18::CNode* pNode = m_pHead;
        while(pNode != NULL)
        {
            LtXmlLib18::CXmlObjectBase::ToXml_Int((pNode->spObj)->GetBase(), xmlOut, false, lpctNamespaceUri, context, isOptionalChoice);
            pNode = pNode->pNext;
        }
    }
    
    /*
     * Creates the collection from XML data - Unmarshalls XML to Objects
     */
    LtXmlLib18::CXmlElement* CVouchersCol::FromXml_Int(LtXmlLib18::CXmlElement* pXmlParent, LtXmlLib18::CXmlElement* pXmlChild, const LtXmlLib18::CSerializationContext& context, bool isOptionalChoice)
    {
        // go through the nodes until we run out of ones that match
        while (pXmlChild != NULL)
        {
            // Stop reading when we hit an element we cant deal with
            if (!DoesElementNameMatch(context, pXmlChild, m_elementName.c_str(), GetNamespace().c_str()))
                break;
            CSmartPtr<LtXmlLib18::CXmlObjectBase> spObj = SimpleHierarchyLib::CClassFactory::CreateClass(SimpleHierarchyLib::CClassFactory::ClsName_CVouchers, m_elementName.c_str());
            LtXmlLib18::CXmlObjectBase::FromXml_Int(spObj->GetBase(), pXmlChild, pXmlChild->GetFirstElement(), context);
    
            // Add new item to the collection
            AppendItem(spObj.Ptr());
        
            // Move to next node
            pXmlChild = pXmlChild->GetNextSiblingElement();
        }
        
        return pXmlChild;
    }
    
    CVouchersCol::iterator CVouchersCol::begin()
    {
        return m_pHead;
    }
    CVouchersCol::iterator CVouchersCol::end()
    {
        return NULL;
    }
    
    // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
    // Add Additional Methods here...
    
    // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
    }; // namespace