1 // Copyright 2018 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PUBLIC_CPP_FPDF_SCOPERS_H_ 6 #define PUBLIC_CPP_FPDF_SCOPERS_H_ 7 8 #include <memory> 9 #include <type_traits> 10 11 #include "public/cpp/fpdf_deleters.h" 12 13 // Versions of FPDF types that clean up the object at scope exit. 14 15 using ScopedFPDFAnnotation = 16 std::unique_ptr<std::remove_pointer<FPDF_ANNOTATION>::type, 17 FPDFAnnotationDeleter>; 18 19 using ScopedFPDFAvail = 20 std::unique_ptr<std::remove_pointer<FPDF_AVAIL>::type, FPDFAvailDeleter>; 21 22 using ScopedFPDFBitmap = 23 std::unique_ptr<std::remove_pointer<FPDF_BITMAP>::type, FPDFBitmapDeleter>; 24 25 using ScopedFPDFClipPath = 26 std::unique_ptr<std::remove_pointer<FPDF_CLIPPATH>::type, 27 FPDFClipPathDeleter>; 28 29 using ScopedFPDFDocument = 30 std::unique_ptr<std::remove_pointer<FPDF_DOCUMENT>::type, 31 FPDFDocumentDeleter>; 32 33 using ScopedFPDFFont = 34 std::unique_ptr<std::remove_pointer<FPDF_FONT>::type, FPDFFontDeleter>; 35 36 using ScopedFPDFFormHandle = 37 std::unique_ptr<std::remove_pointer<FPDF_FORMHANDLE>::type, 38 FPDFFormHandleDeleter>; 39 40 using ScopedFPDFJavaScriptAction = 41 std::unique_ptr<std::remove_pointer<FPDF_JAVASCRIPT_ACTION>::type, 42 FPDFJavaScriptActionDeleter>; 43 44 using ScopedFPDFPage = 45 std::unique_ptr<std::remove_pointer<FPDF_PAGE>::type, FPDFPageDeleter>; 46 47 using ScopedFPDFPageLink = 48 std::unique_ptr<std::remove_pointer<FPDF_PAGELINK>::type, 49 FPDFPageLinkDeleter>; 50 51 using ScopedFPDFPageObject = 52 std::unique_ptr<std::remove_pointer<FPDF_PAGEOBJECT>::type, 53 FPDFPageObjectDeleter>; 54 55 using ScopedFPDFStructTree = 56 std::unique_ptr<std::remove_pointer<FPDF_STRUCTTREE>::type, 57 FPDFStructTreeDeleter>; 58 59 using ScopedFPDFTextFind = 60 std::unique_ptr<std::remove_pointer<FPDF_SCHHANDLE>::type, 61 FPDFTextFindDeleter>; 62 63 using ScopedFPDFTextPage = 64 std::unique_ptr<std::remove_pointer<FPDF_TEXTPAGE>::type, 65 FPDFTextPageDeleter>; 66 67 #endif // PUBLIC_CPP_FPDF_SCOPERS_H_ 68