In This Topic
    Invoice.cpp
    In This Topic
    /**********************************************************************************************
     * Copyright (c) 2001-2023 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 19.0.14.11049
     * Using Schema: SimpleHierarchy.xsd
     **********************************************************************************************/
    #include "StdAfx.h" 
    #pragma warning (push) 
    #pragma warning (disable:4251)  // template export warning 
    #pragma warning (disable:4786)  // long debug names 
    #include "../SimpleHierarchyLib.h" 
    #include "../SimpleHierarchyLib/Invoice.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
    
    // Name                    : Invoice
    // Long Name               : Invoice
    // Element Name            : Invoice
    // Class Namespace         : SimpleHierarchyLib
    // Namespace Alias         : 
    // Schema Namespace        : 
    // Mapped Class Name       : CInvoice
    // Mapped Class Full Name  : SimpleHierarchyLib::CInvoice
    // Mapped Class File Name  : CInvoice
    // IsAbstract              : False
    // IsElement               : True
    // IsComplexType           : False
    
    namespace SimpleHierarchyLib
    {
    
    LtXmlLib20Data::CParentElementInfo* CInvoice::ms_pParentElementInfo = NULL;
    LtXmlLib20Data::CAttributeInfo** CInvoice::ms_ppAttributeInfo = NULL;
    LtXmlLib20Data::CElementInfo** CInvoice::ms_ppElementInfo = NULL;
    
    CInvoicePtr CInvoice::CreateInstance(LPCTSTR lpctElementName/*=_T("Invoice")*/)
    {
        return new SimpleHierarchyLib::CInvoice(lpctElementName);
    }
    
    /*  
     * Constructor for CInvoice
     *
     * The class is created with all the mandatory fields populated with the
     * default data.
     * All Collection objects are created.
     * However any 1-n relationships (these are represented as collections) are
     * empty. To comply with the schema these must be populated before the xml
     * obtained from ToXml is valid against the schema SimpleHierarchy.xsd
     */
    CInvoice::CInvoice(LPCTSTR lpctElementName/*=_T("Invoice")*/)
     : CInstanceMonitor(_T("CInvoice"))
    {
        m_elementName = lpctElementName;
        Init();
    }
    
    CInvoice::~CInvoice()
    {
        Cleanup();
    }
    
    void CInvoice::Cleanup()
    {
        // unregister for any events we have asked for
        // cos there'll be no one left to hear soon
        this->m_Item = NULL;
    }
    
    void CInvoice::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
    {
        if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
        {
        }
    }
    
    /*
     * Initializes the class
     *
     * The Creates all the mandatory fields (populated with the default data) 
     * All Collection object are created.
     * However any 1-n relationships (these are represented as collections) are
     * empty. To comply with the schema these must be populated before the xml
     * obtained from ToXml is valid against the schema SimpleHierarchy.xsd.
     */
    void CInvoice::Init()
    {
        Cleanup();
    
        this->m_InvoiceNo = 0;
        this->m_DeliveryAddress = dynamic_cast<SimpleHierarchyLib::CAddressType*>(SimpleHierarchyLib::CClassFactory::CreateClass(SimpleHierarchyLib::CClassFactory::ClsName_CAddressType, _T("DeliveryAddress")).Ptr());
        this->m_BillingAddress = NULL;
        this->m_Item = dynamic_cast<SimpleHierarchyLib::CItemTypeCol*>(SimpleHierarchyLib::CClassFactory::CreateClassCollection(SimpleHierarchyLib::CClassFactory::ClsName_CItemTypeCol, _T("Item"), _T(""), 1, -1).Ptr());
        this->m_Payment = dynamic_cast<SimpleHierarchyLib::CPayment*>(SimpleHierarchyLib::CClassFactory::CreateClass(SimpleHierarchyLib::CClassFactory::ClsName_CPayment, _T("Payment")).Ptr());
        
    
    
    // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
    // Add Additional Init Settings...
    
    // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    }
        
    
    void CInvoice::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
    {
        if (bRead)
        {
            switch(iPropertyIndex)
            {
            case 1:
                    rValue.SetUI4(GetInvoiceNo());
                break;
            case 2:
                    rValue.SetXmlObject(GetDeliveryAddress().Ptr());
                break;
            case 3:
                    rValue.SetXmlObject(GetBillingAddress().Ptr());
                break;
            case 4:
                rValue.SetXmlCollection(GetItem().Ptr());
                break;
            case 5:
                    rValue.SetXmlObject(GetPayment().Ptr());
                break;
            default:
                throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
            };
        }
        else
        {
            switch(iPropertyIndex)
            {
            case 1:
                SetInvoiceNo(rValue.GetUI4());
                break;
            case 2:
                SetDeliveryAddress(dynamic_cast<SimpleHierarchyLib::CAddressType*>(rValue.GetXmlObject().Ptr()));
                break;
            case 3:
                SetBillingAddress(dynamic_cast<SimpleHierarchyLib::CAddressType*>(rValue.GetXmlObject().Ptr()));
                break;
            case 4:
                throw LtXmlLib20::CLtException(_T("Collections can not be set"));
                break;
            case 5:
                SetPayment(dynamic_cast<SimpleHierarchyLib::CPayment*>(rValue.GetXmlObject().Ptr()));
                break;
            default:
                throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
            }
        }
    }
    
    /*
     * Represents a mandatory Element in the XML document
     *
     * 
     * This property is represented as an Element in the XML.
     * It is mandatory and therefore must be populated within the XML.
     * It is defaulted to 0.
     */
    DWORD CInvoice::GetInvoiceNo() const
    {
        return this->m_InvoiceNo;
    }
    void CInvoice::SetInvoiceNo(DWORD value)
    { 
        this->m_InvoiceNo = value; 
    }
    
    /*
     * Represents a mandatory Element in the XML document
     *
     * 
     * This property is represented as an Element in the XML.
     * It is mandatory and therefore must be populated within the XML.
     * If this property is set, then the object will be COPIED. If the property is set to NULL an exception is raised.
     */
    SimpleHierarchyLib::CAddressTypePtr CInvoice::GetDeliveryAddress() const
    { 
        return this->m_DeliveryAddress;  
    }
    void CInvoice::SetDeliveryAddress(SimpleHierarchyLib::CAddressType* value)
    { 
        Throw_IfPropertyIsNull(value, _T("DeliveryAddress"));
        if (value != NULL)
            SetElementName(value, _T("DeliveryAddress"));
        this->m_DeliveryAddress = value; 
    }
    
    /*
     * Represents an optional Element in the XML document
     *
     * 
     * This property is represented as an Element in the XML.
     * It is optional, initially it is NULL.
     */
    SimpleHierarchyLib::CAddressTypePtr CInvoice::GetBillingAddress() const
    { 
        return this->m_BillingAddress;  
    }
    void CInvoice::SetBillingAddress(SimpleHierarchyLib::CAddressType* value)
    { 
        if (value == NULL)
            this->m_BillingAddress = NULL;
        else
        {
            SetElementName(value, _T("BillingAddress"));
            this->m_BillingAddress = value; 
        }
    }
    
    /*
     * A collection of CInvoices
     *
     * 
     * This property is represented as an Element in the XML.
     * This collection may contain 1 to Many objects.
     */
    SimpleHierarchyLib::CItemTypeColPtr CInvoice::GetItem() const
    {
        return this->m_Item; 
    }
    
    /*
     * Represents a mandatory Element in the XML document
     *
     * 
     * This property is represented as an Element in the XML.
     * It is mandatory and therefore must be populated within the XML.
     * If this property is set, then the object will be COPIED. If the property is set to NULL an exception is raised.
     */
    SimpleHierarchyLib::CPaymentPtr CInvoice::GetPayment() const
    { 
        return this->m_Payment;  
    }
    void CInvoice::SetPayment(SimpleHierarchyLib::CPayment* value)
    { 
        Throw_IfPropertyIsNull(value, _T("Payment"));
        if (value != NULL)
            SetElementName(value, _T("Payment"));
        this->m_Payment = value; 
    }
    
    /*
     * Allows the class to be copied
     * Performs a 'deep copy' of all the data in the class (and its children)
     */
    SimpleHierarchyLib::CInvoicePtr CInvoice::Clone() const
    {
        SimpleHierarchyLib::CInvoicePtr newObject = CreateInstance(m_elementName.c_str());
    
        int index = 0;
        newObject->m_InvoiceNo = m_InvoiceNo;
        newObject->m_DeliveryAddress = NULL;
        if (m_DeliveryAddress != NULL)
            newObject->m_DeliveryAddress = dynamic_cast<SimpleHierarchyLib::CAddressType*>(m_DeliveryAddress->Clone().Ptr());
        newObject->m_BillingAddress = NULL;
        if (m_BillingAddress != NULL)
            newObject->m_BillingAddress = dynamic_cast<SimpleHierarchyLib::CAddressType*>(m_BillingAddress->Clone().Ptr());
        for (index = 0; index < m_Item->GetCount(); index++)
            newObject->m_Item->Add(dynamic_cast<SimpleHierarchyLib::CItemType*>(m_Item->Item(index)->Clone().Ptr()));
        newObject->m_Payment = NULL;
        if (m_Payment != NULL)
            newObject->m_Payment = dynamic_cast<SimpleHierarchyLib::CPayment*>(m_Payment->Clone().Ptr());
    
    
    // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
    // Add Additional clone code here...
    
    // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
    
        return newObject.Ptr();
    }
    
    std::tstring CInvoice::GetTargetNamespace() const
    {
        return _T("");
    }   
    
    std::tstring CInvoice::GetNamespace() const
    {
        return _T("");
    }   
    
    LtXmlLib20::CXmlObjectBase* CInvoice::GetBase()
    {
        return this;
    }   
    
    void CInvoice::CleanMetaData()
    {
        LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
    }
    
    LtXmlLib20Data::CParentElementInfo* CInvoice::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("Invoice"),                   
                                                                                _T(""), 
                                                                                true,
                                                                                false,
                                                                                -1,
                                                                                LtXmlLib20::ItemType_none,
                                                                                LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
                                                                                NULL,
                                                                                false);
            }
            m_csInit.Leave();
        }
        
        return ms_pParentElementInfo;
    }
    
    LtXmlLib20Data::CElementInfo** CInvoice::GetClassElementInfo() const
    {
        if (ms_ppElementInfo == NULL)
        {
            m_csInit.Enter();
            if (ms_ppElementInfo == NULL)
            {
                ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[6];
            
                ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("InvoiceNo"), _T(""), 1, false, LtXmlLib20::ItemType_ui4, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
                ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqClsMnd(_T("DeliveryAddress"), _T(""), 2, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&SimpleHierarchyLib::CClassFactory::CreateClass, SimpleHierarchyLib::CClassFactory::ClsName_CAddressType, true);
                ms_ppElementInfo[2] = new LtXmlLib20Data::CElementInfoSeqClsOpt(_T("BillingAddress"), _T(""), 3, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&SimpleHierarchyLib::CClassFactory::CreateClass, SimpleHierarchyLib::CClassFactory::ClsName_CAddressType);
                ms_ppElementInfo[3] = new LtXmlLib20Data::CElementInfoSeqClsCol(_T("Item"), _T(""), 4, LtXmlLib20Data::XmlElementType_ELEMENT);
                ms_ppElementInfo[4] = new LtXmlLib20Data::CElementInfoSeqClsMnd(_T("Payment"), _T(""), 5, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&SimpleHierarchyLib::CClassFactory::CreateClass, SimpleHierarchyLib::CClassFactory::ClsName_CPayment, true);
                ms_ppElementInfo[5] = NULL;
            }
            m_csInit.Leave();
        }
        return ms_ppElementInfo;
    }
    
    LtXmlLib20Data::CAttributeInfo**    CInvoice::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;
    }
    
    // ##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