Refactor wxSecretValue creation

No real changes, just add a new platform-specific NewImpl() method instead of
making wxSecretValue ctor itself platform-specific.

This makes adding other ctors for this class simpler.
This commit is contained in:
Vadim Zeitlin 2016-06-04 18:46:23 +02:00
parent 675d9d779d
commit 1de80a72d9
4 changed files with 17 additions and 7 deletions

View File

@ -30,7 +30,10 @@ public:
wxSecretValue() : m_impl(NULL) { }
// Creates a secret value from the given data.
wxSecretValue(size_t size, const void *data);
wxSecretValue(size_t size, const void *data)
: m_impl(NewImpl(size, data))
{
}
wxSecretValue(const wxSecretValue& other);
wxSecretValue& operator=(const wxSecretValue& other);
@ -60,6 +63,10 @@ public:
static void Wipe(size_t size, void *data);
private:
// This method is implemented in platform-specific code and must return a
// new heap-allocated object initialized with the given data.
static wxSecretValueImpl* NewImpl(size_t size, const void *data);
// This ctor is only used by wxSecretStore and takes ownership of the
// provided existing impl pointer.
explicit wxSecretValue(wxSecretValueImpl* impl) : m_impl(impl) { }

View File

@ -155,9 +155,10 @@ private:
// MSW-specific implementation of common methods
// ============================================================================
wxSecretValue::wxSecretValue(size_t size, const void *data)
: m_impl(new wxSecretValueGenericImpl(size, data))
/* static */
wxSecretValueImpl* wxSecretValue::NewImpl(size_t size, const void *data)
{
return new wxSecretValueGenericImpl(size, data);
}
/* static */

View File

@ -231,9 +231,10 @@ private:
// OSX-specific implementation of common methods
// ============================================================================
wxSecretValue::wxSecretValue(size_t size, const void *data)
: m_impl(new wxSecretValueGenericImpl(size, data))
/* static */
wxSecretValueImpl* wxSecretValue::NewImpl(size_t size, const void *data)
{
return new wxSecretValueGenericImpl(size, data);
}
/* static */

View File

@ -251,9 +251,10 @@ const char* wxSecretStoreLibSecretImpl::FIELD_USER = "user";
// LibSecret-specific implementation of common methods
// ============================================================================
wxSecretValue::wxSecretValue(size_t size, const void *data)
: m_impl(new wxSecretValueLibSecretImpl(size, data))
/* static */
wxSecretValueImpl* wxSecretValue::NewImpl(size_t size, const void *data)
{
return new wxSecretValueLibSecretImpl(size, data);
}
/* static */