Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: core/fpdfdoc/cpvt_sectioninfo.h

Issue 2136683002: Use smart pointers for class owned member variables (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_variabletext.cpp ('k') | core/fpdfdoc/cpvt_sectioninfo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FPDFDOC_CPVT_SECTIONINFO_H_ 7 #ifndef CORE_FPDFDOC_CPVT_SECTIONINFO_H_
8 #define CORE_FPDFDOC_CPVT_SECTIONINFO_H_ 8 #define CORE_FPDFDOC_CPVT_SECTIONINFO_H_
9 9
10 #include <memory>
11
10 #include "core/fpdfdoc/cpvt_floatrect.h" 12 #include "core/fpdfdoc/cpvt_floatrect.h"
11 #include "core/fpdfdoc/include/cpvt_secprops.h" 13 #include "core/fpdfdoc/include/cpvt_secprops.h"
12 #include "core/fpdfdoc/include/cpvt_wordprops.h" 14 #include "core/fpdfdoc/include/cpvt_wordprops.h"
13 15
14 struct CPVT_SectionInfo { 16 struct CPVT_SectionInfo {
15 CPVT_SectionInfo() 17 CPVT_SectionInfo();
16 : rcSection(), nTotalLine(0), pSecProps(nullptr), pWordProps(nullptr) {} 18 CPVT_SectionInfo(const CPVT_SectionInfo& other);
19 ~CPVT_SectionInfo();
17 20
18 ~CPVT_SectionInfo() { 21 void operator=(const CPVT_SectionInfo& other);
19 delete pSecProps;
20 delete pWordProps;
21 }
22
23 CPVT_SectionInfo(const CPVT_SectionInfo& other)
24 : rcSection(), nTotalLine(0), pSecProps(nullptr), pWordProps(nullptr) {
25 operator=(other);
26 }
27
28 void operator=(const CPVT_SectionInfo& other) {
29 if (this == &other)
30 return;
31
32 rcSection = other.rcSection;
33 nTotalLine = other.nTotalLine;
34 if (other.pSecProps) {
35 if (pSecProps)
36 *pSecProps = *other.pSecProps;
37 else
38 pSecProps = new CPVT_SecProps(*other.pSecProps);
39 }
40 if (other.pWordProps) {
41 if (pWordProps)
42 *pWordProps = *other.pWordProps;
43 else
44 pWordProps = new CPVT_WordProps(*other.pWordProps);
45 }
46 }
47 22
48 CPVT_FloatRect rcSection; 23 CPVT_FloatRect rcSection;
49 int32_t nTotalLine; 24 int32_t nTotalLine;
50 CPVT_SecProps* pSecProps; 25 std::unique_ptr<CPVT_SecProps> pSecProps;
51 CPVT_WordProps* pWordProps; 26 std::unique_ptr<CPVT_WordProps> pWordProps;
52 }; 27 };
53 28
54 #endif // CORE_FPDFDOC_CPVT_SECTIONINFO_H_ 29 #endif // CORE_FPDFDOC_CPVT_SECTIONINFO_H_
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_variabletext.cpp ('k') | core/fpdfdoc/cpvt_sectioninfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698