summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-09-26 21:02:24 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-09-27 11:54:52 +0200
commitf7445e1014815a9eb02e2c22257bbce32dc43589 (patch)
tree537e4c221d6ce75329b4e86f42a2125136a4bab1 /include
parent34905a6e9e0c262b61e5969274b661692af44a46 (diff)
tdf#75757 comphelper: avoid STL inheritance in SequenceAsHashMap
Change-Id: I5c7d107a05deb06749b4d04246ba183adfafb14d Reviewed-on: https://gerrit.libreoffice.org/42829 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/sequenceashashmap.hxx85
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