Add support for reading multi string values to wxRegKey.
Add a wxRegKey::QueryValue() overload working with REG_MULTI_SZ values. Closes #16653. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78136 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -970,7 +970,38 @@ bool wxRegKey::QueryValue(const wxString& szValue, wxMemoryBuffer& buffer) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxRegKey::QueryValue(const wxString& szValue, wxArrayString &names,
|
||||
wxArrayString &values) const
|
||||
{
|
||||
// Make sure value is a multistring.
|
||||
wxASSERT_MSG(GetValueType (szValue) == Type_Multi_String,
|
||||
wxT("Type mismatch in wxRegKey::QueryValue()."));
|
||||
|
||||
wxMemoryBuffer buf;
|
||||
if ( !QueryValue (szValue, buf) )
|
||||
return false;
|
||||
|
||||
wxChar * const data = static_cast<wxChar *>(buf.GetData());
|
||||
|
||||
// Parse the list of NUL-separated strings of the form "name=value".
|
||||
size_t begin = 0;
|
||||
for ( size_t i = 0; i < buf.GetDataLen() - 1; i++ )
|
||||
{
|
||||
if ( data[i] == 0 )
|
||||
{
|
||||
if ( i > begin )
|
||||
{
|
||||
wxString value;
|
||||
names.Add(wxString(&data[begin]).BeforeFirst('=', &value));
|
||||
values.Add(value);
|
||||
}
|
||||
|
||||
begin = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxRegKey::QueryValue(const wxString& szValue,
|
||||
wxString& strValue,
|
||||
|
||||
Reference in New Issue
Block a user