#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../CardinalityLib.h"
#include "../CardinalityLib/MyRootObject.h"
namespace CardinalityLib
{
LtXmlLib20Data::CParentElementInfo* CMyRootObject::ms_pParentElementInfo = NULL;
LtXmlLib20Data::CAttributeInfo** CMyRootObject::ms_ppAttributeInfo = NULL;
LtXmlLib20Data::CElementInfo** CMyRootObject::ms_ppElementInfo = NULL;
CMyRootObjectPtr CMyRootObject::CreateInstance(LPCTSTR lpctElementName)
{
return new CardinalityLib::CMyRootObject(lpctElementName);
}
CMyRootObject::CMyRootObject(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CMyRootObject"))
, m_ASimpleDateMandatoryElement(LtXmlLib20::CDateTime::dt_date)
, m_ASimpleDateOptionalElement(LtXmlLib20::CDateTime::dt_date)
{
m_elementName = lpctElementName;
Init();
}
CMyRootObject::~CMyRootObject()
{
Cleanup();
}
void CMyRootObject::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
this->m_ASimpleStringCollectionElement = NULL;
this->m_ASimpleDateCollectionElement = NULL;
this->m_AComplexCollectionElement = NULL;
}
void CMyRootObject::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CMyRootObject::Init()
{
Cleanup();
this->m_ASimpleStringMandatoryElement = _T("");
this->m_ASimpleDateMandatoryElement = LtXmlLib20::CDateTime(LtXmlLib20::CDateTime::dt_date);
this->m_AComplexMandatoryElement = dynamic_cast<CardinalityLib::CAComplexMandatoryElement*>(CardinalityLib::CClassFactory::CreateClass(CardinalityLib::CClassFactory::ClsName_CAComplexMandatoryElement, _T("AComplexMandatoryElement")).Ptr());
this->m_ASimpleStringOptionalElement = _T("");
this->m_IsValidASimpleStringOptionalElement = false;
this->m_ASimpleDateOptionalElement = LtXmlLib20::CDateTime(LtXmlLib20::CDateTime::dt_date);
this->m_IsValidASimpleDateOptionalElement = false;
this->m_AComplexOptionalElement = NULL;
this->m_ASimpleStringCollectionElement = new LtXmlLib20::CstringCol(_T("ASimpleStringCollectionElement"), _T(""), 0, -1, _T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, NULL);
this->m_ASimpleDateCollectionElement = new LtXmlLib20::CdateCol(_T("ASimpleDateCollectionElement"), _T(""), 0, -1, _T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, NULL);
this->m_AComplexCollectionElement = dynamic_cast<CardinalityLib::CAComplexCollectionElementCol*>(CardinalityLib::CClassFactory::CreateClassCollection(CardinalityLib::CClassFactory::ClsName_CAComplexCollectionElementCol, _T("AComplexCollectionElement"), _T(""), 0, -1).Ptr());
}
void CMyRootObject::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
rValue.SetString(GetASimpleStringMandatoryElement());
break;
case 2:
rValue.SetDate(GetASimpleDateMandatoryElement());
break;
case 3:
rValue.SetXmlObject(GetAComplexMandatoryElement().Ptr());
break;
case 4:
if (IsValidASimpleStringOptionalElement())
rValue.SetString(GetASimpleStringOptionalElement());
else
rValue.SetInvalid();
break;
case 5:
if (IsValidASimpleDateOptionalElement())
rValue.SetDate(GetASimpleDateOptionalElement());
else
rValue.SetInvalid();
break;
case 6:
rValue.SetXmlObject(GetAComplexOptionalElement().Ptr());
break;
case 7:
rValue.SetXmlCollection(GetASimpleStringCollectionElement());
break;
case 8:
rValue.SetXmlCollection(GetASimpleDateCollectionElement());
break;
case 9:
rValue.SetXmlCollection(GetAComplexCollectionElement().Ptr());
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
SetASimpleStringMandatoryElement(rValue.GetString());
break;
case 2:
SetASimpleDateMandatoryElement(rValue.GetDate());
break;
case 3:
SetAComplexMandatoryElement(dynamic_cast<CardinalityLib::CAComplexMandatoryElement*>(rValue.GetXmlObject().Ptr()));
break;
case 4:
if (rValue.IsValid())
SetASimpleStringOptionalElement(rValue.GetString());
else
SetValidASimpleStringOptionalElement(false);
break;
case 5:
if (rValue.IsValid())
SetASimpleDateOptionalElement(rValue.GetDate());
else
SetValidASimpleDateOptionalElement(false);
break;
case 6:
SetAComplexOptionalElement(dynamic_cast<CardinalityLib::CAComplexOptionalElement*>(rValue.GetXmlObject().Ptr()));
break;
case 7:
throw LtXmlLib20::CLtException(_T("Collections can not be set"));
break;
case 8:
throw LtXmlLib20::CLtException(_T("Collections can not be set"));
break;
case 9:
throw LtXmlLib20::CLtException(_T("Collections can not be set"));
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
}
}
}
std::tstring CMyRootObject::GetASimpleStringMandatoryElement() const
{
return this->m_ASimpleStringMandatoryElement;
}
void CMyRootObject::SetASimpleStringMandatoryElement(std::tstring value)
{
// Apply whitespace rules appropriately
value = LtXmlLib20::CWhitespaceUtils::Preserve(value);
this->m_ASimpleStringMandatoryElement = value;
}
LtXmlLib20::CDateTime CMyRootObject::GetASimpleDateMandatoryElement() const
{
return this->m_ASimpleDateMandatoryElement;
}
void CMyRootObject::SetASimpleDateMandatoryElement(LtXmlLib20::CDateTime value)
{
this->m_ASimpleDateMandatoryElement.SetDateTime(value, this->m_ASimpleDateMandatoryElement.GetType());
}
CardinalityLib::CAComplexMandatoryElementPtr CMyRootObject::GetAComplexMandatoryElement() const
{
return this->m_AComplexMandatoryElement;
}
void CMyRootObject::SetAComplexMandatoryElement(CardinalityLib::CAComplexMandatoryElement* value)
{
Throw_IfPropertyIsNull(value, _T("AComplexMandatoryElement"));
if (value != NULL)
SetElementName(value, _T("AComplexMandatoryElement"));
this->m_AComplexMandatoryElement = value;
}
std::tstring CMyRootObject::GetASimpleStringOptionalElement() const
{
if (m_IsValidASimpleStringOptionalElement == false)
throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetASimpleStringOptionalElement is not valid. SetASimpleStringOptionalElement must be called first"));
return this->m_ASimpleStringOptionalElement;
}
void CMyRootObject::SetASimpleStringOptionalElement(std::tstring value)
{
// Apply whitespace rules appropriately
value = LtXmlLib20::CWhitespaceUtils::Preserve(value);
this->m_IsValidASimpleStringOptionalElement = true;
this->m_ASimpleStringOptionalElement = value;
}
bool CMyRootObject::IsValidASimpleStringOptionalElement() const
{
return m_IsValidASimpleStringOptionalElement;
}
void CMyRootObject::SetValidASimpleStringOptionalElement(bool value)
{
if (value != m_IsValidASimpleStringOptionalElement)
{
this->m_ASimpleStringOptionalElement = _T("");
m_IsValidASimpleStringOptionalElement = value;
}
}
LtXmlLib20::CDateTime CMyRootObject::GetASimpleDateOptionalElement() const
{
if (m_IsValidASimpleDateOptionalElement == false)
throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetASimpleDateOptionalElement is not valid. SetASimpleDateOptionalElement must be called first"));
return this->m_ASimpleDateOptionalElement;
}
void CMyRootObject::SetASimpleDateOptionalElement(LtXmlLib20::CDateTime value)
{
this->m_IsValidASimpleDateOptionalElement = true;
this->m_ASimpleDateOptionalElement.SetDateTime(value, m_ASimpleDateOptionalElement.GetType());
}
bool CMyRootObject::IsValidASimpleDateOptionalElement() const
{
return m_IsValidASimpleDateOptionalElement;
}
void CMyRootObject::SetValidASimpleDateOptionalElement(bool value)
{
if (value != m_IsValidASimpleDateOptionalElement)
{
this->m_ASimpleDateOptionalElement = LtXmlLib20::CDateTime(LtXmlLib20::CDateTime::dt_date);
m_IsValidASimpleDateOptionalElement = value;
}
}
CardinalityLib::CAComplexOptionalElementPtr CMyRootObject::GetAComplexOptionalElement() const
{
return this->m_AComplexOptionalElement;
}
void CMyRootObject::SetAComplexOptionalElement(CardinalityLib::CAComplexOptionalElement* value)
{
if (value == NULL)
this->m_AComplexOptionalElement = NULL;
else
{
SetElementName(value, _T("AComplexOptionalElement"));
this->m_AComplexOptionalElement = value;
}
}
LtXmlLib20::CstringColPtr CMyRootObject::GetASimpleStringCollectionElement() const
{
return this->m_ASimpleStringCollectionElement;
}
LtXmlLib20::CdateColPtr CMyRootObject::GetASimpleDateCollectionElement() const
{
return this->m_ASimpleDateCollectionElement;
}
CardinalityLib::CAComplexCollectionElementColPtr CMyRootObject::GetAComplexCollectionElement() const
{
return this->m_AComplexCollectionElement;
}
CardinalityLib::CMyRootObjectPtr CMyRootObject::Clone() const
{
CardinalityLib::CMyRootObjectPtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_ASimpleStringMandatoryElement = m_ASimpleStringMandatoryElement;
newObject->m_ASimpleDateMandatoryElement = m_ASimpleDateMandatoryElement;
newObject->m_AComplexMandatoryElement = NULL;
if (m_AComplexMandatoryElement != NULL)
newObject->m_AComplexMandatoryElement = dynamic_cast<CardinalityLib::CAComplexMandatoryElement*>(m_AComplexMandatoryElement->Clone().Ptr());
newObject->m_ASimpleStringOptionalElement = m_ASimpleStringOptionalElement;
newObject->m_IsValidASimpleStringOptionalElement = m_IsValidASimpleStringOptionalElement;
newObject->m_ASimpleDateOptionalElement = m_ASimpleDateOptionalElement;
newObject->m_IsValidASimpleDateOptionalElement = m_IsValidASimpleDateOptionalElement;
newObject->m_AComplexOptionalElement = NULL;
if (m_AComplexOptionalElement != NULL)
newObject->m_AComplexOptionalElement = dynamic_cast<CardinalityLib::CAComplexOptionalElement*>(m_AComplexOptionalElement->Clone().Ptr());
for (index = 0; index < m_ASimpleStringCollectionElement->GetCount(); index++)
newObject->m_ASimpleStringCollectionElement->Add(m_ASimpleStringCollectionElement->Item(index));
for (index = 0; index < m_ASimpleDateCollectionElement->GetCount(); index++)
newObject->m_ASimpleDateCollectionElement->Add(m_ASimpleDateCollectionElement->Item(index));
for (index = 0; index < m_AComplexCollectionElement->GetCount(); index++)
newObject->m_AComplexCollectionElement->Add(dynamic_cast<CardinalityLib::CAComplexCollectionElement*>(m_AComplexCollectionElement->Item(index)->Clone().Ptr()));
return newObject.Ptr();
}
std::tstring CMyRootObject::GetTargetNamespace() const
{
return _T("");
}
std::tstring CMyRootObject::GetNamespace() const
{
return _T("");
}
LtXmlLib20::CXmlObjectBase* CMyRootObject::GetBase()
{
return this;
}
void CMyRootObject::CleanMetaData()
{
LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib20Data::CParentElementInfo* CMyRootObject::GetClassInfo() const
{
if (ms_pParentElementInfo == NULL)
{
m_csInit.Enter();
if (ms_pParentElementInfo == NULL)
{
ms_pParentElementInfo = new LtXmlLib20Data::CParentElementInfo(
LtXmlLib20Data::XmlElementGroupType_SEQUENCE,
LtXmlLib20Data::XmlElementType_ELEMENT,
_T("MyRootObject"),
_T(""),
true,
false,
-1,
LtXmlLib20::ItemType_none,
LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib20Data::CElementInfo** CMyRootObject::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[10];
ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("ASimpleStringMandatoryElement"), _T(""), 1, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("ASimpleDateMandatoryElement"), _T(""), 2, false, LtXmlLib20::ItemType_date, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[2] = new LtXmlLib20Data::CElementInfoSeqClsMnd(_T("AComplexMandatoryElement"), _T(""), 3, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&CardinalityLib::CClassFactory::CreateClass, CardinalityLib::CClassFactory::ClsName_CAComplexMandatoryElement, true);
ms_ppElementInfo[3] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("ASimpleStringOptionalElement"), _T(""), 4, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[4] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("ASimpleDateOptionalElement"), _T(""), 5, false, LtXmlLib20::ItemType_date, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[5] = new LtXmlLib20Data::CElementInfoSeqClsOpt(_T("AComplexOptionalElement"), _T(""), 6, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&CardinalityLib::CClassFactory::CreateClass, CardinalityLib::CClassFactory::ClsName_CAComplexOptionalElement);
ms_ppElementInfo[6] = new LtXmlLib20Data::CElementInfoSeqPrimCol(_T("ASimpleStringCollectionElement"), _T(""), 7);
ms_ppElementInfo[7] = new LtXmlLib20Data::CElementInfoSeqPrimCol(_T("ASimpleDateCollectionElement"), _T(""), 8);
ms_ppElementInfo[8] = new LtXmlLib20Data::CElementInfoSeqClsCol(_T("AComplexCollectionElement"), _T(""), 9, LtXmlLib20Data::XmlElementType_ELEMENT);
ms_ppElementInfo[9] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib20Data::CAttributeInfo** CMyRootObject::GetClassAttributeInfo() const
{
if (ms_ppAttributeInfo == NULL)
{
m_csInit.Enter();
if (ms_ppAttributeInfo == NULL)
{
ms_ppAttributeInfo = new LtXmlLib20Data::CAttributeInfo*[1];
ms_ppAttributeInfo[0] = NULL;
}
m_csInit.Leave();
}
return ms_ppAttributeInfo;
}
};