Liquid XML Data Binder 2020
In This Topic
    AlbumTypeCol.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: MusicStore.xsd
     **********************************************************************************************/
    #include "StdAfx.h" 
    #pragma warning( disable : 4786 ) 
    #pragma warning( disable : 4251 ) 
    #include "../MusicStoreLib.h" 
    #include "../MusicStoreLib/AlbumTypeCol.h" 
    #include "../MusicStoreLib/AlbumType.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 MusicStoreLib
    {
    
    /*
     * 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.
     */
    CAlbumTypeCol::CAlbumTypeCol(LPCTSTR lpctElementName, LPCTSTR lpctNamespaceUri, int minOccurs, int maxOccurs)
     : CXmlCollectionCommonBase(lpctElementName, lpctNamespaceUri, minOccurs, maxOccurs), CInstanceMonitor(_T("CAlbumTypeCol"))
    {
    }
    
    /*
     * Adds a MusicStoreLib::CAlbumType to the collection
     */
    void CAlbumTypeCol::Add(MusicStoreLib::CAlbumType* pCls)
    {
        SetElementName(pCls, m_elementName.c_str());
        AppendItem(pCls);
    }
    
    void CAlbumTypeCol::AddAt(int index, MusicStoreLib::CAlbumType* pCls)
    {
        SetElementName(pCls, m_elementName.c_str());
        AddItemAt(index, pCls);
    }
    
    /*
     *  Create a new MusicStoreLib::CAlbumType object and adds it the collection
     */
    MusicStoreLib::CAlbumTypePtr CAlbumTypeCol::Add()
    {
        CSmartPtr<LtXmlLib18::CXmlObjectBase> spCls = MusicStoreLib::CClassFactory::CreateClass(MusicStoreLib::CClassFactory::ClsName_CAlbumType, m_elementName.c_str());
        AppendItem(spCls);
        return dynamic_cast<MusicStoreLib::CAlbumType*>(spCls.Ptr());
    }
    
    /*
     * Gets a CAlbumType object from the collection (0 based)
     */
    CSmartPtr<MusicStoreLib::CAlbumType> CAlbumTypeCol::Item(int index) const
    {   
        return dynamic_cast<MusicStoreLib::CAlbumType*>(GetNodeAtIndex(index)->spObj.Ptr());
    }
    
    /*
     *  Removes the object from the collection
     */
    void CAlbumTypeCol::Remove(MusicStoreLib::CAlbumType* pCls)
    {
        RemoveNode(GetNodeForItem(pCls));
    }
    
    /*
     * Gets a representation of the class as XML - Marshalls Objects to XML
     */
    void CAlbumTypeCol::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* CAlbumTypeCol::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 = MusicStoreLib::CClassFactory::CreateClass(MusicStoreLib::CClassFactory::ClsName_CAlbumType, 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;
    }
    
    CAlbumTypeCol::iterator CAlbumTypeCol::begin()
    {
        return m_pHead;
    }
    CAlbumTypeCol::iterator CAlbumTypeCol::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