Use template function to avoid code duplication in wxRegConfig
Don't repeat exactly the same code for 3 different types, just use a template function instead. Change the existing TryGetValue() helpers to take all output parameters consistently by pointer, rather than taking only long by pointer and the other by reference. This allows to isolate the inconsistency of the type of wxRegKey::QueryValue() parameter in a single place here, hiding it from the rest of wxRegConfig code. Add an extra unit test for writing/reading longs to/from wxRegConfig.
This commit is contained in:
@@ -88,6 +88,12 @@ protected:
|
||||
return self->m_keyLocal;
|
||||
}
|
||||
|
||||
// Type-independent implementation of Do{Read,Write}Foo().
|
||||
template <typename T>
|
||||
bool DoReadValue(const wxString& key, T* pValue) const;
|
||||
template <typename T>
|
||||
bool DoWriteValue(const wxString& key, const T& value);
|
||||
|
||||
// implement read/write methods
|
||||
virtual bool DoReadString(const wxString& key, wxString *pStr) const wxOVERRIDE;
|
||||
virtual bool DoReadLong(const wxString& key, long *plResult) const wxOVERRIDE;
|
||||
|
Reference in New Issue
Block a user