summaryrefslogtreecommitdiff
path: root/include/xmloff/xmluconv.hxx
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2020-12-17 16:23:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-18 07:56:54 +0100
commitd9b8670548561f7f53a546b8fe53212c6b1ce26e (patch)
treef81854d5bf867dfc4eb7da2f31632656c745969c /include/xmloff/xmluconv.hxx
parent8c9a4ff511a3b1d84a7a6d08a1b153c07f164abb (diff)
use more string_view in convertEnum
Change-Id: I859de4b908672722e1873c5b41cb456b42258ddd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107885 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/xmloff/xmluconv.hxx')
-rw-r--r--include/xmloff/xmluconv.hxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx
index 3a9950edbd64..daca3b617f7f 100644
--- a/include/xmloff/xmluconv.hxx
+++ b/include/xmloff/xmluconv.hxx
@@ -147,6 +147,21 @@ public:
return bRet;
}
+ /** convert string to enum using given enum map, if the enum is
+ not found in the map, this method will return false */
+ template<typename EnumT>
+ static bool convertEnum( EnumT& rEnum,
+ std::string_view rValue,
+ const SvXMLEnumMapEntry<EnumT> *pMap )
+ {
+ sal_uInt16 nTmp;
+ bool bRet = convertEnumImpl(nTmp, rValue,
+ reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(pMap));
+ if (bRet)
+ rEnum = static_cast<EnumT>(nTmp);
+ return bRet;
+ }
+
/** convert string to enum using given token map, if the enum is
not found in the map, this method will return false */
template<typename EnumT>
@@ -162,6 +177,21 @@ public:
return bRet;
}
+ /** convert string to enum using given token map, if the enum is
+ not found in the map, this method will return false */
+ template<typename EnumT>
+ static bool convertEnum( EnumT& rEnum,
+ std::string_view rValue,
+ const SvXMLEnumStringMapEntry<EnumT> *pMap )
+ {
+ sal_uInt16 nTmp;
+ bool bRet = convertEnumImpl(nTmp, rValue,
+ reinterpret_cast<const SvXMLEnumStringMapEntry<sal_uInt16>*>(pMap));
+ if (bRet)
+ rEnum = static_cast<EnumT>(nTmp);
+ return bRet;
+ }
+
/** convert enum to string using given enum map with an optional
default token. If the enum is not found in the map,
this method will either use the given default or return
@@ -268,6 +298,14 @@ private:
std::u16string_view rValue,
const SvXMLEnumStringMapEntry<sal_uInt16> *pMap );
+ static bool convertEnumImpl( sal_uInt16& rEnum,
+ std::string_view rValue,
+ const SvXMLEnumMapEntry<sal_uInt16> *pMap );
+
+ static bool convertEnumImpl( sal_uInt16& rEnum,
+ std::string_view rValue,
+ const SvXMLEnumStringMapEntry<sal_uInt16> *pMap );
+
static bool convertEnumImpl( OUStringBuffer& rBuffer,
sal_uInt16 nValue,
const SvXMLEnumMapEntry<sal_uInt16> *pMap,