mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Replace auto_ptr with unique_ptr
This is a mechanical replacement. For now it seems that unique_ptrs are essentially used for exception-safety. More could certainly be done to clarify pointer ownership in general.
This commit is contained in:
parent
af5f69cea7
commit
557975a8de
@ -3654,11 +3654,11 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
|
||||
}
|
||||
|
||||
// returns NULL if id-to-row conversion is unsupported
|
||||
auto_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
|
||||
pit_type par_begin, pit_type par_end,
|
||||
OutputWhat output, bool master) const
|
||||
unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
|
||||
pit_type par_begin, pit_type par_end,
|
||||
OutputWhat output, bool master) const
|
||||
{
|
||||
auto_ptr<TexRow> texrow(NULL);
|
||||
unique_ptr<TexRow> texrow;
|
||||
OutputParams runparams(¶ms().encoding());
|
||||
runparams.nice = true;
|
||||
runparams.flavor = params().getOutputFlavor(format);
|
||||
@ -3712,7 +3712,7 @@ auto_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
|
||||
LaTeXFeatures features(*this, params(), runparams);
|
||||
params().validate(features);
|
||||
runparams.use_polyglossia = features.usePolyglossia();
|
||||
texrow.reset(new TexRow());
|
||||
texrow = make_unique<TexRow>();
|
||||
texrow->newline();
|
||||
texrow->newline();
|
||||
// latex or literate
|
||||
@ -3755,7 +3755,7 @@ auto_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
|
||||
writeDocBookSource(os, absFileName(), runparams, output);
|
||||
} else {
|
||||
// latex or literate
|
||||
texrow.reset(new TexRow());
|
||||
texrow = make_unique<TexRow>();
|
||||
texrow->newline();
|
||||
texrow->newline();
|
||||
otexstream ots(os, *texrow);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "OutputEnums.h"
|
||||
#include "OutputParams.h"
|
||||
|
||||
#include "support/unique_ptr.h"
|
||||
#include "support/strfwd.h"
|
||||
#include "support/types.h"
|
||||
|
||||
@ -623,8 +624,8 @@ public:
|
||||
|
||||
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
|
||||
/// including preamble
|
||||
/// returns NULL if Id to Row conversion is unsupported
|
||||
std::auto_ptr<TexRow> getSourceCode(odocstream & os,
|
||||
/// returns nullptr if Id to Row conversion is unsupported
|
||||
unique_ptr<TexRow> getSourceCode(odocstream & os,
|
||||
std::string const & format, pit_type par_begin,
|
||||
pit_type par_end, OutputWhat output, bool master) const;
|
||||
|
||||
|
@ -130,9 +130,9 @@ Buffer * BufferList::newBuffer(string const & s)
|
||||
|
||||
Buffer * BufferList::createNewBuffer(string const & s)
|
||||
{
|
||||
auto_ptr<Buffer> tmpbuf;
|
||||
unique_ptr<Buffer> tmpbuf;
|
||||
try {
|
||||
tmpbuf.reset(new Buffer(s));
|
||||
tmpbuf = make_unique<Buffer>(s);
|
||||
} catch (ExceptionMessage const & message) {
|
||||
if (message.type_ == ErrorException) {
|
||||
Alert::error(message.title_, message.details_);
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/lyxtime.h"
|
||||
#include "support/textutils.h"
|
||||
#include "support/unique_ptr.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@ -463,8 +464,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
|
||||
} else if (token == "\\SpecialChar" ||
|
||||
(token == "\\SpecialCharNoPassThru" &&
|
||||
!par.layout().pass_thru && !inset().isPassThru())) {
|
||||
auto_ptr<Inset> inset;
|
||||
inset.reset(new InsetSpecialChar);
|
||||
auto inset = make_unique<InsetSpecialChar>();
|
||||
inset->read(lex);
|
||||
inset->setBuffer(*buf);
|
||||
par.insertInset(par.size(), inset.release(), font, change);
|
||||
@ -473,8 +473,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
|
||||
docstring const s = ltrim(lex.getDocString(), "\\");
|
||||
par.insert(par.size(), s, font, change);
|
||||
} else if (token == "\\IPAChar") {
|
||||
auto_ptr<Inset> inset;
|
||||
inset.reset(new InsetIPAChar);
|
||||
auto inset = make_unique<InsetIPAChar>();
|
||||
inset->read(lex);
|
||||
inset->setBuffer(*buf);
|
||||
par.insertInset(par.size(), inset.release(), font, change);
|
||||
@ -499,7 +498,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
|
||||
} else if (token == "\\backslash") {
|
||||
par.appendChar('\\', font, change);
|
||||
} else if (token == "\\LyXTable") {
|
||||
auto_ptr<Inset> inset(new InsetTabular(buf));
|
||||
auto inset = make_unique<InsetTabular>(buf);
|
||||
inset->read(lex);
|
||||
par.insertInset(par.size(), inset.release(), font, change);
|
||||
} else if (token == "\\change_unchanged") {
|
||||
|
@ -65,13 +65,14 @@
|
||||
#include "frontends/alert.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/unique_ptr.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
@ -309,7 +310,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
||||
case EXTERNAL_CODE: {
|
||||
InsetExternalParams iep;
|
||||
InsetExternal::string2params(to_utf8(cmd.argument()), *buf, iep);
|
||||
auto_ptr<InsetExternal> inset(new InsetExternal(buf));
|
||||
auto inset = make_unique<InsetExternal>(buf);
|
||||
inset->setBuffer(*buf);
|
||||
inset->setParams(iep);
|
||||
return inset.release();
|
||||
@ -318,7 +319,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
||||
case GRAPHICS_CODE: {
|
||||
InsetGraphicsParams igp;
|
||||
InsetGraphics::string2params(to_utf8(cmd.argument()), *buf, igp);
|
||||
auto_ptr<InsetGraphics> inset(new InsetGraphics(buf));
|
||||
auto inset = make_unique<InsetGraphics>(buf);
|
||||
inset->setParams(igp);
|
||||
return inset.release();
|
||||
}
|
||||
@ -514,7 +515,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
|
||||
if (lex.getString() != "\\begin_inset")
|
||||
LYXERR0("Buffer::readInset: Consistency check failed.");
|
||||
|
||||
auto_ptr<Inset> inset;
|
||||
unique_ptr<Inset> inset;
|
||||
|
||||
string tmptok;
|
||||
lex >> tmptok;
|
||||
|
@ -111,8 +111,8 @@ void ViewSourceWidget::getContent(BufferView const * view,
|
||||
if (par_begin > par_end)
|
||||
swap(par_begin, par_end);
|
||||
odocstringstream ostr;
|
||||
texrow_ = view->buffer().getSourceCode(ostr, format,
|
||||
par_begin, par_end + 1, output, master);
|
||||
texrow_ = view->buffer()
|
||||
.getSourceCode(ostr, format, par_begin, par_end + 1, output, master);
|
||||
//ensure that the last line can always be selected in its full width
|
||||
str = ostr.str() + "\n";
|
||||
}
|
||||
@ -201,7 +201,7 @@ void ViewSourceWidget::realUpdateView()
|
||||
#ifdef DEVEL_VERSION
|
||||
// output tex<->row correspondences in the source panel if the "-dbg latex"
|
||||
// option is given.
|
||||
if (texrow_.get() && lyx::lyxerr.debugging(Debug::LATEX)) {
|
||||
if (texrow_ && lyx::lyxerr.debugging(Debug::LATEX)) {
|
||||
QStringList list = qcontent.split(QChar('\n'));
|
||||
docstring_list dlist;
|
||||
for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
@ -216,7 +216,7 @@ void ViewSourceWidget::realUpdateView()
|
||||
viewSourceTV->blockSignals(true);
|
||||
bool const changed = setText(qcontent);
|
||||
|
||||
if (changed && !texrow_.get()) {
|
||||
if (changed && !texrow_) {
|
||||
// position-to-row is unavailable
|
||||
// we jump to the first modification
|
||||
const QChar * oc = old.constData();
|
||||
@ -246,7 +246,7 @@ void ViewSourceWidget::realUpdateView()
|
||||
//c.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,1);
|
||||
viewSourceTV->setTextCursor(c);
|
||||
|
||||
} else if (texrow_.get()) {
|
||||
} else if (texrow_) {
|
||||
// Use the available position-to-row conversion to highlight
|
||||
// the current selection in the source
|
||||
std::pair<int,int> rows = texrow_->rowFromCursor(bv_->cursor());
|
||||
@ -309,7 +309,7 @@ void ViewSourceWidget::realUpdateView()
|
||||
// need a proper LFUN if we want to implement it in release mode
|
||||
void ViewSourceWidget::gotoCursor()
|
||||
{
|
||||
if (!bv_ || !texrow_.get())
|
||||
if (!bv_ || !texrow_)
|
||||
return;
|
||||
int row = viewSourceTV->textCursor().blockNumber() + 1;
|
||||
const_cast<BufferView *>(bv_)->setCursorFromRow(row, *texrow_);
|
||||
|
@ -85,7 +85,7 @@ private:
|
||||
QTimer * update_timer_;
|
||||
/// TexRow information from the last source view. If TexRow is unavailable
|
||||
/// for the last format then texrow_ is null.
|
||||
std::auto_ptr<TexRow> texrow_;
|
||||
unique_ptr<TexRow> texrow_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -434,7 +434,7 @@ string const substituteIt<TransformCommand>(string const & input,
|
||||
else if (id == Resize)
|
||||
ptr = store.getCommandTransformer(params.resizedata);
|
||||
|
||||
if (!ptr.get())
|
||||
if (!ptr)
|
||||
return input;
|
||||
|
||||
string result =
|
||||
@ -473,7 +473,7 @@ string const substituteIt<TransformOption>(string const & input,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ptr.get())
|
||||
if (!ptr)
|
||||
return input;
|
||||
|
||||
return subst(input, ptr->placeholder(), ptr->option());
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include "graphics/GraphicsParams.h"
|
||||
|
||||
#include "support/unique_ptr.h"
|
||||
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
@ -121,7 +123,7 @@ public:
|
||||
*/
|
||||
class TransformCommand {
|
||||
public:
|
||||
typedef std::auto_ptr<TransformCommand const> ptr_type;
|
||||
typedef unique_ptr<TransformCommand const> ptr_type;
|
||||
virtual ~TransformCommand() {}
|
||||
|
||||
/// The string from the External Template that we seek to replace.
|
||||
@ -200,7 +202,7 @@ private:
|
||||
*/
|
||||
class TransformOption {
|
||||
public:
|
||||
typedef std::auto_ptr<TransformOption const> ptr_type;
|
||||
typedef unique_ptr<TransformOption const> ptr_type;
|
||||
virtual ~TransformOption() {}
|
||||
|
||||
/// The string from the External Template that we seek to replace.
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "support/TempFile.h"
|
||||
#include "support/textutils.h"
|
||||
#include "support/unique_ptr.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
@ -370,7 +371,7 @@ void splitScripts(MathData & ar)
|
||||
|
||||
// create extra script inset and move superscript over
|
||||
InsetMathScript * p = ar[i].nucleus()->asScriptInset();
|
||||
auto_ptr<InsetMathScript> q(new InsetMathScript(buf, true));
|
||||
auto q = make_unique<InsetMathScript>(buf, true);
|
||||
swap(q->up(), p->up());
|
||||
p->removeScript(true);
|
||||
|
||||
@ -598,7 +599,7 @@ void extractFunctions(MathData & ar, ExternalMath kind)
|
||||
extractScript(exp, jt, ar.end(), true);
|
||||
|
||||
// create a proper inset as replacement
|
||||
auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(buf, name));
|
||||
auto p = make_unique<InsetMathExFunc>(buf, name);
|
||||
|
||||
// jt points to the "argument". Get hold of this.
|
||||
MathData::iterator st =
|
||||
@ -683,7 +684,7 @@ void extractIntegrals(MathData & ar, ExternalMath kind)
|
||||
continue;
|
||||
|
||||
// core ist part from behind the scripts to the 'd'
|
||||
auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("int")));
|
||||
auto p = make_unique<InsetMathExInt>(buf, from_ascii("int"));
|
||||
|
||||
// handle scripts if available
|
||||
if (!testIntSymbol(*it)) {
|
||||
@ -768,7 +769,7 @@ void extractSums(MathData & ar)
|
||||
continue;
|
||||
|
||||
// create a proper inset as replacement
|
||||
auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("sum")));
|
||||
auto p = make_unique<InsetMathExInt>(buf, from_ascii("sum"));
|
||||
|
||||
// collect lower bound and summation index
|
||||
InsetMathScript const * sub = ar[i]->asScriptInset();
|
||||
@ -856,7 +857,7 @@ void extractDiff(MathData & ar)
|
||||
}
|
||||
|
||||
// create a proper diff inset
|
||||
auto_ptr<InsetMathDiff> diff(new InsetMathDiff(buf));
|
||||
auto diff = make_unique<InsetMathDiff>(buf);
|
||||
|
||||
// collect function, let jt point behind last used item
|
||||
MathData::iterator jt = it + 1;
|
||||
|
@ -74,9 +74,10 @@ following hack as starting point to write some macros:
|
||||
#include "Encoding.h"
|
||||
#include "Lexer.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/unique_ptr.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@ -1945,7 +1946,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
|
||||
|
||||
// Disabled
|
||||
else if (1 && t.cs() == "ar") {
|
||||
auto_ptr<InsetMathXYArrow> p(new InsetMathXYArrow);
|
||||
auto p = make_unique<InsetMathXYArrow>();
|
||||
// try to read target
|
||||
parse(p->cell(0), FLAG_OTPTION, mode);
|
||||
// try to read label
|
||||
|
Loading…
Reference in New Issue
Block a user