File indexing completed on 2024-05-12 15:50:05
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H 0008 #define KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H 0009 0010 #include <QStringList> 0011 0012 namespace KSyntaxHighlighting 0013 { 0014 /** 0015 * Storage for match result of a Rule. 0016 * Heavily used internally during highlightLine, therefore completely inline. 0017 */ 0018 class MatchResult 0019 { 0020 public: 0021 /** 0022 * Match at given offset found. 0023 * @param offset offset of match 0024 */ 0025 MatchResult(const int offset) 0026 : m_offset(offset) 0027 { 0028 } 0029 0030 /** 0031 * Match at given offset found with additional skip offset. 0032 */ 0033 explicit MatchResult(const int offset, const int skipOffset) 0034 : m_offset(offset) 0035 , m_skipOffset(skipOffset) 0036 { 0037 } 0038 0039 /** 0040 * Match at given offset found with additional captures. 0041 * @param offset offset of match 0042 * @param captures captures of the match 0043 */ 0044 explicit MatchResult(const int offset, const QStringList &captures) 0045 : m_offset(offset) 0046 , m_captures(captures) 0047 { 0048 } 0049 0050 /** 0051 * Offset of the match 0052 * @return offset of the match 0053 */ 0054 int offset() const 0055 { 0056 return m_offset; 0057 } 0058 0059 /** 0060 * Skip offset of the match 0061 * @return skip offset of the match, no match possible until this offset is reached 0062 */ 0063 int skipOffset() const 0064 { 0065 return m_skipOffset; 0066 } 0067 0068 /** 0069 * Captures of the match. 0070 * @return captured text of this match 0071 */ 0072 const QStringList &captures() const 0073 { 0074 return m_captures; 0075 } 0076 0077 private: 0078 /** 0079 * match offset, filled in all constructors 0080 */ 0081 int m_offset; 0082 0083 /** 0084 * skip offset, optional 0085 */ 0086 int m_skipOffset = 0; 0087 0088 /** 0089 * captures, optional 0090 */ 0091 QStringList m_captures; 0092 }; 0093 } 0094 0095 #endif // KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H