diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-10-21 17:23:10 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-11-21 12:57:57 +0000 |
commit | 783b93978d49ccdbc30b4afdd95a94980f99100e (patch) | |
tree | 359e5c67f94f4a9c1244c45f2b3d5a30886211c7 /include/comphelper | |
parent | loplugin:countusersofdefaultparams in include/sot..svl (diff) | |
download | core-783b93978d49ccdbc30b4afdd95a94980f99100e.tar.gz core-783b93978d49ccdbc30b4afdd95a94980f99100e.zip |
introduce getValue(sKey) for SequenceAsHashMap
returns the plain value (Any) if it exists, else return an empty Any
replaces some getUnpackedValueOrDefault calls in sw
where is was not clear if the unpacked value exsisted or was default
needed for removal of Any-to-Any template specialisations
Change-Id: I618da7a7174143f5edef48e47e7aa1b6a52845e1
Reviewed-on: https://gerrit.libreoffice.org/30114
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/comphelper')
-rw-r--r-- | include/comphelper/sequenceashashmap.hxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/comphelper/sequenceashashmap.hxx b/include/comphelper/sequenceashashmap.hxx index cea549305922..fdec8cc085df 100644 --- a/include/comphelper/sequenceashashmap.hxx +++ b/include/comphelper/sequenceashashmap.hxx @@ -237,6 +237,30 @@ class COMPHELPER_DLLPUBLIC SequenceAsHashMap : public SequenceAsHashMapBase return aValue; } + /** @short check if the specified item exists + and return its value or it returns + an empty css::uno::Any. + + @descr If a value should be extracted only in case + the requested property exists really (without creating + of new items as the index operator of a + hash map does!) this method can be used. + + @param sKey + key name of the item. + + @return The value of the specified property or + an empty css::uno::Any. + */ + inline css::uno::Any getValue(const OUString& sKey) const + { + const_iterator pIt = find(sKey); + if (pIt == end()) + return css::uno::Any(); + + return pIt->second; + } + /** @short creates a new item with the specified name and value only in case such item name |