diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-01-16 13:29:19 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-01-16 11:40:18 +0000 |
commit | 15fe7346ade34f09f9be016ff847421ce0fa56f4 (patch) | |
tree | 51c4b2f4ef92f8c7418978933860c824c7356421 /include/sax | |
parent | f41d42491528905594b9a36a3bf16998f309c702 (diff) |
Simplify FastAttributeList
Change-Id: Id89edb25e35527e8603c32e44fb2940721aeda58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145562
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include/sax')
-rw-r--r-- | include/sax/fastattribs.hxx | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx index 22512bd5a929..2dc7c3d72420 100644 --- a/include/sax/fastattribs.hxx +++ b/include/sax/fastattribs.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/util/XCloneable.hpp> #include <cppuhelper/implbase.hxx> +#include <o3tl/string_view.hxx> #include <rtl/math.h> #include <sax/saxdllapi.h> @@ -105,9 +106,18 @@ public: bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const; bool getAsDouble( sal_Int32 nToken, double &rDouble) const; bool getAsView( sal_Int32 nToken, std::string_view& rPos ) const; - sal_Int32 getAsIntegerByIndex( sal_Int32 nTokenIndex ) const; - std::string_view getAsViewByIndex( sal_Int32 nTokenIndex ) const; - OUString getValueByIndex( sal_Int32 nTokenIndex ) const; + sal_Int32 getAsIntegerByIndex( sal_Int32 nTokenIndex ) const + { + return o3tl::toInt32(getAsViewByIndex(nTokenIndex)); + } + std::string_view getAsViewByIndex( sal_Int32 nTokenIndex ) const + { + return std::string_view(getFastAttributeValue(nTokenIndex), AttributeValueLength(nTokenIndex)); + } + OUString getValueByIndex( sal_Int32 nTokenIndex ) const + { + return OStringToOUString(getAsViewByIndex(nTokenIndex), RTL_TEXTENCODING_UTF8); + } // XFastAttributeList virtual sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) override; @@ -168,14 +178,12 @@ public: sal_Int32 toInt32() const { assert(mnIdx < mrList.maAttributeTokens.size()); - return rtl_str_toInt32(mrList.getFastAttributeValue(mnIdx), 10); + return mrList.getAsIntegerByIndex(mnIdx); } double toDouble() const { assert(mnIdx < mrList.maAttributeTokens.size()); - const char* pStr = mrList.getFastAttributeValue(mnIdx); - sal_Int32 nLen = mrList.AttributeValueLength(mnIdx); - return rtl_math_stringToDouble(pStr, pStr + nLen, '.', 0, nullptr, nullptr); + return o3tl::toDouble(mrList.getAsViewByIndex(mnIdx)); } bool toBoolean() const { @@ -185,9 +193,7 @@ public: OUString toString() const { assert(mnIdx < mrList.maAttributeTokens.size()); - return OUString(mrList.getFastAttributeValue(mnIdx), - mrList.AttributeValueLength(mnIdx), - RTL_TEXTENCODING_UTF8); + return mrList.getValueByIndex(mnIdx); } const char* toCString() const { @@ -202,7 +208,7 @@ public: std::string_view toView() const { assert(mnIdx < mrList.maAttributeTokens.size()); - return std::string_view(mrList.getFastAttributeValue(mnIdx), mrList.AttributeValueLength(mnIdx)); + return mrList.getAsViewByIndex(mnIdx); } bool isString(const char *str) const { |