Board index » cppbuilder » how to use an XML data structure created by the XML Data Binding

how to use an XML data structure created by the XML Data Binding


2005-03-18 05:19:04 PM
cppbuilder44
Hi,
this code is the way i use the code generated by the XML Data Binding
Wizard. My problem is how do I release the memory allocated by
_di_OrderContainer.
//-----------------------------------------------------------------------------
void clsXMLOrderFile::Load()
{
int i;
clsOrder* lOrder;
clsOrderList *tmpList;
_di_OrderContainer XMLOrderContainer;
_di_IXMLOrderTypeList XMLOrderList;
_di_IXMLOrderType XMLOrder;
try
{
try
{
// Create OrderList
tmpList = new clsOrderList();
// Read TXMLdocument in memory
XMLOrderContainer = LoadOrderList(FFileName);
// Get Last key from the XML OrderList
tmpList->LastKey = XMLOrderContainer->Get_KeyField();
// Get reference to XML (Template)OrderList
XMLOrderList = XMLOrderContainer->OrderList;
i = 0;
while (XMLOrderList->Count>i)
{
// Get current XML Order
XMLOrder = XMLOrderList->Get_Item(i);
// Create new order
lOrder = new clsOrder();
// Convert from XML to Order
lOrder->FromXML(XMLOrder);
// Add the order to the OrderList
tmpList->AddOrder(lOrder);
i++;
}
}
catch(Exception *E)
{
try
{
Save();
Load();
}
catch(Exception *E)
{
Application->MessageBox(E->Message.c_str(),"<?Error?>",MB_OK);
}
}
}
catch(...)
{
Application->MessageBox("Foutje","foutje",MB_OK);
}
GetDataRef()->Assign( tmpList );
delete tmpList;
tmpList = NULL;
lVersion =
(long)StrToInt64Def(IFM->GetStatusUserToUser2Ref()->Value(FFileName),0L);
}
the XMLOrderContainer is created from this XML definition
what is a list of orders and a max order nr (LastKey) init.
<?xml version="1.0"?>
<xs:schema xmlns:xs="www.w3.org/2001/XMLSchema"
xmlns:xdb="www.borland.com/schemas/delphi/6.0/XMLDataBinding">
<xs:element name="OrderList" type="OrderListType"/>
<xs:complexType name="OrderListType"><xs:annotation>
<xs:appinfo xdb:identifierName="OrderContainer"
xdb:docElement="OrderList"/>
</xs:annotation>
<xs:sequence>
<xs:element name="KeyField" type="xs:string"/>
<xs:element name="Order" type="OrderType"
maxOccurs="unbounded"><xs:annotation>
<xs:appinfo xdb:identifierName="OrderList"/>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="OrderType"><xs:annotation>
<xs:appinfo xdb:repeated="True"/>
</xs:annotation>
<xs:sequence>
<xs:element name="version" type="xs:string"/>
<xs:element name="Orderid" type="xs:integer"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="State" type="xs:integer"/>
<xs:element name="CountDownActive" type="xs:boolean"/>
<xs:element name="Grade" type="xs:string"/>
<xs:element name="InktJetTypeActive" type="xs:boolean"/>
<xs:element name="InktTextText" type="xs:string"/>
<xs:element name="CrackQuality" type="xs:integer"/>
<xs:element name="DirtQuality" type="xs:integer"/>
<xs:element name="{*word*76}Quality" type="xs:string"/>
<xs:element name="EggType" type="xs:string"/>
<xs:element name="EggColor" type="xs:string"/>
<xs:element name="SortFunction" type="xs:string"/>
<xs:element name="EggStampActive" type="xs:boolean"/>
<xs:element name="Amount" type="xs:integer"/>
<xs:element name="PackType" type="PackType"/>
<xs:element name="Lane" type="LaneType" maxOccurs="unbounded"/>
<xs:element name="Progress" type="xs:integer"/>
<xs:element name="ImageFile" type="xs:string"/>
<xs:element name="ActiveLanes" type="xs:integer"/>
<xs:element name="MachineOrderID" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PackType">
<xs:sequence>
<xs:element name="ID" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="LaneType"><xs:annotation>
<xs:appinfo xdb:repeated="True"/>
</xs:annotation>
<xs:sequence>
<xs:element name="ID" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
 
 

Re:how to use an XML data structure created by the XML Data Binding

"Jochanan" < XXXX@XXXXX.COM >wrote in message
Quote
how do I release the memory allocated by _di_OrderContainer.
All of the data types that have the _di_ prefix are freed automatically when
they goes out of scope.
Gambit
 

Re:how to use an XML data structure created by the XML Data Binding

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schreef in bericht
Quote

"Jochanan" < XXXX@XXXXX.COM >wrote in message
news:423a9d1a$ XXXX@XXXXX.COM ...

>how do I release the memory allocated by _di_OrderContainer.

All of the data types that have the _di_ prefix are freed automatically
when
they goes out of scope.


Gambit


that is what i thout but when i run my code with code guard and i scip this
function it give me a difference of 60 less in my memory leaks
and thos i want to have as close as possible to zero.
When i get out of the function i expect the system to release the memory and
that is not happening.
do you have any other idea's.
Jochanan
 

{smallsort}

Re:how to use an XML data structure created by the XML Data Binding

I Found it is was my mistake thanks for the reaction.
I forget te delet the object clsOrder.
thanks
Jochanan
"Jochanan" < XXXX@XXXXX.COM >schreef in bericht
Quote

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schreef in bericht
news:423aa36d$ XXXX@XXXXX.COM ...
>
>"Jochanan" < XXXX@XXXXX.COM >wrote in message
>news:423a9d1a$ XXXX@XXXXX.COM ...
>
>>how do I release the memory allocated by _di_OrderContainer.
>
>All of the data types that have the _di_ prefix are freed automatically
>when
>they goes out of scope.
>
>
>Gambit
>
>
that is what i thout but when i run my code with code guard and i scip
this function it give me a difference of 60 less in my memory leaks
and thos i want to have as close as possible to zero.

When i get out of the function i expect the system to release the memory
and that is not happening.

do you have any other idea's.

Jochanan