diff options
author | Albert Astals Cid <aacid@kde.org> | 2017-05-05 15:12:42 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2017-05-05 15:12:42 +0200 |
commit | d73bcd3721f3b53bb97241cc53a6abf807aff782 (patch) | |
tree | 32ef3e45ae9fddbdd648fad2666a01c74c6dafbf /cpp | |
parent | 9ad9d92591a6389f84919ff2de3668c2b6158dc9 (diff) |
auto_ptr -> unique_ptr
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/poppler-document.cpp | 25 | ||||
-rw-r--r-- | cpp/poppler-image.cpp | 9 | ||||
-rw-r--r-- | cpp/poppler-page.cpp | 3 | ||||
-rw-r--r-- | cpp/tests/poppler-dump.cpp | 9 | ||||
-rw-r--r-- | cpp/tests/poppler-render.cpp | 5 |
5 files changed, 28 insertions, 23 deletions
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@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 @@ 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@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 @@ 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@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) 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@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 @@ 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@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 @@ 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"); } |