Got rid of auto_ptr in the XSLT stylesheet compiler

This commit is contained in:
Jez Higgins 2020-04-15 23:05:47 +01:00
parent a7ff4b9a1b
commit 6674947a12
3 changed files with 10 additions and 10 deletions

View file

@ -25,7 +25,7 @@ int main(int argc, const char* argv[])
try try
{ {
Arabica::SAX::InputSource<std::string> source(argv[2]); Arabica::SAX::InputSource<std::string> source(argv[2]);
std::auto_ptr<Arabica::XSLT::Stylesheet<std::string> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<std::string> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0) if(stylesheet.get() == 0)
{ {
std::cerr << "Couldn't compile stylesheet: " << compiler.error() << std::endl; std::cerr << "Couldn't compile stylesheet: " << compiler.error() << std::endl;

View file

@ -227,11 +227,11 @@ public:
{ {
} // ~StylesheetCompiler } // ~StylesheetCompiler
std::auto_ptr<Stylesheet<string_type, string_adaptor> > compile(InputSourceT& source) std::unique_ptr<Stylesheet<string_type, string_adaptor> > compile(InputSourceT& source)
{ {
error_ = ""; error_ = "";
std::auto_ptr<CompiledStylesheet<string_type, string_adaptor> > stylesheet(new CompiledStylesheet<string_type, string_adaptor>()); auto stylesheet = std::make_unique<CompiledStylesheet<string_type, string_adaptor>>();
StylesheetParser<string_type, string_adaptor> parser; StylesheetParser<string_type, string_adaptor> parser;
CompilationContext<string_type, string_adaptor> context(parser, *stylesheet.get()); CompilationContext<string_type, string_adaptor> context(parser, *stylesheet.get());
@ -252,7 +252,7 @@ public:
stylesheet.reset(); stylesheet.reset();
} // catch } // catch
return std::auto_ptr<Stylesheet<string_type, string_adaptor> >(stylesheet.release()); return std::unique_ptr<Stylesheet<string_type, string_adaptor> >(stylesheet.release());
} // compile } // compile
const std::string& error() const const std::string& error() const

View file

@ -177,7 +177,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler; Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_)); Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() != 0) if(stylesheet.get() != 0)
assertImplementation(false, "Expected " + input_xslt_ + " not to compile. But it did :o"); assertImplementation(false, "Expected " + input_xslt_ + " not to compile. But it did :o");
throw SkipException(reason_ + " : " + compiler.error()); throw SkipException(reason_ + " : " + compiler.error());
@ -209,7 +209,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler; Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_)); Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0) if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error()); assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());
@ -255,7 +255,7 @@ protected:
string_type input = string_adaptor::construct(input_xslt_); string_type input = string_adaptor::construct(input_xslt_);
Arabica::SAX::InputSource<string_type, string_adaptor> source(input); Arabica::SAX::InputSource<string_type, string_adaptor> source(input);
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0) if(stylesheet.get() == 0)
return; return;
@ -301,7 +301,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler; Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_)); Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0) if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error()); assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());
@ -397,7 +397,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler; Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_)); Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0) if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error()); assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());
@ -498,7 +498,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler; Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_)); Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source); std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0) if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error()); assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());