QtNovelUI/libParse/tokeniimpl.cpp

54 lines
1.6 KiB
C++

#include "tokeniimpl.h"
using namespace Lex;
TokenWord::TokenWord(const QString &file_path) { filepath_val = file_path; }
QString TokenWord::content() const { return content_val; }
QString TokenWord::filePath() const { return filepath_val; }
int TokenWord::row() const { return row_val; }
int TokenWord::column() const { return column_val; }
// WordBase &TokenWord::operator=(const WordBase &other) {
// this->content_val = other.content();
// this->filepath_val = other.filePath();
// this->row_val = other.row();
// this->column_val = other.column();
// return *this;
//}
void TokenWord::reset(const QString &word, int row, int col) {
content_val = word;
row_val = row;
column_val = col;
}
TokenResult::TokenResult(TokenDef *def, WordBase *word, int length) : def_store(def), remains_store(nullptr) {
TokenWord *inst = nullptr;
if (word->content().length() != length) {
inst = new TokenWord(word->filePath());
inst->reset(word->content().mid(length), word->row(), word->column() + length);
}
remains_store = inst;
content_store = word->content().mid(0, length);
filepath_store = word->filePath();
row_store = word->row();
col_store = word->column();
}
TokenDef *TokenResult::def() const { return def_store; }
WordBase *TokenResult::remains() const { return remains_store; }
QString TokenResult::content() const { return content_store; }
QString TokenResult::filePath() const { return filepath_store; }
int TokenResult::row() const { return row_store; }
int TokenResult::column() const { return col_store; }