RedPanda-CPP/RedPandaIDE/parser/statementmodel.h

38 lines
1.1 KiB
C
Raw Normal View History

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