diff --git a/include/wx/richtext/richtextxml.h b/include/wx/richtext/richtextxml.h index 67b76b6830..5ca8b1c0ab 100644 --- a/include/wx/richtext/richtextxml.h +++ b/include/wx/richtext/richtextxml.h @@ -15,7 +15,6 @@ * Includes */ -#include "wx/hashmap.h" #include "wx/richtext/richtextbuffer.h" #include "wx/richtext/richtextstyles.h" @@ -217,12 +216,12 @@ public: Call with XML node name, C++ class name so that wxRTC can read in the node. If you add a custom object, call this. */ - static void RegisterNodeName(const wxString& nodeName, const wxString& className) { sm_nodeNameToClassMap[nodeName] = className; } + static void RegisterNodeName(const wxString& nodeName, const wxString& className); /** Cleans up the mapping between node name and C++ class. */ - static void ClearNodeToClassMap() { sm_nodeNameToClassMap.clear(); } + static void ClearNodeToClassMap(); protected: #if wxUSE_STREAMS @@ -231,8 +230,6 @@ protected: #endif wxRichTextXMLHelper m_helper; - - static wxStringToStringHashMap sm_nodeNameToClassMap; }; #endif diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index 4814650ab8..91a2f65973 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -32,6 +32,8 @@ #include "wx/stopwatch.h" #include "wx/xml/xml.h" +#include + // Set to 1 for slower wxXmlDocument method, 0 for faster direct method. // If we make wxXmlDocument::Save more efficient, we might switch to this // method. @@ -50,7 +52,12 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxRichTextXMLHandler, wxRichTextFileHandler); -wxStringToStringHashMap wxRichTextXMLHandler::sm_nodeNameToClassMap; +namespace +{ + +std::unordered_map gs_nodeNameToClassMap; + +} // anonymous namespace void wxRichTextXMLHandler::Init() { @@ -111,12 +118,22 @@ bool wxRichTextXMLHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& s return success; } +void wxRichTextXMLHandler::RegisterNodeName(const wxString& nodeName, const wxString& className) +{ + gs_nodeNameToClassMap[nodeName] = className; +} + +void wxRichTextXMLHandler::ClearNodeToClassMap() +{ + gs_nodeNameToClassMap.clear(); +} + /// Creates an object given an XML element name wxRichTextObject* wxRichTextXMLHandler::CreateObjectForXMLName(wxRichTextObject* WXUNUSED(parent), const wxString& name) const { // The standard node to class mappings are added in wxRichTextModule::OnInit in richtextbuffer.cpp - wxStringToStringHashMap::const_iterator it = sm_nodeNameToClassMap.find(name); - if (it == sm_nodeNameToClassMap.end()) + const auto it = gs_nodeNameToClassMap.find(name); + if (it == gs_nodeNameToClassMap.end()) return nullptr; else return wxDynamicCast(wxCreateDynamicObject(it->second), wxRichTextObject);