47 lines
840 B
C
47 lines
840 B
C
|
#pragma once
|
|||
|
#include <QString>
|
|||
|
#include <QTextStream>
|
|||
|
#include <QFile>
|
|||
|
#include <tuple>
|
|||
|
|
|||
|
namespace Lex {
|
|||
|
class ExStream
|
|||
|
{
|
|||
|
public:
|
|||
|
typedef int n_row;
|
|||
|
typedef int n_col;
|
|||
|
explicit ExStream();
|
|||
|
virtual ~ExStream();
|
|||
|
|
|||
|
/**
|
|||
|
* 初始化文件指向.
|
|||
|
*
|
|||
|
* \param path 源文件
|
|||
|
* \return -2无法打开:-1:文件不存在,0:成功
|
|||
|
*/
|
|||
|
int initSource(const QString &path);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 直接设置源代码
|
|||
|
* @param codes 源代码
|
|||
|
*/
|
|||
|
void setSourceCode(const QString &codes);
|
|||
|
|
|||
|
/**
|
|||
|
* 在文件文本流中读取一个字符.
|
|||
|
*
|
|||
|
* \return
|
|||
|
*/
|
|||
|
std::tuple<n_row, n_col, QChar> read();
|
|||
|
|
|||
|
private:
|
|||
|
QFile * file_target;
|
|||
|
QString contents_temp;
|
|||
|
QTextStream* text_input;
|
|||
|
|
|||
|
QString current_line;
|
|||
|
int current_row, current_col;
|
|||
|
|
|||
|
};
|
|||
|
}
|