switched PRgeHandler where possible to smart pointers.

This commit is contained in:
suter_a 2023-10-21 18:40:35 +02:00
parent 05c06a071e
commit 823ef087c9

View File

@ -31,6 +31,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <string> #include <string>
#include <memory>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -345,7 +346,7 @@ PRgeHandler::PRgeHandler(const std::string fln)
} }
// create the rge xml handler // create the rge xml handler
PXmlRgeHandler *xmlRge = new PXmlRgeHandler(); std::unique_ptr<PXmlRgeHandler> xmlRge = std::make_unique<PXmlRgeHandler>();
if (xmlRge == nullptr) { if (xmlRge == nullptr) {
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "**ERROR** couldn't invoke PXmlRgeHandler." << std::endl; std::cerr << "**ERROR** couldn't invoke PXmlRgeHandler." << std::endl;
@ -355,7 +356,7 @@ PRgeHandler::PRgeHandler(const std::string fln)
} }
// create the SAX parser // create the SAX parser
TSAXParser *saxParser = new TSAXParser(); std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
if (saxParser == nullptr) { if (saxParser == nullptr) {
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "**ERROR** couldn't invoke TSAXParser." << std::endl; std::cerr << "**ERROR** couldn't invoke TSAXParser." << std::endl;
@ -366,7 +367,7 @@ PRgeHandler::PRgeHandler(const std::string fln)
saxParser->SetStopOnError(); saxParser->SetStopOnError();
// connect SAX parser and rge handler // connect SAX parser and rge handler
saxParser->ConnectToHandler("PXmlRgeHandler", xmlRge); saxParser->ConnectToHandler("PXmlRgeHandler", xmlRge.get());
int status = saxParser->ParseFile(fln.c_str()); int status = saxParser->ParseFile(fln.c_str());
if (status != 0) { if (status != 0) {
std::cerr << std::endl; std::cerr << std::endl;
@ -433,9 +434,6 @@ PRgeHandler::PRgeHandler(const std::string fln)
fData.push_back(dataSet); fData.push_back(dataSet);
} }
} }
delete saxParser;
delete xmlRge;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------