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