2022-11-06 00:37:50 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <tuple>
|
|
|
|
|
|
2022-11-06 11:40:11 +00:00
|
|
|
|
namespace Lex {
|
|
|
|
|
class ExStream
|
2022-11-06 00:37:50 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef int n_row;
|
|
|
|
|
typedef int n_col;
|
2022-11-06 11:40:11 +00:00
|
|
|
|
explicit ExStream();
|
|
|
|
|
virtual ~ExStream();
|
2022-11-06 00:37:50 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化文件指向.
|
|
|
|
|
*
|
|
|
|
|
* \param path 源文件
|
|
|
|
|
* \return -2无法打开:-1:文件不存在,0:成功
|
|
|
|
|
*/
|
|
|
|
|
int initSource(const QString &path);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 在文件文本流中读取一个字符.
|
|
|
|
|
*
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
|
|
|
|
std::tuple<n_row, n_col, QChar> read();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QFile * file_target;
|
|
|
|
|
QTextStream* text_input;
|
|
|
|
|
|
|
|
|
|
QString current_line;
|
|
|
|
|
int current_row, current_col;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|