diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/comphelper/sequenceashashmap.hxx | 85 |
1 files changed, 73 insertions, 12 deletions
diff --git a/include/comphelper/sequenceashashmap.hxx b/include/comphelper/sequenceashashmap.hxx index 270601af7c67..b4b2991948ae 100644 --- a/include/comphelper/sequenceashashmap.hxx +++ b/include/comphelper/sequenceashashmap.hxx @@ -40,14 +40,9 @@ namespace comphelper{ such name sequences very easy ... */ -struct SequenceAsHashMapBase : public std::unordered_map< - OUString , - css::uno::Any , - OUStringHash > -{ -}; +using SequenceAsHashMapBase = std::unordered_map<OUString, css::uno::Any, OUStringHash>; -class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAsHashMapBase +class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap { public: @@ -221,8 +216,8 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs TValueType getUnpackedValueOrDefault(const OUString& sKey , const TValueType& aDefault) const { - const_iterator pIt = find(sKey); - if (pIt == end()) + auto pIt = m_aMap.find(sKey); + if (pIt == m_aMap.end()) return aDefault; TValueType aValue = TValueType(); @@ -249,8 +244,8 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs */ css::uno::Any getValue(const OUString& sKey) const { - const_iterator pIt = find(sKey); - if (pIt == end()) + auto pIt = m_aMap.find(sKey); + if (pIt == m_aMap.end()) return css::uno::Any(); return pIt->second; @@ -281,7 +276,7 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs bool createItemIfMissing(const OUString& sKey , const TValueType& aValue) { - if (find(sKey) == end()) + if (m_aMap.find(sKey) == m_aMap.end()) { (*this)[sKey] = css::uno::toAny(aValue); return true; @@ -320,6 +315,72 @@ class SAL_WARN_UNUSED COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAs the map containing all items for the update. */ void update(const SequenceAsHashMap& rSource); + + css::uno::Any& operator[](const OUString& rKey) + { + return m_aMap[rKey]; + } + + using iterator = SequenceAsHashMapBase::iterator; + using const_iterator = SequenceAsHashMapBase::const_iterator; + + void clear() + { + m_aMap.clear(); + } + + size_t size() const + { + return m_aMap.size(); + } + + bool empty() const + { + return m_aMap.empty(); + } + + iterator begin() + { + return m_aMap.begin(); + } + + const_iterator begin() const + { + return m_aMap.begin(); + } + + iterator end() + { + return m_aMap.end(); + } + + const_iterator end() const + { + return m_aMap.end(); + } + + iterator find(const OUString& rKey) + { + return m_aMap.find(rKey); + } + + const_iterator find(const OUString& rKey) const + { + return m_aMap.find(rKey); + } + + iterator erase(iterator it) + { + return m_aMap.erase(it); + } + + size_t erase(const OUString& rKey) + { + return m_aMap.erase(rKey); + } + +private: + SequenceAsHashMapBase m_aMap; }; } // namespace comphelper |