| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #ifndef KSYNTAXHIGHLIGHTING_CONTEXTSWITCH_P_H |
| 8 | #define KSYNTAXHIGHLIGHTING_CONTEXTSWITCH_P_H |
| 9 | |
| 10 | #include <QStringView> |
| 11 | #include <QVarLengthArray> |
| 12 | |
| 13 | namespace KSyntaxHighlighting |
| 14 | { |
| 15 | class Context; |
| 16 | class DefinitionData; |
| 17 | |
| 18 | class ContextSwitch |
| 19 | { |
| 20 | public: |
| 21 | using ContextList = QVarLengthArray<Context *, 2>; |
| 22 | |
| 23 | ContextSwitch() = default; |
| 24 | ~ContextSwitch() = default; |
| 25 | |
| 26 | bool isStay() const |
| 27 | { |
| 28 | return m_isStay; |
| 29 | } |
| 30 | |
| 31 | int popCount() const |
| 32 | { |
| 33 | return m_popCount; |
| 34 | } |
| 35 | |
| 36 | const ContextList &contexts() const |
| 37 | { |
| 38 | return m_contexts; |
| 39 | } |
| 40 | |
| 41 | void resolve(DefinitionData &def, QStringView context); |
| 42 | |
| 43 | private: |
| 44 | bool m_isStay = true; |
| 45 | int m_popCount = 0; |
| 46 | ContextList m_contexts; |
| 47 | }; |
| 48 | } |
| 49 | |
| 50 | #endif // KSYNTAXHIGHLIGHTING_CONTEXTSWITCH_P_H |
| 51 | |