[poppler] cpp/poppler-document.cpp cpp/poppler-image.cpp cpp/poppler-page.cpp cpp/tests qt4/tests qt5/tests
Albert Astals Cid
aacid at kemper.freedesktop.org
Fri May 5 13:13:04 UTC 2017
cpp/poppler-document.cpp | 25 +++++++++++++------------
cpp/poppler-image.cpp | 9 +++++----
cpp/poppler-page.cpp | 3 ++-
cpp/tests/poppler-dump.cpp | 9 +++++----
cpp/tests/poppler-render.cpp | 5 +++--
qt4/tests/check_fonts.cpp | 4 ++--
qt4/tests/check_links.cpp | 4 ++--
qt5/tests/check_fonts.cpp | 4 ++--
qt5/tests/check_links.cpp | 4 ++--
9 files changed, 36 insertions(+), 31 deletions(-)
New commits:
commit d73bcd3721f3b53bb97241cc53a6abf807aff782
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri May 5 15:12:42 2017 +0200
auto_ptr -> unique_ptr
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index 62e0a997..35bbfa2a 100644
--- a/cpp/poppler-document.cpp
+++ b/cpp/poppler-document.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2009-2011, Pino Toscano <pino at kde.org>
* Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
+ * Copyright (C) 2017, Albert Astals Cid <aacid at 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 @@ ustring document::info_key(const std::string &key) const
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 @@ time_type document::info_date(const std::string &key) const
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 @@ ustring document::get_title() const
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 @@ ustring document::get_author() const
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 @@ ustring document::get_subject() const
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 @@ ustring document::get_keywords() const
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 @@ ustring document::get_creator() const
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 @@ ustring document::get_producer() const
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 @@ time_type document::get_creation_date() const
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 @@ time_type document::get_modification_date() const
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 @@ bool document::has_permission(permission_enum which) const
*/
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 @@ int document::pages() const
*/
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 23306dfb..359298c7 100644
--- a/cpp/poppler-image.cpp
+++ b/cpp/poppler-image.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010-2011, Pino Toscano <pino at kde.org>
* Copyright (C) 2013 Adrian Johnson <ajohnson at redneon.com>
+ * Copyright (C) 2017, Albert Astals Cid <aacid at 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 @@ image_private *image_private::create_data(int width, int height, image::format_e
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 @@ image_private *image_private::create_data(char *data, int width, int height, ima
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 @@ bool image::save(const std::string &file_name, const std::string &out_format, in
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 d72a4776..b8927b80 100644
--- a/cpp/poppler-page.cpp
+++ b/cpp/poppler-page.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009-2010, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2017, Albert Astals Cid <aacid at 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) const
*/
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 c7ff349c..1185971b 100644
--- a/cpp/tests/poppler-dump.cpp
+++ b/cpp/tests/poppler-dump.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009-2010, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2017, Albert Astals Cid <aacid at 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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 b440dd45..7cc7ca2d 100644
--- a/cpp/tests/poppler-render.cpp
+++ b/cpp/tests/poppler-render.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2017, Albert Astals Cid <aacid at 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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 267595df..77579a97 100644
--- a/qt4/tests/check_fonts.cpp
+++ b/qt4/tests/check_fonts.cpp
@@ -23,7 +23,7 @@ static QList<Poppler::FontInfo> loadFontsViaIterator( Poppler::Document *doc, in
{
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 @@ void TestFontsData::checkFontIterator()
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 d4e7f031..5b6cc59e 100644
--- a/qt4/tests/check_links.cpp
+++ b/qt4/tests/check_links.cpp
@@ -30,7 +30,7 @@ void TestLinks::checkDocumentWithNoDests()
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 @@ void TestLinks::checkDests_xr02()
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 5d3c38e9..ad4b0b88 100644
--- a/qt5/tests/check_fonts.cpp
+++ b/qt5/tests/check_fonts.cpp
@@ -23,7 +23,7 @@ static QList<Poppler::FontInfo> loadFontsViaIterator( Poppler::Document *doc, in
{
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 @@ void TestFontsData::checkFontIterator()
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 7a398387..cce13ec6 100644
--- a/qt5/tests/check_links.cpp
+++ b/qt5/tests/check_links.cpp
@@ -30,7 +30,7 @@ void TestLinks::checkDocumentWithNoDests()
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 @@ void TestLinks::checkDests_xr02()
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() ) );
More information about the poppler
mailing list