summaryrefslogtreecommitdiff
path: root/include/xmlreader/span.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-05-16 09:24:31 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-05-16 09:25:53 +0200
commitdf18d5878c71d8d38a43dd04c0e907f9385addb4 (patch)
tree72d8da1543c6835594f37b6d75cb194fc6f775b1 /include/xmlreader/span.hxx
parent09269acdb98854b1892aa539efec7d6a7875ad06 (diff)
Some string literal clean up
Change-Id: I108882af13fa97fa094547ec4efb468f988f337d
Diffstat (limited to 'include/xmlreader/span.hxx')
-rw-r--r--include/xmlreader/span.hxx29
1 files changed, 12 insertions, 17 deletions
diff --git a/include/xmlreader/span.hxx b/include/xmlreader/span.hxx
index 4f3e4d1c285d..26c6648bf329 100644
--- a/include/xmlreader/span.hxx
+++ b/include/xmlreader/span.hxx
@@ -22,12 +22,13 @@
#include "sal/config.h"
-#include "rtl/string.hxx"
-#include "rtl/stringutils.hxx"
-#include "rtl/ustring.hxx"
+#include <cstddef>
+
#include "sal/types.h"
#include "xmlreader/detail/xmlreaderdllapi.hxx"
+namespace rtl { class OUString; }
+
namespace xmlreader {
struct OOO_DLLPUBLIC_XMLREADER Span {
@@ -40,6 +41,10 @@ struct OOO_DLLPUBLIC_XMLREADER Span {
inline Span(char const * theBegin, sal_Int32 theLength):
begin(theBegin), length(theLength) {}
+ template< std::size_t N > explicit inline Span(char const (& literal)[N]):
+ begin(literal), length(N - 1)
+ {}
+
inline void clear() throw() { begin = 0; }
inline bool is() const { return begin != 0; }
@@ -53,23 +58,13 @@ struct OOO_DLLPUBLIC_XMLREADER Span {
return equals(Span(textBegin, textLength));
}
- inline bool equals(OString const & text) const {
- return rtl_str_compare_WithLength(
- begin, length, text.getStr(), text.getLength()) == 0;
- }
-
- /**
- @overload
- This function accepts an ASCII string literal as its argument.
- */
- template< typename T > bool
- equals( T& literal, typename rtl::internal::ConstCharArrayDetector< T, rtl::internal::Dummy >::Type = rtl::internal::Dummy() ) SAL_THROW(())
+ template< std::size_t N > inline bool equals(char const (& literal)[N])
+ const
{
- assert( strlen( literal ) == rtl::internal::ConstCharArrayDetector< T >::size - 1 );
- return rtl_str_compare_WithLength( begin, length, literal, rtl::internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
+ return equals(Span(literal, N - 1));
}
- OUString convertFromUtf8() const;
+ rtl::OUString convertFromUtf8() const;
};
}