summaryrefslogtreecommitdiff
path: root/include/xmloff
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
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')
-rw-r--r--include/xmloff/xmltoken.hxx5
-rw-r--r--include/xmloff/xmluconv.hxx38
2 files changed, 43 insertions, 0 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index e0f3ef898c65..0a8a12381240 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3410,6 +3410,11 @@ namespace xmloff::token {
const OUString& rString,
enum XMLTokenEnum eToken );
+ /// compare eToken to the string
+ XMLOFF_DLLPUBLIC bool IsXMLToken(
+ std::string_view rString,
+ enum XMLTokenEnum eToken );
+
XMLOFF_DLLPUBLIC bool IsXMLToken(
const sax_fastparser::FastAttributeList::FastAttributeIter& aIter,
enum XMLTokenEnum eToken );
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,