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,
const Attributes& attributes)
{
// 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
// i.e. "atom". The "species" element is delegated to a SpeciesHandler
......@@ -52,8 +52,8 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "a")
{
......@@ -79,7 +79,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
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")
{
current_atom_name = StrX(attributes.getValue(index)).localForm();
......@@ -96,7 +96,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
void AtomSetHandler::endElement(const XMLCh* const uri,
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;
istringstream stst(content);
if ( locname == "unit_cell")
......@@ -146,14 +146,14 @@ StructureHandler* AtomSetHandler::startSubHandler(const XMLCh* const uri,
// If it can, return a pointer to the StructureHandler, otherwise return 0
// cout << " AtomSetHandler::startSubHandler " << StrX(qname) << endl;
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
if ( locname == "species")
{
// check for species attributes
unsigned int len = attributes.getLength();
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")
{
current_species_name = StrX(attributes.getValue(index)).localForm();
......@@ -175,7 +175,7 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname,
const StructureHandler* const last)
{
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
// cout << " AtomSetHandler::endSubHandler " << locname << endl;
if ( locname == "species" )
{
......
......@@ -46,7 +46,7 @@ void SampleHandler::endElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, string& content)
{
// istringstream stst(st);
// string locname(XMLString::transcode(localname));
// string locname = StrX(localname).localForm();
// cout << " SampleHandler::endElement " << locname << endl;
}
......@@ -59,7 +59,7 @@ StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri,
// If it can, return a pointer to the StructureHandler, otherwise return 0
// cout << " SampleHandler::startSubHandler " << StrX(qname) << endl;
string qnm = XMLString::transcode(qname);
string qnm = StrX(qname).localForm();
if ( qnm == "atomset" )
{
return new AtomSetHandler(s_.atoms);
......
......@@ -39,7 +39,7 @@ void SpeciesHandler::read(const Attributes& attributes)
unsigned int len = attributes.getLength();
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" )
{
current_l = atoi(StrX(attributes.getValue(index)).localForm());
......@@ -84,7 +84,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
{
// cout << " SpeciesHandler::startElement " << StrX(qname) << endl;
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
if ( locname == "species" )
{
......@@ -92,7 +92,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
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" )
{
current_name = StrX(attributes.getValue(index)).localForm();
......@@ -135,10 +135,8 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
void SpeciesHandler::endElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, string& content)
{
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
istringstream stst(content);
// cout << " SpeciesHandler::endElement " << StrX(qname) << " content="
// << string(content,0,20) << endl;
if ( locname == "description" )
{
......
......@@ -65,7 +65,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
{
bool onpe0 = wf_.context().onpe0();
// cout << " WavefunctionHandler::startElement " << StrX(qname) << endl;
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
int nspin=1, nel=0, nempty=0;
......@@ -76,7 +76,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
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")
{
ecut = atof(StrX(attributes.getValue(index)).localForm());
......@@ -116,8 +116,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "a")
{
......@@ -143,8 +143,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "a")
{
......@@ -171,8 +171,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
string dmat_form;
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "form")
{
......@@ -195,8 +195,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "nx")
{
......@@ -240,8 +240,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "kpoint")
{
......@@ -302,8 +302,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
string attrname = StrX(attributes.getLocalName(index)).localForm();
string attrval = StrX(attributes.getValue(index)).localForm();
istringstream stst(attrval);
if ( attrname == "nx")
{
......@@ -338,7 +338,7 @@ void WavefunctionHandler::endElement(const XMLCh* const uri,
{
const Context& ctxt = wf_.context();
bool onpe0 = ctxt.onpe0();
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
//cout << " WavefunctionHandler::endElement " << locname << endl;
if ( locname == "density_matrix")
{
......@@ -495,7 +495,7 @@ void WavefunctionHandler::endSubHandler(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname,
const StructureHandler* const last)
{
string locname(XMLString::transcode(localname));
string locname = StrX(localname).localForm();
//cout << " WavefunctionHandler::endSubHandler " << locname << endl;
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