auto_ptr -> unique_ptr
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index 62e0a99..35bbfa2 100644
--- a/cpp/poppler-document.cpp
+++ b/cpp/poppler-document.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2009-2011, Pino Toscano <pino@kde.org>
* Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
+ * Copyright (C) 2017, Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -341,7 +342,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_value(d->doc->getDocInfoStringEntry(key.c_str()));
+ std::unique_ptr<GooString> goo_value(d->doc->getDocInfoStringEntry(key.c_str()));
if (!goo_value.get()) {
return ustring();
}
@@ -386,7 +387,7 @@
return time_type(-1);
}
- std::auto_ptr<GooString> goo_date(d->doc->getDocInfoStringEntry(key.c_str()));
+ std::unique_ptr<GooString> goo_date(d->doc->getDocInfoStringEntry(key.c_str()));
if (!goo_date.get()) {
return time_type(-1);
}
@@ -432,7 +433,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_title(d->doc->getDocInfoTitle());
+ std::unique_ptr<GooString> goo_title(d->doc->getDocInfoTitle());
if (!goo_title.get()) {
return ustring();
}
@@ -476,7 +477,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_author(d->doc->getDocInfoAuthor());
+ std::unique_ptr<GooString> goo_author(d->doc->getDocInfoAuthor());
if (!goo_author.get()) {
return ustring();
}
@@ -520,7 +521,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_subject(d->doc->getDocInfoSubject());
+ std::unique_ptr<GooString> goo_subject(d->doc->getDocInfoSubject());
if (!goo_subject.get()) {
return ustring();
}
@@ -564,7 +565,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_keywords(d->doc->getDocInfoKeywords());
+ std::unique_ptr<GooString> goo_keywords(d->doc->getDocInfoKeywords());
if (!goo_keywords.get()) {
return ustring();
}
@@ -608,7 +609,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_creator(d->doc->getDocInfoCreator());
+ std::unique_ptr<GooString> goo_creator(d->doc->getDocInfoCreator());
if (!goo_creator.get()) {
return ustring();
}
@@ -652,7 +653,7 @@
return ustring();
}
- std::auto_ptr<GooString> goo_producer(d->doc->getDocInfoProducer());
+ std::unique_ptr<GooString> goo_producer(d->doc->getDocInfoProducer());
if (!goo_producer.get()) {
return ustring();
}
@@ -696,7 +697,7 @@
return time_type(-1);
}
- std::auto_ptr<GooString> goo_creation_date(d->doc->getDocInfoCreatDate());
+ std::unique_ptr<GooString> goo_creation_date(d->doc->getDocInfoCreatDate());
if (!goo_creation_date.get()) {
return time_type(-1);
}
@@ -741,7 +742,7 @@
return time_type(-1);
}
- std::auto_ptr<GooString> goo_modification_date(d->doc->getDocInfoModDate());
+ std::unique_ptr<GooString> goo_modification_date(d->doc->getDocInfoModDate());
if (!goo_modification_date.get()) {
return time_type(-1);
}
@@ -840,7 +841,7 @@
*/
ustring document::metadata() const
{
- std::auto_ptr<GooString> md(d->doc->getCatalog()->readMetadata());
+ std::unique_ptr<GooString> md(d->doc->getCatalog()->readMetadata());
if (md.get()) {
return detail::unicode_GooString_to_ustring(md.get());
}
@@ -896,7 +897,7 @@
*/
page* document::create_page(const ustring &label) const
{
- std::auto_ptr<GooString> goolabel(detail::ustring_to_unicode_GooString(label));
+ std::unique_ptr<GooString> goolabel(detail::ustring_to_unicode_GooString(label));
int index = 0;
if (!d->doc->getCatalog()->labelToIndex(goolabel.get(), &index)) {
diff --git a/cpp/poppler-image.cpp b/cpp/poppler-image.cpp
index 23306df..359298c 100644
--- a/cpp/poppler-image.cpp
+++ b/cpp/poppler-image.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010-2011, Pino Toscano <pino@kde.org>
* Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
+ * Copyright (C) 2017, Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -115,7 +116,7 @@
return 0;
}
- std::auto_ptr<image_private> d(new image_private(width, height, format));
+ std::unique_ptr<image_private> d(new image_private(width, height, format));
d->bytes_num = bpr * height;
d->data = reinterpret_cast<char *>(std::malloc(d->bytes_num));
if (!d->data) {
@@ -138,13 +139,13 @@
return 0;
}
- std::auto_ptr<image_private> d(new image_private(width, height, format));
+ image_private *d = new image_private(width, height, format);
d->bytes_num = bpr * height;
d->data = data;
d->own_data = false;
d->bytes_per_row = bpr;
- return d.release();
+ return d;
}
/**
@@ -345,7 +346,7 @@
std::string fmt = out_format;
std::transform(fmt.begin(), fmt.end(), fmt.begin(), tolower);
- std::auto_ptr<ImgWriter> w;
+ std::unique_ptr<ImgWriter> w;
const int actual_dpi = dpi == -1 ? 75 : dpi;
if (false) {
}
diff --git a/cpp/poppler-page.cpp b/cpp/poppler-page.cpp
index d72a477..b8927b8 100644
--- a/cpp/poppler-page.cpp
+++ b/cpp/poppler-page.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009-2010, Pino Toscano <pino@kde.org>
+ * Copyright (C) 2017, Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -265,7 +266,7 @@
*/
ustring page::text(const rectf &r, text_layout_enum layout_mode) const
{
- std::auto_ptr<GooString> s;
+ std::unique_ptr<GooString> s;
const GBool use_raw_order = (layout_mode == raw_order_layout);
TextOutputDev td(0, gFalse, 0, use_raw_order, gFalse);
d->doc->doc->displayPage(&td, d->index + 1, 72, 72, 0, false, true, false);
diff --git a/cpp/tests/poppler-dump.cpp b/cpp/tests/poppler-dump.cpp
index c7ff349..1185971 100644
--- a/cpp/tests/poppler-dump.cpp
+++ b/cpp/tests/poppler-dump.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009-2010, Pino Toscano <pino@kde.org>
+ * Copyright (C) 2017, Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -333,7 +334,7 @@
std::string file_name(argv[1]);
- std::auto_ptr<poppler::document> doc(poppler::document::load_from_file(file_name));
+ std::unique_ptr<poppler::document> doc(poppler::document::load_from_file(file_name));
if (!doc.get()) {
error("loading error");
}
@@ -363,7 +364,7 @@
print_metadata(doc.get());
}
if (show_toc) {
- std::auto_ptr<poppler::toc> doctoc(doc->create_toc());
+ std::unique_ptr<poppler::toc> doctoc(doc->create_toc());
print_toc(doctoc.get());
}
if (show_fonts) {
@@ -376,7 +377,7 @@
const int pages = doc->pages();
for (int i = 0; i < pages; ++i) {
std::cout << "Page " << (i + 1) << "/" << pages << ":" << std::endl;
- std::auto_ptr<poppler::page> p(doc->create_page(i));
+ std::unique_ptr<poppler::page> p(doc->create_page(i));
print_page(p.get());
}
}
@@ -384,7 +385,7 @@
const int pages = doc->pages();
for (int i = 0; i < pages; ++i) {
std::cout << "Page " << (i + 1) << "/" << pages << ":" << std::endl;
- std::auto_ptr<poppler::page> p(doc->create_page(i));
+ std::unique_ptr<poppler::page> p(doc->create_page(i));
print_page_text(p.get());
}
}
diff --git a/cpp/tests/poppler-render.cpp b/cpp/tests/poppler-render.cpp
index b440dd4..7cc7ca2 100644
--- a/cpp/tests/poppler-render.cpp
+++ b/cpp/tests/poppler-render.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010, Pino Toscano <pino@kde.org>
+ * Copyright (C) 2017, Albert Astals Cid <aacid@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -80,7 +81,7 @@
const std::string file_name(argv[1]);
- std::auto_ptr<poppler::document> doc(poppler::document::load_from_file(file_name));
+ std::unique_ptr<poppler::document> doc(poppler::document::load_from_file(file_name));
if (!doc.get()) {
error("loading error");
}
@@ -91,7 +92,7 @@
if (doc_page < 0 || doc_page >= doc->pages()) {
error("specified page number out of page count");
}
- std::auto_ptr<poppler::page> p(doc->create_page(doc_page));
+ std::unique_ptr<poppler::page> p(doc->create_page(doc_page));
if (!p.get()) {
error("NULL page");
}
diff --git a/qt4/tests/check_fonts.cpp b/qt4/tests/check_fonts.cpp
index 267595d..77579a9 100644
--- a/qt4/tests/check_fonts.cpp
+++ b/qt4/tests/check_fonts.cpp
@@ -23,7 +23,7 @@
{
int num = count == -1 ? doc->numPages() - from : count;
QList<Poppler::FontInfo> list;
- std::auto_ptr< Poppler::FontIterator > it( doc->newFontIterator( from ) );
+ std::unique_ptr< Poppler::FontIterator > it( doc->newFontIterator( from ) );
while ( it->hasNext() && num )
{
list += it->next();
@@ -142,7 +142,7 @@
Poppler::Document *doc6 = Poppler::Document::load(TESTDATADIR "/tests/cropbox.pdf");
QVERIFY( doc6 );
- std::auto_ptr< Poppler::FontIterator > it;
+ std::unique_ptr< Poppler::FontIterator > it;
// some tests with the 1-page document:
// - check a default iterator
diff --git a/qt4/tests/check_links.cpp b/qt4/tests/check_links.cpp
index d4e7f03..5b6cc59 100644
--- a/qt4/tests/check_links.cpp
+++ b/qt4/tests/check_links.cpp
@@ -30,7 +30,7 @@
doc = Poppler::Document::load(TESTDATADIR "/unittestcases/WithAttachments.pdf");
QVERIFY( doc );
- std::auto_ptr< Poppler::LinkDestination > dest;
+ std::unique_ptr< Poppler::LinkDestination > dest;
dest.reset( doc->linkDestination("no.dests.in.this.document") );
QVERIFY( !isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( isDestinationValid_name( dest.get() ) );
@@ -79,7 +79,7 @@
doc = Poppler::Document::load(TESTDATADIR "/unittestcases/xr02.pdf");
QVERIFY( doc );
- std::auto_ptr< Poppler::LinkDestination > dest;
+ std::unique_ptr< Poppler::LinkDestination > dest;
dest.reset( doc->linkDestination("section.1") );
QVERIFY( isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( !isDestinationValid_name( dest.get() ) );
diff --git a/qt5/tests/check_fonts.cpp b/qt5/tests/check_fonts.cpp
index 5d3c38e..ad4b0b8 100644
--- a/qt5/tests/check_fonts.cpp
+++ b/qt5/tests/check_fonts.cpp
@@ -23,7 +23,7 @@
{
int num = count == -1 ? doc->numPages() - from : count;
QList<Poppler::FontInfo> list;
- std::auto_ptr< Poppler::FontIterator > it( doc->newFontIterator( from ) );
+ std::unique_ptr< Poppler::FontIterator > it( doc->newFontIterator( from ) );
while ( it->hasNext() && num )
{
list += it->next();
@@ -142,7 +142,7 @@
Poppler::Document *doc6 = Poppler::Document::load(TESTDATADIR "/tests/cropbox.pdf");
QVERIFY( doc6 );
- std::auto_ptr< Poppler::FontIterator > it;
+ std::unique_ptr< Poppler::FontIterator > it;
// some tests with the 1-page document:
// - check a default iterator
diff --git a/qt5/tests/check_links.cpp b/qt5/tests/check_links.cpp
index 7a39838..cce13ec 100644
--- a/qt5/tests/check_links.cpp
+++ b/qt5/tests/check_links.cpp
@@ -30,7 +30,7 @@
doc = Poppler::Document::load(TESTDATADIR "/unittestcases/WithAttachments.pdf");
QVERIFY( doc );
- std::auto_ptr< Poppler::LinkDestination > dest;
+ std::unique_ptr< Poppler::LinkDestination > dest;
dest.reset( doc->linkDestination("no.dests.in.this.document") );
QVERIFY( !isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( isDestinationValid_name( dest.get() ) );
@@ -79,7 +79,7 @@
doc = Poppler::Document::load(TESTDATADIR "/unittestcases/xr02.pdf");
QVERIFY( doc );
- std::auto_ptr< Poppler::LinkDestination > dest;
+ std::unique_ptr< Poppler::LinkDestination > dest;
dest.reset( doc->linkDestination("section.1") );
QVERIFY( isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( !isDestinationValid_name( dest.get() ) );