Commit 707eaddd by Francois Gygi

Use StrX in XML handler classes to avoid mem leaks

parent c4e49cf0
...@@ -42,7 +42,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri, ...@@ -42,7 +42,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
const Attributes& attributes) const Attributes& attributes)
{ {
// cout << " AtomSetHandler::startElement " << StrX(qname) << endl; // cout << " AtomSetHandler::startElement " << StrX(qname) << endl;
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
// consider only elements that are dealt with directly by AtomSetHandler // consider only elements that are dealt with directly by AtomSetHandler
// i.e. "atom". The "species" element is delegated to a SpeciesHandler // i.e. "atom". The "species" element is delegated to a SpeciesHandler
...@@ -52,8 +52,8 @@ void AtomSetHandler::startElement(const XMLCh* const uri, ...@@ -52,8 +52,8 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "a") if ( attrname == "a")
{ {
...@@ -79,7 +79,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri, ...@@ -79,7 +79,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
if ( attrname == "name") if ( attrname == "name")
{ {
current_atom_name = StrX(attributes.getValue(index)).localForm(); current_atom_name = StrX(attributes.getValue(index)).localForm();
...@@ -96,7 +96,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri, ...@@ -96,7 +96,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
void AtomSetHandler::endElement(const XMLCh* const uri, void AtomSetHandler::endElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, string& content) const XMLCh* const localname, const XMLCh* const qname, string& content)
{ {
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
// cout << " AtomSetHandler::endElement " << locname << endl; // cout << " AtomSetHandler::endElement " << locname << endl;
istringstream stst(content); istringstream stst(content);
if ( locname == "unit_cell") if ( locname == "unit_cell")
...@@ -146,14 +146,14 @@ StructureHandler* AtomSetHandler::startSubHandler(const XMLCh* const uri, ...@@ -146,14 +146,14 @@ StructureHandler* AtomSetHandler::startSubHandler(const XMLCh* const uri,
// If it can, return a pointer to the StructureHandler, otherwise return 0 // If it can, return a pointer to the StructureHandler, otherwise return 0
// cout << " AtomSetHandler::startSubHandler " << StrX(qname) << endl; // cout << " AtomSetHandler::startSubHandler " << StrX(qname) << endl;
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
if ( locname == "species") if ( locname == "species")
{ {
// check for species attributes // check for species attributes
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
if ( attrname == "name") if ( attrname == "name")
{ {
current_species_name = StrX(attributes.getValue(index)).localForm(); current_species_name = StrX(attributes.getValue(index)).localForm();
...@@ -175,7 +175,7 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri, ...@@ -175,7 +175,7 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, const XMLCh* const localname, const XMLCh* const qname,
const StructureHandler* const last) const StructureHandler* const last)
{ {
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
// cout << " AtomSetHandler::endSubHandler " << locname << endl; // cout << " AtomSetHandler::endSubHandler " << locname << endl;
if ( locname == "species" ) if ( locname == "species" )
{ {
......
...@@ -46,7 +46,7 @@ void SampleHandler::endElement(const XMLCh* const uri, ...@@ -46,7 +46,7 @@ void SampleHandler::endElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, string& content) const XMLCh* const localname, const XMLCh* const qname, string& content)
{ {
// istringstream stst(st); // istringstream stst(st);
// string locname(XMLString::transcode(localname)); // string locname = StrX(localname).localForm();
// cout << " SampleHandler::endElement " << locname << endl; // cout << " SampleHandler::endElement " << locname << endl;
} }
...@@ -59,7 +59,7 @@ StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri, ...@@ -59,7 +59,7 @@ StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri,
// If it can, return a pointer to the StructureHandler, otherwise return 0 // If it can, return a pointer to the StructureHandler, otherwise return 0
// cout << " SampleHandler::startSubHandler " << StrX(qname) << endl; // cout << " SampleHandler::startSubHandler " << StrX(qname) << endl;
string qnm = XMLString::transcode(qname); string qnm = StrX(qname).localForm();
if ( qnm == "atomset" ) if ( qnm == "atomset" )
{ {
return new AtomSetHandler(s_.atoms); return new AtomSetHandler(s_.atoms);
......
...@@ -39,7 +39,7 @@ void SpeciesHandler::read(const Attributes& attributes) ...@@ -39,7 +39,7 @@ void SpeciesHandler::read(const Attributes& attributes)
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for ( unsigned int index = 0; index < len; index++ ) for ( unsigned int index = 0; index < len; index++ )
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
if ( attrname == "l" ) if ( attrname == "l" )
{ {
current_l = atoi(StrX(attributes.getValue(index)).localForm()); current_l = atoi(StrX(attributes.getValue(index)).localForm());
...@@ -84,7 +84,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri, ...@@ -84,7 +84,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
{ {
// cout << " SpeciesHandler::startElement " << StrX(qname) << endl; // cout << " SpeciesHandler::startElement " << StrX(qname) << endl;
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
if ( locname == "species" ) if ( locname == "species" )
{ {
...@@ -92,7 +92,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri, ...@@ -92,7 +92,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for ( unsigned int index = 0; index < len; index++ ) for ( unsigned int index = 0; index < len; index++ )
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
if ( attrname == "name" ) if ( attrname == "name" )
{ {
current_name = StrX(attributes.getValue(index)).localForm(); current_name = StrX(attributes.getValue(index)).localForm();
...@@ -135,10 +135,8 @@ void SpeciesHandler::startElement(const XMLCh* const uri, ...@@ -135,10 +135,8 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
void SpeciesHandler::endElement(const XMLCh* const uri, void SpeciesHandler::endElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, string& content) const XMLCh* const localname, const XMLCh* const qname, string& content)
{ {
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
istringstream stst(content); istringstream stst(content);
// cout << " SpeciesHandler::endElement " << StrX(qname) << " content="
// << string(content,0,20) << endl;
if ( locname == "description" ) if ( locname == "description" )
{ {
......
...@@ -65,7 +65,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -65,7 +65,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
{ {
bool onpe0 = wf_.context().onpe0(); bool onpe0 = wf_.context().onpe0();
// cout << " WavefunctionHandler::startElement " << StrX(qname) << endl; // cout << " WavefunctionHandler::startElement " << StrX(qname) << endl;
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
int nspin=1, nel=0, nempty=0; int nspin=1, nel=0, nempty=0;
...@@ -76,7 +76,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -76,7 +76,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
if ( attrname == "ecut") if ( attrname == "ecut")
{ {
ecut = atof(StrX(attributes.getValue(index)).localForm()); ecut = atof(StrX(attributes.getValue(index)).localForm());
...@@ -116,8 +116,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -116,8 +116,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "a") if ( attrname == "a")
{ {
...@@ -143,8 +143,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -143,8 +143,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "a") if ( attrname == "a")
{ {
...@@ -171,8 +171,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -171,8 +171,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
string dmat_form; string dmat_form;
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "form") if ( attrname == "form")
{ {
...@@ -195,8 +195,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -195,8 +195,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "nx") if ( attrname == "nx")
{ {
...@@ -240,8 +240,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -240,8 +240,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "kpoint") if ( attrname == "kpoint")
{ {
...@@ -302,8 +302,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri, ...@@ -302,8 +302,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength(); unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++) for (unsigned int index = 0; index < len; index++)
{ {
string attrname(XMLString::transcode(attributes.getLocalName(index))); string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval(XMLString::transcode(attributes.getValue(index))); string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval); istringstream stst(attrval);
if ( attrname == "nx") if ( attrname == "nx")
{ {
...@@ -338,7 +338,7 @@ void WavefunctionHandler::endElement(const XMLCh* const uri, ...@@ -338,7 +338,7 @@ void WavefunctionHandler::endElement(const XMLCh* const uri,
{ {
const Context& ctxt = wf_.context(); const Context& ctxt = wf_.context();
bool onpe0 = ctxt.onpe0(); bool onpe0 = ctxt.onpe0();
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
//cout << " WavefunctionHandler::endElement " << locname << endl; //cout << " WavefunctionHandler::endElement " << locname << endl;
if ( locname == "density_matrix") if ( locname == "density_matrix")
{ {
...@@ -495,7 +495,7 @@ void WavefunctionHandler::endSubHandler(const XMLCh* const uri, ...@@ -495,7 +495,7 @@ void WavefunctionHandler::endSubHandler(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, const XMLCh* const localname, const XMLCh* const qname,
const StructureHandler* const last) const StructureHandler* const last)
{ {
string locname(XMLString::transcode(localname)); string locname = StrX(localname).localForm();
//cout << " WavefunctionHandler::endSubHandler " << locname << endl; //cout << " WavefunctionHandler::endSubHandler " << locname << endl;
delete last; delete last;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment