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:
parent
69e00f892c
commit
89738ef01f
@ -116,6 +116,7 @@ wxMSW:
|
|||||||
- Implement wxListBox::EnsureVisible() (RIVDSL).
|
- Implement wxListBox::EnsureVisible() (RIVDSL).
|
||||||
- Drastically improve efficiency of selecting all items in wxDataViewCtrl.
|
- Drastically improve efficiency of selecting all items in wxDataViewCtrl.
|
||||||
- Fix wxMenuEvent::GetMenu() for wxEVT_MENU_{OPEN,CLOSE} in MDI frames.
|
- Fix wxMenuEvent::GetMenu() for wxEVT_MENU_{OPEN,CLOSE} in MDI frames.
|
||||||
|
- Added support for reading multi string values to wxRegKey (Carl Godkin).
|
||||||
|
|
||||||
wxOSX/Cocoa:
|
wxOSX/Cocoa:
|
||||||
|
|
||||||
|
@ -205,6 +205,10 @@ public:
|
|||||||
bool SetValue(const wxString& szValue, const wxMemoryBuffer& buf);
|
bool SetValue(const wxString& szValue, const wxMemoryBuffer& buf);
|
||||||
// return the binary value
|
// return the binary value
|
||||||
bool QueryValue(const wxString& szValue, wxMemoryBuffer& buf) const;
|
bool QueryValue(const wxString& szValue, wxMemoryBuffer& buf) const;
|
||||||
|
// return multiple strings
|
||||||
|
bool QueryValue(const wxString& szValue,
|
||||||
|
wxArrayString& names,
|
||||||
|
wxArrayString& values) const;
|
||||||
|
|
||||||
// query existence of a key/value
|
// query existence of a key/value
|
||||||
// return true if value exists
|
// return true if value exists
|
||||||
|
@ -355,6 +355,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool QueryValue(const wxString& szValue, wxMemoryBuffer& buf) const;
|
bool QueryValue(const wxString& szValue, wxMemoryBuffer& buf) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieves a multiple string value.
|
||||||
|
|
||||||
|
The @a szValue must exist and have @c REG_MULTI_SZ type. The names and
|
||||||
|
the values of the pairs present in it are returned in the @a names and
|
||||||
|
@a value arrays, which will have the same (possible 0) size.
|
||||||
|
|
||||||
|
@since 3.1.0
|
||||||
|
*/
|
||||||
|
bool QueryValue(const wxString& szValue,
|
||||||
|
wxArrayString& names,
|
||||||
|
wxArrayString& values) const;
|
||||||
/**
|
/**
|
||||||
Renames the key. Returns @true if successful.
|
Renames the key. Returns @true if successful.
|
||||||
*/
|
*/
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
|
|
||||||
// information
|
// information
|
||||||
bool IsKeySelected() const;
|
bool IsKeySelected() const;
|
||||||
|
static const char *ValueTypeName(wxRegKey::ValueType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// structure describing a registry key/value
|
// structure describing a registry key/value
|
||||||
@ -1054,7 +1055,6 @@ bool RegTreeCtrl::TreeNode::OnExpand()
|
|||||||
{
|
{
|
||||||
case wxRegKey::Type_String:
|
case wxRegKey::Type_String:
|
||||||
case wxRegKey::Type_Expand_String:
|
case wxRegKey::Type_Expand_String:
|
||||||
case wxRegKey::Type_Multi_String:
|
|
||||||
{
|
{
|
||||||
wxString strValue;
|
wxString strValue;
|
||||||
icon = RegImageList::TextValue;
|
icon = RegImageList::TextValue;
|
||||||
@ -1063,6 +1063,22 @@ bool RegTreeCtrl::TreeNode::OnExpand()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case wxRegKey::Type_Multi_String:
|
||||||
|
{
|
||||||
|
wxArrayString names, values;
|
||||||
|
m_pKey->QueryValue(str, names, values);
|
||||||
|
strItem += "(multi string) ";
|
||||||
|
for ( size_t i = 0; i < names.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
if ( i > 0 )
|
||||||
|
strItem += wxT (", ");
|
||||||
|
strItem += names[i] + wxT ("=") + values[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
icon = RegImageList::TextValue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case wxRegKey::Type_None:
|
case wxRegKey::Type_None:
|
||||||
// @@ handle the error...
|
// @@ handle the error...
|
||||||
icon = RegImageList::BinaryValue;
|
icon = RegImageList::BinaryValue;
|
||||||
@ -1367,6 +1383,37 @@ void RegTreeCtrl::SetRegistryView(wxRegKey::WOW64ViewMode viewMode)
|
|||||||
m_pRoot->Refresh();
|
m_pRoot->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *RegTreeCtrl::ValueTypeName(wxRegKey::ValueType type)
|
||||||
|
{
|
||||||
|
switch ( type )
|
||||||
|
{
|
||||||
|
case wxRegKey::Type_None:
|
||||||
|
return "none";
|
||||||
|
case wxRegKey::Type_String:
|
||||||
|
return "string";
|
||||||
|
case wxRegKey::Type_Expand_String:
|
||||||
|
return "expand_string";
|
||||||
|
case wxRegKey::Type_Binary:
|
||||||
|
return "binary";
|
||||||
|
case wxRegKey::Type_Dword:
|
||||||
|
return "number";
|
||||||
|
case wxRegKey::Type_Dword_big_endian:
|
||||||
|
return "big endian number";
|
||||||
|
case wxRegKey::Type_Link:
|
||||||
|
return "symbolic link";
|
||||||
|
case wxRegKey::Type_Multi_String:
|
||||||
|
return "multiple strings";
|
||||||
|
case wxRegKey::Type_Resource_list:
|
||||||
|
return "resource list in the resource map";
|
||||||
|
case wxRegKey::Type_Full_resource_descriptor:
|
||||||
|
return "resource list in the hardware description";
|
||||||
|
case wxRegKey::Type_Resource_requirements_list:
|
||||||
|
return "resource requirements list";
|
||||||
|
default:
|
||||||
|
return "unrecognized";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RegTreeCtrl::ShowProperties()
|
void RegTreeCtrl::ShowProperties()
|
||||||
{
|
{
|
||||||
wxTreeItemId lCurrent = GetSelection();
|
wxTreeItemId lCurrent = GetSelection();
|
||||||
@ -1405,8 +1452,7 @@ void RegTreeCtrl::ShowProperties()
|
|||||||
value,
|
value,
|
||||||
parent->m_strName.c_str(),
|
parent->m_strName.c_str(),
|
||||||
key.GetValueType(value),
|
key.GetValueType(value),
|
||||||
key.IsNumericValue(value) ? wxT("numeric") : wxT("string"));
|
ValueTypeName(key.GetValueType (value)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,7 +970,38 @@ bool wxRegKey::QueryValue(const wxString& szValue, wxMemoryBuffer& buffer) const
|
|||||||
return false;
|
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,
|
bool wxRegKey::QueryValue(const wxString& szValue,
|
||||||
wxString& strValue,
|
wxString& strValue,
|
||||||
|
Loading…
Reference in New Issue
Block a user