/src/libreoffice/include/xmlreader/span.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <cstring> |
25 | | |
26 | | #include <sal/types.h> |
27 | | #include <xmlreader/detail/xmlreaderdllapi.hxx> |
28 | | |
29 | | namespace rtl { class OUString; } |
30 | | |
31 | | namespace xmlreader { |
32 | | |
33 | | struct SAL_WARN_UNUSED OOO_DLLPUBLIC_XMLREADER Span { |
34 | | char const * begin; |
35 | | sal_Int32 length; |
36 | | |
37 | 712k | Span(): begin(nullptr), length(0) {} |
38 | | // init length to avoid compiler warnings |
39 | | |
40 | | Span(char const * theBegin, sal_Int32 theLength): |
41 | 2.82M | begin(theBegin), length(theLength) {} |
42 | | |
43 | | template< std::size_t N > explicit Span(char const (& literal)[N]): |
44 | 216 | begin(literal), length(N - 1) |
45 | 216 | {}xmlreader::Span::Span<37ul>(char const (&) [37ul]) Line | Count | Source | 44 | 108 | begin(literal), length(N - 1) | 45 | 108 | {} |
xmlreader::Span::Span<4ul>(char const (&) [4ul]) Line | Count | Source | 44 | 108 | begin(literal), length(N - 1) | 45 | 108 | {} |
Unexecuted instantiation: xmlreader::Span::Span<1ul>(char const (&) [1ul]) |
46 | | |
47 | 367k | void clear() noexcept { begin = nullptr; } |
48 | | |
49 | 735k | bool is() const { return begin != nullptr; } |
50 | | |
51 | 1.24M | bool operator==(Span const & text) const { |
52 | 1.24M | return length == text.length |
53 | 722k | && std::memcmp(begin, text.begin, text.length) == 0; |
54 | 1.24M | } |
55 | | |
56 | 0 | bool operator!=(Span const & text) const { |
57 | 0 | return !(operator==(text)); |
58 | 0 | } |
59 | | |
60 | 878k | bool equals(char const * textBegin, sal_Int32 textLength) const { |
61 | 878k | return operator==(Span(textBegin, textLength)); |
62 | 878k | } |
63 | | |
64 | | template< std::size_t N > bool operator==(char const (& literal)[N]) |
65 | | const |
66 | 367k | { |
67 | 367k | return operator==(Span(literal, N - 1)); |
68 | 367k | } Unexecuted instantiation: bool xmlreader::Span::operator==<15ul>(char const (&) [15ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<12ul>(char const (&) [12ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<14ul>(char const (&) [14ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<5ul>(char const (&) [5ul]) const bool xmlreader::Span::operator==<6ul>(char const (&) [6ul]) const Line | Count | Source | 66 | 367k | { | 67 | 367k | return operator==(Span(literal, N - 1)); | 68 | 367k | } |
Unexecuted instantiation: bool xmlreader::Span::operator==<7ul>(char const (&) [7ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<4ul>(char const (&) [4ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<3ul>(char const (&) [3ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<13ul>(char const (&) [13ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<8ul>(char const (&) [8ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<9ul>(char const (&) [9ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<10ul>(char const (&) [10ul]) const bool xmlreader::Span::operator==<42ul>(char const (&) [42ul]) const Line | Count | Source | 66 | 108 | { | 67 | 108 | return operator==(Span(literal, N - 1)); | 68 | 108 | } |
Unexecuted instantiation: bool xmlreader::Span::operator==<11ul>(char const (&) [11ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<17ul>(char const (&) [17ul]) const Unexecuted instantiation: bool xmlreader::Span::operator==<2ul>(char const (&) [2ul]) const |
69 | | |
70 | | template< std::size_t N > bool operator!=(char const (& literal)[N]) |
71 | | const |
72 | 0 | { |
73 | 0 | return operator!=(Span(literal, N - 1)); |
74 | 0 | } Unexecuted instantiation: bool xmlreader::Span::operator!=<5ul>(char const (&) [5ul]) const Unexecuted instantiation: bool xmlreader::Span::operator!=<6ul>(char const (&) [6ul]) const |
75 | | |
76 | | rtl::OUString convertFromUtf8() const; |
77 | | }; |
78 | | |
79 | | } |
80 | | |
81 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |