BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Jochanan
Guest





PostPosted: Fri Mar 18, 2005 9:19 am    Post subject: how to use an XML data structure created by the XML Data Bin Reply with quote



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="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://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="BloodQuality" 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>




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Mar 18, 2005 9:45 am    Post subject: Re: how to use an XML data structure created by the XML Data Reply with quote




"Jochanan" <jvdniet (AT) hotmail (DOT) com> wrote


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



Back to top
Jochanan
Guest





PostPosted: Fri Mar 18, 2005 10:08 am    Post subject: Re: how to use an XML data structure created by the XML Data Reply with quote




"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schreef in bericht
news:423aa36d$2 (AT) newsgroups (DOT) borland.com...
Quote:

"Jochanan" <jvdniet (AT) hotmail (DOT) com> wrote in message
news:423a9d1a$1 (AT) newsgroups (DOT) borland.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



Back to top
Jochanan
Guest





PostPosted: Fri Mar 18, 2005 10:21 am    Post subject: Re: how to use an XML data structure created by the XML Data Reply with quote

I Found it is was my mistake thanks for the reaction.


I forget te delet the object clsOrder.


thanks

Jochanan


"Jochanan" <jvdniet (AT) hotmail (DOT) com> schreef in bericht
news:423aa8af (AT) newsgroups (DOT) borland.com...
Quote:

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schreef in bericht
news:423aa36d$2 (AT) newsgroups (DOT) borland.com...

"Jochanan" <jvdniet (AT) hotmail (DOT) com> wrote in message
news:423a9d1a$1 (AT) newsgroups (DOT) borland.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





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.