• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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_DELETERS_H_
6 #define PUBLIC_CPP_FPDF_DELETERS_H_
7 
8 #include "public/fpdf_dataavail.h"
9 #include "public/fpdf_edit.h"
10 #include "public/fpdf_formfill.h"
11 #include "public/fpdf_structtree.h"
12 #include "public/fpdf_text.h"
13 #include "public/fpdfview.h"
14 
15 // Custom deleters for using FPDF_* types with std::unique_ptr<>.
16 
17 struct FPDFAvailDeleter {
operatorFPDFAvailDeleter18   inline void operator()(FPDF_AVAIL avail) { FPDFAvail_Destroy(avail); }
19 };
20 
21 struct FPDFBitmapDeleter {
operatorFPDFBitmapDeleter22   inline void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); }
23 };
24 
25 struct FPDFDocumentDeleter {
operatorFPDFDocumentDeleter26   inline void operator()(FPDF_DOCUMENT doc) { FPDF_CloseDocument(doc); }
27 };
28 
29 struct FPDFFormHandleDeleter {
operatorFPDFFormHandleDeleter30   inline void operator()(FPDF_FORMHANDLE form) {
31     FPDFDOC_ExitFormFillEnvironment(form);
32   }
33 };
34 
35 struct FPDFTextPageDeleter {
operatorFPDFTextPageDeleter36   inline void operator()(FPDF_TEXTPAGE text) { FPDFText_ClosePage(text); }
37 };
38 
39 struct FPDFPageDeleter {
operatorFPDFPageDeleter40   inline void operator()(FPDF_PAGE page) { FPDF_ClosePage(page); }
41 };
42 
43 struct FPDFStructTreeDeleter {
operatorFPDFStructTreeDeleter44   inline void operator()(FPDF_STRUCTTREE tree) { FPDF_StructTree_Close(tree); }
45 };
46 
47 struct FPDFFontDeleter {
operatorFPDFFontDeleter48   inline void operator()(FPDF_FONT font) { FPDFFont_Close(font); }
49 };
50 
51 #endif  // PUBLIC_CPP_FPDF_DELETERS_H_
52