diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/xmlreader/pad.hxx | 6 | ||||
-rw-r--r-- | include/xmlreader/span.hxx | 29 |
2 files changed, 18 insertions, 17 deletions
diff --git a/include/xmlreader/pad.hxx b/include/xmlreader/pad.hxx index 0b8e1f3b7453..728a702d0a9e 100644 --- a/include/xmlreader/pad.hxx +++ b/include/xmlreader/pad.hxx @@ -22,6 +22,8 @@ #include "sal/config.h" +#include <cstddef> + #include "rtl/strbuf.hxx" #include "sal/types.h" #include "xmlreader/detail/xmlreaderdllapi.hxx" @@ -33,6 +35,10 @@ class OOO_DLLPUBLIC_XMLREADER Pad { public: void add(char const * begin, sal_Int32 length); + template< std::size_t N > void add(char const (& literal)[N]) { + add(literal, N - 1); + } + void addEphemeral(char const * begin, sal_Int32 length); void clear(); 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; }; } |