Use std::unordered_map<> in wxShadowObject
Use the standard containers directly instead of using wx hash map macros for declaring the types for clarity and simplicity.
This commit is contained in:
parent
cdb70479e4
commit
baa9a28eb0
1 changed files with 10 additions and 16 deletions
|
|
@ -13,20 +13,14 @@
|
|||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/object.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
typedef int (*wxShadowObjectMethod)(void*, void*);
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(
|
||||
wxShadowObjectMethod,
|
||||
wxShadowObjectMethods,
|
||||
class WXDLLIMPEXP_BASE
|
||||
);
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(
|
||||
void *,
|
||||
wxShadowObjectFields,
|
||||
class WXDLLIMPEXP_BASE
|
||||
);
|
||||
|
||||
using wxShadowObjectMethods = std::unordered_map<wxString, wxShadowObjectMethod>;
|
||||
using wxShadowObjectFields = std::unordered_map<wxString, void*>;
|
||||
|
||||
class WXDLLIMPEXP_BASE wxShadowObject
|
||||
{
|
||||
|
|
@ -35,7 +29,7 @@ public:
|
|||
|
||||
void AddMethod( const wxString &name, wxShadowObjectMethod method )
|
||||
{
|
||||
wxShadowObjectMethods::iterator it = m_methods.find( name );
|
||||
const auto it = m_methods.find( name );
|
||||
if (it == m_methods.end())
|
||||
m_methods[ name ] = method;
|
||||
else
|
||||
|
|
@ -44,7 +38,7 @@ public:
|
|||
|
||||
bool InvokeMethod( const wxString &name, void* window, void* param, int* returnValue )
|
||||
{
|
||||
wxShadowObjectMethods::iterator it = m_methods.find( name );
|
||||
const auto it = m_methods.find( name );
|
||||
if (it == m_methods.end())
|
||||
return false;
|
||||
wxShadowObjectMethod method = it->second;
|
||||
|
|
@ -56,7 +50,7 @@ public:
|
|||
|
||||
void AddField( const wxString &name, void* initialValue = nullptr )
|
||||
{
|
||||
wxShadowObjectFields::iterator it = m_fields.find( name );
|
||||
const auto it = m_fields.find( name );
|
||||
if (it == m_fields.end())
|
||||
m_fields[ name ] = initialValue;
|
||||
else
|
||||
|
|
@ -65,7 +59,7 @@ public:
|
|||
|
||||
void SetField( const wxString &name, void* value )
|
||||
{
|
||||
wxShadowObjectFields::iterator it = m_fields.find( name );
|
||||
const auto it = m_fields.find( name );
|
||||
if (it == m_fields.end())
|
||||
return;
|
||||
it->second = value;
|
||||
|
|
@ -73,7 +67,7 @@ public:
|
|||
|
||||
void* GetField( const wxString &name, void *defaultValue = nullptr )
|
||||
{
|
||||
wxShadowObjectFields::iterator it = m_fields.find( name );
|
||||
const auto it = m_fields.find( name );
|
||||
if (it == m_fields.end())
|
||||
return defaultValue;
|
||||
return it->second;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue