C
cerr
Hi There,
I have a little issue going here:
I have a xml configuration file that looks kinda like this:
<PID>
<DESCRIPTION>Steveston Hwy</DESCRIPTION>
<BCAST>192.168.101.255</BCAST>
<DESTINATION>
<DESTNO>1531</DESTNO>
<DESTNO>301</DESTNO>
<DESTNO>12555</DESTNO>
</DESTINATION>
</PID>
Now there could be various <PID> tags as well as each <PID> would
likely have multiple <DESTNO> tags.
How do I store this best in my app?
I thoughtr I'd declare a struct like this:
struct structPID
{
string strBcast;
string strDescription;
vector<int> Dest;
};
and just extend the array when there's more PIDs in that file.
But when I read out the file i'm using my xml parser and i thought i'd
do something like this:
//i_PIDlist is the pointer to a variable decalred private in class
PIDClient.
bool PIDClient::readPIDConfig(string Configfile, vector<structPID>
*i_PIDlist)
{
RSXMLParser xmlPIDData(Configfile,
RSXMLParser::FILE);
if (!xmlPIDData.IsDataGood()) {
OUTPUT(std::cerr << "Document " << conf->
intersectionDataFile << " is not parsed
successfully.\n";
)
return false;
}
string strPID = xmlPIDData.GetNodeData("PID"); //PID
while (strPID.size() > 0) {
RSXMLParser xmlPID(strPID); //PID details
structPID tmpPID;
tmpPID.strBcast=xmlPID.GetNodeData("BCAST");
tmpPID.strDescription=xmlPID.GetNodeData("DESCRIPTION");
string strDest = xmlPIDData.GetNodeData("DESTINATION");
while(strDest.size() > 0) {
RSXMLParser xmlPIDDest(strDest);
xmlPIDDest.GetNodeData("DESTNO");
tmpPID.Dest->push_back();
}
i_PIDlist->push_back(tmpPID);
//delete tmpPID;
//tmpPID=NULL;
strPID = xmlPIDData.GetNext();
}
return true;
}
But there's two problems i'm seeing just right out of the bat:
If the outer while loop goes twice, how would tmpPID be re-declared?
I thought about declaring it on the heap and then calling delete in
the end of the funtion before it loops around but even then,
I would do a i_PIDlist->push_back(tmpPID) and it woudl push on a
pionter that gets ereased soon after...
Thanks for a little help and guidance here.
Ron
I have a little issue going here:
I have a xml configuration file that looks kinda like this:
<PID>
<DESCRIPTION>Steveston Hwy</DESCRIPTION>
<BCAST>192.168.101.255</BCAST>
<DESTINATION>
<DESTNO>1531</DESTNO>
<DESTNO>301</DESTNO>
<DESTNO>12555</DESTNO>
</DESTINATION>
</PID>
Now there could be various <PID> tags as well as each <PID> would
likely have multiple <DESTNO> tags.
How do I store this best in my app?
I thoughtr I'd declare a struct like this:
struct structPID
{
string strBcast;
string strDescription;
vector<int> Dest;
};
and just extend the array when there's more PIDs in that file.
But when I read out the file i'm using my xml parser and i thought i'd
do something like this:
//i_PIDlist is the pointer to a variable decalred private in class
PIDClient.
bool PIDClient::readPIDConfig(string Configfile, vector<structPID>
*i_PIDlist)
{
RSXMLParser xmlPIDData(Configfile,
RSXMLParser::FILE);
if (!xmlPIDData.IsDataGood()) {
OUTPUT(std::cerr << "Document " << conf->
intersectionDataFile << " is not parsed
successfully.\n";
)
return false;
}
string strPID = xmlPIDData.GetNodeData("PID"); //PID
while (strPID.size() > 0) {
RSXMLParser xmlPID(strPID); //PID details
structPID tmpPID;
tmpPID.strBcast=xmlPID.GetNodeData("BCAST");
tmpPID.strDescription=xmlPID.GetNodeData("DESCRIPTION");
string strDest = xmlPIDData.GetNodeData("DESTINATION");
while(strDest.size() > 0) {
RSXMLParser xmlPIDDest(strDest);
xmlPIDDest.GetNodeData("DESTNO");
tmpPID.Dest->push_back();
}
i_PIDlist->push_back(tmpPID);
//delete tmpPID;
//tmpPID=NULL;
strPID = xmlPIDData.GetNext();
}
return true;
}
But there's two problems i'm seeing just right out of the bat:
If the outer while loop goes twice, how would tmpPID be re-declared?
I thought about declaring it on the heap and then calling delete in
the end of the funtion before it loops around but even then,
I would do a i_PIDlist->push_back(tmpPID) and it woudl push on a
pionter that gets ereased soon after...
Thanks for a little help and guidance here.
Ron