Merge branch 'config-size_t'

Add support for 64-bit numbers and size_t to wxConfig.

See https://github.com/wxWidgets/wxWidgets/pull/2272
This commit is contained in:
Vadim Zeitlin
2021-03-13 22:35:01 +01:00
22 changed files with 743 additions and 575 deletions

View File

@@ -186,6 +186,15 @@ public:
bool Read(const wxString& key, bool* val) const;
bool Read(const wxString& key, bool* val, bool defVal) const;
// read a 64-bit number when long is 32 bits
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Read(const wxString& key, wxLongLong_t *pl) const;
bool Read(const wxString& key, wxLongLong_t *pl, wxLongLong_t defVal) const;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Read(const wxString& key, size_t* val) const;
bool Read(const wxString& key, size_t* val, size_t defVal) const;
#if wxUSE_BASE64
// read a binary data block
bool Read(const wxString& key, wxMemoryBuffer* data) const
@@ -235,6 +244,9 @@ public:
long ReadLong(const wxString& key, long defVal) const
{ long l; (void)Read(key, &l, defVal); return l; }
wxLongLong_t ReadLongLong(const wxString& key, wxLongLong_t defVal) const
{ wxLongLong_t ll; (void)Read(key, &ll, defVal); return ll; }
double ReadDouble(const wxString& key, double defVal) const
{ double d; (void)Read(key, &d, defVal); return d; }
@@ -304,6 +316,14 @@ public:
bool Write(const wxString& key, unsigned long value)
{ return DoWriteLong(key, value); }
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Write(const wxString& key, wxLongLong_t value)
{ return DoWriteLongLong(key, value); }
bool Write(const wxString& key, wxULongLong_t value)
{ return DoWriteLongLong(key, value); }
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Write(const wxString& key, float value)
{ return DoWriteDouble(key, double(value)); }
@@ -374,6 +394,9 @@ protected:
// do read/write the values of different types
virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0;
virtual bool DoReadLong(const wxString& key, long *pl) const = 0;
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoReadLongLong(const wxString& key, wxLongLong_t *pll) const = 0;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoReadDouble(const wxString& key, double* val) const;
virtual bool DoReadBool(const wxString& key, bool* val) const;
#if wxUSE_BASE64
@@ -382,6 +405,9 @@ protected:
virtual bool DoWriteString(const wxString& key, const wxString& value) = 0;
virtual bool DoWriteLong(const wxString& key, long value) = 0;
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoWriteLongLong(const wxString& key, wxLongLong_t value) = 0;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoWriteDouble(const wxString& key, double value);
virtual bool DoWriteBool(const wxString& key, bool value);
#if wxUSE_BASE64

View File

@@ -196,12 +196,18 @@ public:
protected:
virtual bool DoReadString(const wxString& key, wxString *pStr) const wxOVERRIDE;
virtual bool DoReadLong(const wxString& key, long *pl) const wxOVERRIDE;
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoReadLongLong(const wxString& key, wxLongLong_t *pll) const wxOVERRIDE;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
#if wxUSE_BASE64
virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const wxOVERRIDE;
#endif // wxUSE_BASE64
virtual bool DoWriteString(const wxString& key, const wxString& szValue) wxOVERRIDE;
virtual bool DoWriteLong(const wxString& key, long lValue) wxOVERRIDE;
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoWriteLongLong(const wxString& key, wxLongLong_t value) wxOVERRIDE;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
#if wxUSE_BASE64
virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) wxOVERRIDE;
#endif // wxUSE_BASE64

View File

@@ -88,15 +88,23 @@ 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;
virtual bool DoReadLongLong(const wxString& key, wxLongLong_t *pll) const wxOVERRIDE;
#if wxUSE_BASE64
virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const wxOVERRIDE;
#endif // wxUSE_BASE64
virtual bool DoWriteString(const wxString& key, const wxString& szValue) wxOVERRIDE;
virtual bool DoWriteLong(const wxString& key, long lValue) wxOVERRIDE;
virtual bool DoWriteLongLong(const wxString& key, wxLongLong_t llValue) wxOVERRIDE;
#if wxUSE_BASE64
virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) wxOVERRIDE;
#endif // wxUSE_BASE64

View File

@@ -42,7 +42,8 @@ public:
Type_Multi_String, // Multiple Unicode strings
Type_Resource_list, // Resource list in the resource map
Type_Full_resource_descriptor, // Resource list in the hardware description
Type_Resource_requirements_list // ???
Type_Resource_requirements_list, // ???
Type_Qword // 64-bit number
};
// predefined registry keys
@@ -197,10 +198,14 @@ public:
// retrieve either raw or expanded string value
bool QueryValue(const wxString& szValue, wxString& strValue, bool raw) const;
// set the numeric value
// set the 32-bit numeric value
bool SetValue(const wxString& szValue, long lValue);
// return the numeric value
// return the 32-bit numeric value
bool QueryValue(const wxString& szValue, long *plValue) const;
// set the 64-bit numeric value
bool SetValue64(const wxString& szValue, wxLongLong_t llValue);
// return the 64-bit numeric value
bool QueryValue64(const wxString& szValue, wxLongLong_t *pllValue) const;
// set the binary value
bool SetValue(const wxString& szValue, const wxMemoryBuffer& buf);
// return the binary value