RedPanda-CPP/RedPandaIDE/parser/statementmodel.h

54 lines
1.8 KiB
C
Raw Normal View History

2021-12-26 23:18:28 +08:00
/*
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2021-08-05 23:13:21 +08:00
#ifndef STATEMENTMODEL_H
#define STATEMENTMODEL_H
#include <QObject>
2021-08-08 17:22:37 +08:00
#include <QTextStream>
#include "parserutils.h"
2021-08-05 23:13:21 +08:00
class StatementModel : public QObject
{
Q_OBJECT
public:
explicit StatementModel(QObject *parent = nullptr);
2021-08-29 00:48:23 +08:00
void add(const PStatement& statement);
2021-08-07 14:08:51 +08:00
// function DeleteFirst: Integer;
// function DeleteLast: Integer;
2021-08-29 00:48:23 +08:00
void deleteStatement(const PStatement& statement);
const StatementMap& childrenStatements(const PStatement& statement = PStatement()) const;
2021-08-24 15:05:10 +08:00
const StatementMap& childrenStatements(std::weak_ptr<Statement> statement) const;
2021-08-07 14:08:51 +08:00
void clear();
2021-08-08 17:22:37 +08:00
void dump(const QString& logFile);
#ifdef QT_DEBUG
void dumpAll(const QString& logFile);
#endif
2021-08-07 18:02:57 +08:00
private:
2021-08-29 00:48:23 +08:00
void addMember(StatementMap& map, const PStatement& statement);
int deleteMember(StatementMap& map, const PStatement& statement);
2021-08-08 17:22:37 +08:00
void dumpStatementMap(StatementMap& map, QTextStream& out, int level);
2021-08-07 14:08:51 +08:00
private:
int mCount;
StatementMap mGlobalStatements; //may have overloaded functions, so use PStatementList to store
#ifdef QT_DEBUG
StatementList mAllStatements;
#endif
2021-08-05 23:13:21 +08:00
};
#endif // STATEMENTMODEL_H