File indexing completed on 2024-05-12 15:50:06
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 SPDX-FileCopyrightText: 2018 Christoph Cullmann <cullmann@kde.org> 0004 0005 SPDX-License-Identifier: MIT 0006 */ 0007 0008 #ifndef KSYNTAXHIGHLIGHTING_STATE_P_H 0009 #define KSYNTAXHIGHLIGHTING_STATE_P_H 0010 0011 #include <QSharedData> 0012 #include <QVector> 0013 0014 #include "definitionref_p.h" 0015 0016 namespace KSyntaxHighlighting 0017 { 0018 class Context; 0019 0020 class StateData : public QSharedData 0021 { 0022 friend class State; 0023 friend class AbstractHighlighter; 0024 0025 public: 0026 StateData() = default; 0027 static StateData *get(State &state); 0028 0029 bool isEmpty() const; 0030 void clear(); 0031 int size() const; 0032 void push(Context *context, const QStringList &captures); 0033 0034 /** 0035 * Pop the number of elements given from the top of the current stack. 0036 * Will not pop the initial element. 0037 * @param popCount number of elements to pop 0038 * @return false if one has tried to pop the initial context, else true 0039 */ 0040 bool pop(int popCount); 0041 0042 Context *topContext() const; 0043 const QStringList &topCaptures() const; 0044 0045 private: 0046 /** 0047 * definition id to filter out invalid states 0048 */ 0049 uint64_t m_defId = 0; 0050 0051 /** 0052 * the context stack combines the active context + valid captures 0053 */ 0054 QVector<QPair<Context *, QStringList>> m_contextStack; 0055 }; 0056 0057 } 0058 0059 #endif