From e08d2b1fee0db40bac9538ca8b7be0a951675bd6 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 25 Apr 2018 18:49:32 +0000 Subject: Introduce ScopedFPDF types in public/cpp/fpdf_scopers.h Applies std::remove_ptr to the public API types so that we can deduce a correct unique ptr type no matter how that API might change away from void* usage. Creates shorter names for std::unique_ptr, ...> Change-Id: I04a0ff43cb7d5a4d3867939a53a54c9cef00db86 Reviewed-on: https://pdfium-review.googlesource.com/31292 Reviewed-by: Lei Zhang Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- public/cpp/fpdf_scopers.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 public/cpp/fpdf_scopers.h (limited to 'public') diff --git a/public/cpp/fpdf_scopers.h b/public/cpp/fpdf_scopers.h new file mode 100644 index 0000000000..1898ac887d --- /dev/null +++ b/public/cpp/fpdf_scopers.h @@ -0,0 +1,54 @@ +// Copyright 2018 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_CPP_FPDF_SCOPERS_H_ +#define PUBLIC_CPP_FPDF_SCOPERS_H_ + +#include +#include + +#include "public/cpp/fpdf_deleters.h" +#include "public/fpdf_annot.h" +#include "public/fpdf_dataavail.h" +#include "public/fpdf_edit.h" +#include "public/fpdf_formfill.h" +#include "public/fpdf_structtree.h" +#include "public/fpdf_text.h" +#include "public/fpdfview.h" + +// Versions of FPDF types that clean up the object at scope exit. + +using ScopedFPDFAnnotation = + std::unique_ptr::type, + FPDFAnnotationDeleter>; + +using ScopedFPDFAvail = + std::unique_ptr::type, FPDFAvailDeleter>; + +using ScopedFPDFBitmap = + std::unique_ptr::type, FPDFBitmapDeleter>; + +using ScopedFPDFDocument = + std::unique_ptr::type, + FPDFDocumentDeleter>; + +using ScopedFPDFFormHandle = + std::unique_ptr::type, + FPDFFormHandleDeleter>; + +using ScopedFPDFTextPage = + std::unique_ptr::type, + FPDFTextPageDeleter>; + +using ScopedFPDFPage = + std::unique_ptr::type, FPDFPageDeleter>; + +using ScopedFPDFStructTree = + std::unique_ptr::type, + FPDFStructTreeDeleter>; + +using ScopedFPDFFont = + std::unique_ptr::type, FPDFFontDeleter>; + +#endif // PUBLIC_CPP_FPDF_SCOPERS_H_ -- cgit v1.2.3