In This Topic
#include "StdAfx.h"
#pragma warning( disable : 4786 )
#pragma warning( disable : 4251 )
#include "../MusicStoreLib.h"
#include "../MusicStoreLib/AlbumTypeCol.h"
#include "../MusicStoreLib/AlbumType.h"
namespace MusicStoreLib
{
CAlbumTypeCol::CAlbumTypeCol(LPCTSTR lpctElementName, LPCTSTR lpctNamespaceUri, int minOccurs, int maxOccurs)
: CXmlCollectionCommonBase(lpctElementName, lpctNamespaceUri, minOccurs, maxOccurs), CInstanceMonitor(_T("CAlbumTypeCol"))
{
}
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);
}
MusicStoreLib::CAlbumTypePtr CAlbumTypeCol::Add()
{
CSmartPtr<LtXmlLib20::CXmlObjectBase> spCls = MusicStoreLib::CClassFactory::CreateClass(MusicStoreLib::CClassFactory::ClsName_CAlbumType, m_elementName.c_str());
AppendItem(spCls);
return dynamic_cast<MusicStoreLib::CAlbumType*>(spCls.Ptr());
}
CSmartPtr<MusicStoreLib::CAlbumType> CAlbumTypeCol::Item(int index) const
{
return dynamic_cast<MusicStoreLib::CAlbumType*>(GetNodeAtIndex(index)->spObj.Ptr());
}
void CAlbumTypeCol::Remove(MusicStoreLib::CAlbumType* pCls)
{
RemoveNode(GetNodeForItem(pCls));
}
void CAlbumTypeCol::ToXml_Int(LtXmlLib20::CXmlWriter* xmlOut, bool bRegisterNamespaces, LPCTSTR lpctNamespaceUri, const LtXmlLib20::CSerializationContext& context, bool isOptionalChoice) const
{
ValidateCount(context);
LtXmlLib20::CNode* pNode = m_pHead;
while(pNode != NULL)
{
LtXmlLib20::CXmlObjectBase::ToXml_Int((pNode->spObj)->GetBase(), xmlOut, false, lpctNamespaceUri, context, isOptionalChoice);
pNode = pNode->pNext;
}
}
LtXmlLib20::CXmlElement* CAlbumTypeCol::FromXml_Int(LtXmlLib20::CXmlElement* pXmlParent, LtXmlLib20::CXmlElement* pXmlChild, const LtXmlLib20::CSerializationContext& context, bool isOptionalChoice)
{
// go through the nodes until we run out of ones that match
while (pXmlChild != NULL)
{
if (!DoesElementNameMatch(context, pXmlChild, m_elementName.c_str(), GetNamespace().c_str()))
break;
CSmartPtr<LtXmlLib20::CXmlObjectBase> spObj = MusicStoreLib::CClassFactory::CreateClass(MusicStoreLib::CClassFactory::ClsName_CAlbumType, m_elementName.c_str());
LtXmlLib20::CXmlObjectBase::FromXml_Int(spObj->GetBase(), pXmlChild, pXmlChild->GetFirstElement(), context);
AppendItem(spObj.Ptr());
pXmlChild = pXmlChild->GetNextSiblingElement();
}
return pXmlChild;
}
CAlbumTypeCol::iterator CAlbumTypeCol::begin()
{
return m_pHead;
}
CAlbumTypeCol::iterator CAlbumTypeCol::end()
{
return NULL;
}
};