1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H
8#define KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H
9
10#include <QStringList>
11
12namespace KSyntaxHighlighting
13{
14/**
15 * Storage for match result of a Rule.
16 * Heavily used internally during highlightLine, therefore completely inline.
17 */
18class MatchResult
19{
20public:
21 /**
22 * Match at given offset found.
23 * @param offset offset of match
24 */
25 MatchResult(const int offset)
26 : m_offset(offset)
27 {
28 }
29
30 /**
31 * Match at given offset found with additional skip offset.
32 */
33 explicit MatchResult(const int offset, const int skipOffset)
34 : m_offset(offset)
35 , m_skipOffset(skipOffset)
36 {
37 }
38
39 /**
40 * Match at given offset found with additional captures.
41 * @param offset offset of match
42 * @param captures captures of the match
43 */
44 explicit MatchResult(const int offset, QStringList &&captures)
45 : m_offset(offset)
46 , m_captures(std::move(captures))
47 {
48 }
49
50 /**
51 * Offset of the match
52 * @return offset of the match
53 */
54 int offset() const
55 {
56 return m_offset;
57 }
58
59 /**
60 * Skip offset of the match
61 * @return skip offset of the match, no match possible until this offset is reached
62 */
63 int skipOffset() const
64 {
65 return m_skipOffset;
66 }
67
68 /**
69 * Captures of the match.
70 * @return captured text of this match
71 */
72 QStringList &captures()
73 {
74 return m_captures;
75 }
76
77private:
78 /**
79 * match offset, filled in all constructors
80 */
81 int m_offset;
82
83 /**
84 * skip offset, optional
85 */
86 int m_skipOffset = 0;
87
88 /**
89 * captures, optional
90 */
91 QStringList m_captures;
92};
93}
94
95#endif // KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H
96

source code of syntax-highlighting/src/lib/matchresult_p.h