In This Topic
#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../MusicStoreLib.h"
#include "../MusicStoreLib/Error.h"
namespace MusicStoreLib
{
LtXmlLib20Data::CParentElementInfo* CError::ms_pParentElementInfo = NULL;
LtXmlLib20Data::CAttributeInfo** CError::ms_ppAttributeInfo = NULL;
LtXmlLib20Data::CElementInfo** CError::ms_ppElementInfo = NULL;
CErrorPtr CError::CreateInstance(LPCTSTR lpctElementName)
{
return new MusicStoreLib::CError(lpctElementName);
}
CError::CError(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CError"))
{
m_elementName = lpctElementName;
Init();
}
CError::~CError()
{
Cleanup();
}
void CError::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
}
void CError::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CError::Init()
{
Cleanup();
this->m_ErrorCode = 0;
this->m_ErrorDescription = _T("");
this->m_HelpFile = _T("");
this->m_IsValidHelpFile = false;
}
void CError::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
rValue.SetI4(GetErrorCode());
break;
case 2:
rValue.SetString(GetErrorDescription());
break;
case 3:
if (IsValidHelpFile())
rValue.SetString(GetHelpFile());
else
rValue.SetInvalid();
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
SetErrorCode(rValue.GetI4());
break;
case 2:
SetErrorDescription(rValue.GetString());
break;
case 3:
if (rValue.IsValid())
SetHelpFile(rValue.GetString());
else
SetValidHelpFile(false);
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
}
}
}
LONG CError::GetErrorCode() const
{
return this->m_ErrorCode;
}
void CError::SetErrorCode(LONG value)
{
this->m_ErrorCode = value;
}
std::tstring CError::GetErrorDescription() const
{
return this->m_ErrorDescription;
}
void CError::SetErrorDescription(std::tstring value)
{
// Apply whitespace rules appropriately
value = LtXmlLib20::CWhitespaceUtils::Preserve(value);
this->m_ErrorDescription = value;
}
std::tstring CError::GetHelpFile() const
{
if (m_IsValidHelpFile == false)
throw LtXmlLib20::CLtInvalidStateException(_T("The Property GetHelpFile is not valid. SetHelpFile must be called first"));
return this->m_HelpFile;
}
void CError::SetHelpFile(std::tstring value)
{
// Apply whitespace rules appropriately
value = LtXmlLib20::CWhitespaceUtils::Preserve(value);
this->m_IsValidHelpFile = true;
this->m_HelpFile = value;
}
bool CError::IsValidHelpFile() const
{
return m_IsValidHelpFile;
}
void CError::SetValidHelpFile(bool value)
{
if (value != m_IsValidHelpFile)
{
this->m_HelpFile = _T("");
m_IsValidHelpFile = value;
}
}
MusicStoreLib::CErrorPtr CError::Clone() const
{
MusicStoreLib::CErrorPtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_ErrorCode = m_ErrorCode;
newObject->m_ErrorDescription = m_ErrorDescription;
newObject->m_HelpFile = m_HelpFile;
newObject->m_IsValidHelpFile = m_IsValidHelpFile;
return newObject.Ptr();
}
std::tstring CError::GetTargetNamespace() const
{
return _T("");
}
std::tstring CError::GetNamespace() const
{
return _T("");
}
LtXmlLib20::CXmlObjectBase* CError::GetBase()
{
return this;
}
void CError::CleanMetaData()
{
LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib20Data::CParentElementInfo* CError::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("Error"),
_T(""),
true,
false,
-1,
LtXmlLib20::ItemType_none,
LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib20Data::CElementInfo** CError::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[4];
ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("ErrorCode"), _T(""), 1, false, LtXmlLib20::ItemType_i4, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("ErrorDescription"), _T(""), 2, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[2] = new LtXmlLib20Data::CElementInfoSeqPrimOpt(_T("HelpFile"), _T(""), 3, false, LtXmlLib20::ItemType_string, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Preserve, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[3] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib20Data::CAttributeInfo** CError::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;
}
};