Use std::unordered_map<> in wxMsgCatalog and related classes
Replace more occurrences of legacy wx hash maps with the standard class.
This commit is contained in:
parent
c9e61ea8d3
commit
e13dbd4278
2 changed files with 15 additions and 7 deletions
|
|
@ -19,10 +19,19 @@
|
|||
|
||||
#include "wx/buffer.h"
|
||||
#include "wx/language.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/strconv.h"
|
||||
|
||||
// This is a hack, but this header used to include wx/hashmap.h which, in turn,
|
||||
// included wx/wxcrt.h and it turns out quite some existing code relied on it
|
||||
// by using the CRT wrapper functions declared there without explicitly
|
||||
// including that header, so keep including it from here to let it continue to
|
||||
// compile.
|
||||
#include "wx/wxcrt.h"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
using wxTranslationsHashMap = std::unordered_map<wxString, wxString>;
|
||||
|
||||
// ============================================================================
|
||||
// global decls
|
||||
|
|
@ -111,7 +120,7 @@ private:
|
|||
wxMsgCatalog *m_pNext;
|
||||
friend class wxTranslations;
|
||||
|
||||
wxStringToStringHashMap m_messages; // all messages in the catalog
|
||||
wxTranslationsHashMap m_messages; // all messages in the catalog
|
||||
wxString m_domain; // name of the domain
|
||||
|
||||
wxPluralFormsCalculatorPtr m_pluralFormsCalculator;
|
||||
|
|
@ -195,7 +204,7 @@ private:
|
|||
// In addition to keeping all the catalogs in the linked list, we also
|
||||
// store them in a hash map indexed by the domain name to allow finding
|
||||
// them by name efficiently.
|
||||
WX_DECLARE_HASH_MAP(wxString, wxMsgCatalog *, wxStringHash, wxStringEqual, wxMsgCatalogMap);
|
||||
using wxMsgCatalogMap = std::unordered_map<wxString, wxMsgCatalog*>;
|
||||
wxMsgCatalogMap m_catalogMap;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/module.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
|
|
@ -869,7 +868,7 @@ public:
|
|||
wxPluralFormsCalculatorPtr& rPluralFormsCalculator);
|
||||
|
||||
// fills the hash with string-translation pairs
|
||||
bool FillHash(wxStringToStringHashMap& hash, const wxString& domain) const;
|
||||
bool FillHash(wxTranslationsHashMap& hash, const wxString& domain) const;
|
||||
|
||||
// return the charset of the strings in this catalog or empty string if
|
||||
// none/unknown
|
||||
|
|
@ -1077,7 +1076,7 @@ bool wxMsgCatalogFile::LoadData(const DataBuffer& data,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool wxMsgCatalogFile::FillHash(wxStringToStringHashMap& hash,
|
||||
bool wxMsgCatalogFile::FillHash(wxTranslationsHashMap& hash,
|
||||
const wxString& domain) const
|
||||
{
|
||||
wxUnusedVar(domain); // silence warning in Unicode build
|
||||
|
|
@ -1195,7 +1194,7 @@ const wxString *wxMsgCatalog::GetString(const wxString& str, unsigned n, const w
|
|||
{
|
||||
index = m_pluralFormsCalculator->evaluate(n);
|
||||
}
|
||||
wxStringToStringHashMap::const_iterator i;
|
||||
wxTranslationsHashMap::const_iterator i;
|
||||
if (index != 0)
|
||||
{
|
||||
if (context.IsEmpty())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue