1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_XMLREADER_SPAN_HXX 25 #define INCLUDED_XMLREADER_SPAN_HXX 26 27 #include "sal/config.h" 28 29 #include "rtl/string.h" 30 #include "sal/types.h" 31 #include "xmlreader/detail/xmlreaderdllapi.hxx" 32 33 namespace rtl { class OUString; } 34 35 namespace xmlreader { 36 37 struct OOO_DLLPUBLIC_XMLREADER Span { 38 char const * begin; 39 sal_Int32 length; 40 Spanxmlreader::Span41 inline Span(): begin(0), length(0) {} 42 // init length to avoid compiler warnings 43 Spanxmlreader::Span44 inline Span(char const * theBegin, sal_Int32 theLength): 45 begin(theBegin), length(theLength) {} 46 clearxmlreader::Span47 inline void clear() throw() { begin = 0; } 48 isxmlreader::Span49 inline bool is() const { return begin != 0; } 50 equalsxmlreader::Span51 inline bool equals(Span const & text) const { 52 return rtl_str_compare_WithLength( 53 begin, length, text.begin, text.length) == 0; 54 } 55 equalsxmlreader::Span56 inline bool equals(char const * textBegin, sal_Int32 textLength) const { 57 return equals(Span(textBegin, textLength)); 58 } 59 60 rtl::OUString convertFromUtf8() const; 61 }; 62 63 } 64 65 #endif 66