Skip to content

Commit bf9e7e8

Browse files
authored
Refactor pimpl pointers in XMLSchemaComplexTypeGenerator and XMLValidator to unique_ptr (#661)
## Summary - Replace raw `class Impl*` pimpl members with `std::unique_ptr<class Impl>` in `XMLSchemaComplexTypeGenerator` and `XMLValidator` - Destructors changed from `{ delete pimpl_; }` to `= default`, letting the compiler generate correct cleanup - Added `#include <memory>` to both headers ## Motivation Both classes already correctly suppressed copy/move with `= delete`, so there was no double-free risk. This refactor makes ownership explicit in the type system and eliminates manual `delete` calls, following the Rule of Zero pattern for pimpl idiom. ## Testing Full debug build succeeds. No behavior change — pure ownership semantics refactor.
1 parent b8e64ec commit bf9e7e8

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

source/src/utility/tag/XMLSchemaGeneration.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ XMLSchemaParticleOP XMLSchemaComplexTypeGeneratorImpl::create_subelement(
20512051
}
20522052

20532053
XMLSchemaComplexTypeGenerator::XMLSchemaComplexTypeGenerator() : pimpl_( new XMLSchemaComplexTypeGeneratorImpl ) {}
2054-
XMLSchemaComplexTypeGenerator::~XMLSchemaComplexTypeGenerator() { delete pimpl_; }
2054+
XMLSchemaComplexTypeGenerator::~XMLSchemaComplexTypeGenerator() = default;
20552055
//XMLSchemaComplexTypeGenerator::XMLSchemaComplexTypeGenerator( XMLSchemaComplexTypeGenerator const & src ) :
20562056
// pimpl_( new XMLSchemaComplexTypeGeneratorImpl( *src.pimpl_ ))
20572057
//{

source/src/utility/tag/XMLSchemaGeneration.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117

118118
// Boost headers
119119
#include <functional>
120+
#include <memory>
120121

121122
// LibXML includes
122123

@@ -969,7 +970,7 @@ public:
969970

970971

971972
private:
972-
class XMLSchemaComplexTypeGeneratorImpl * pimpl_;
973+
std::unique_ptr< class XMLSchemaComplexTypeGeneratorImpl > pimpl_;
973974

974975
};
975976

source/src/utility/tag/XMLSchemaValidation.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class XMLValidatorImpl {
425425

426426

427427
XMLValidator::XMLValidator() : pimpl_( new XMLValidatorImpl() ) {}
428-
XMLValidator::~XMLValidator() { delete pimpl_; }
428+
XMLValidator::~XMLValidator() = default;
429429

430430
bool
431431
XMLValidator::schema_has_been_set() const

source/src/utility/tag/XMLSchemaValidation.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
// C++ headers
3030
#include <list>
31+
#include <memory>
3132
#include <string>
3233
//#include <vector>
3334
//#include <map>
@@ -84,7 +85,7 @@ private:
8485
XMLValidator( XMLValidator const & ) = delete;
8586
XMLValidator & operator = ( XMLValidator const & rhs ) = delete;
8687

87-
class XMLValidatorImpl * pimpl_;
88+
std::unique_ptr< class XMLValidatorImpl > pimpl_;
8889
};
8990

9091
class XMLValidationOutput

0 commit comments

Comments
 (0)