40 lines
660 B
C++
40 lines
660 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);
|
||
|
||
/**
|
||
* 在文件文本流中读取一个字符.
|
||
*
|
||
* \return
|
||
*/
|
||
std::tuple<n_row, n_col, QChar> read();
|
||
|
||
private:
|
||
QFile * file_target;
|
||
QTextStream* text_input;
|
||
|
||
QString current_line;
|
||
int current_row, current_col;
|
||
|
||
};
|
||
}
|