合并改进加速运行
This commit is contained in:
commit
cbc2b2ccb6
|
@ -6,7 +6,7 @@
|
||||||
<LocalDebuggerCommandArguments>--path "D:\CustomNovels\科学+修仙+创造世界" --dest E:\</LocalDebuggerCommandArguments>
|
<LocalDebuggerCommandArguments>--path "D:\CustomNovels\科学+修仙+创造世界" --dest E:\</LocalDebuggerCommandArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LocalDebuggerCommandArguments>--path "D:\手作小说\科学+修仙+创造世界"</LocalDebuggerCommandArguments>
|
<LocalDebuggerCommandArguments>--path "D:\CustomNovels\科学+修仙+创造世界" --dest E:\</LocalDebuggerCommandArguments>
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -30,16 +30,17 @@ QList<std::shared_ptr<const IWordBase>> WordReader::extract_from(const QString&
|
||||||
QList<std::shared_ptr<const IWordBase>> ret_list;
|
QList<std::shared_ptr<const IWordBase>> ret_list;
|
||||||
int line_number = 1;
|
int line_number = 1;
|
||||||
while (!tin.atEnd()) {
|
while (!tin.atEnd()) {
|
||||||
auto doc_pos = tin.pos();
|
uint64_t relative_offset = line_number;
|
||||||
|
relative_offset = relative_offset << 32;
|
||||||
auto line = tin.readLine() + "\n";
|
auto line = tin.readLine() + "\n";
|
||||||
ret_list.append(this->parse_line(doc_pos, line_number++, line, path));
|
ret_list.append(this->parse_line(relative_offset, line_number++, line, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_list;
|
return ret_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
QList<std::shared_ptr<const IWordBase>> WordReader::parse_line(int start_pos, int row, const QString& line_text, const QString& path) const {
|
QList<std::shared_ptr<const IWordBase>> WordReader::parse_line(uint64_t start_pos, int row, const QString& line_text, const QString& path) const {
|
||||||
QRegExp split_char(u8"\\s");
|
QRegExp split_char(u8"\\s");
|
||||||
auto words = line_text.split(split_char, QString::SplitBehavior::SkipEmptyParts);
|
auto words = line_text.split(split_char, QString::SplitBehavior::SkipEmptyParts);
|
||||||
|
|
||||||
|
@ -60,12 +61,12 @@ TokenException::TokenException(const QString& message) : msg_store(message) {}
|
||||||
|
|
||||||
QString TokenException::message() const { return msg_store; }
|
QString TokenException::message() const { return msg_store; }
|
||||||
|
|
||||||
WordContent::WordContent(int r, int c, int pos, const QString& t, const QString& p)
|
WordContent::WordContent(int r, int c, uint64_t pos, const QString& t, const QString& p)
|
||||||
: row_n(r), col_n(c), doc_offset(pos), text_n(t), path_p(p) {}
|
: row_n(r), col_n(c), doc_offset(pos), text_n(t), path_p(p) {}
|
||||||
|
|
||||||
QString WordContent::file() const { return path_p; }
|
QString WordContent::file() const { return path_p; }
|
||||||
|
|
||||||
int lib_token::WordContent::position() const {
|
uint64_t lib_token::WordContent::position() const {
|
||||||
return doc_offset;
|
return doc_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ QString WordImpl::file() const
|
||||||
return content_ptr->file();
|
return content_ptr->file();
|
||||||
}
|
}
|
||||||
|
|
||||||
int lib_token::WordImpl::position() const {
|
uint64_t lib_token::WordImpl::position() const {
|
||||||
return content_ptr->position();
|
return content_ptr->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace lib_token {
|
||||||
* @brief 获取位置
|
* @brief 获取位置
|
||||||
* @return 起始位置
|
* @return 起始位置
|
||||||
*/
|
*/
|
||||||
virtual int position() const = 0;
|
virtual uint64_t position() const = 0;
|
||||||
/**
|
/**
|
||||||
* @brief 词语内容
|
* @brief 词语内容
|
||||||
* @return
|
* @return
|
||||||
|
@ -49,16 +49,17 @@ namespace lib_token {
|
||||||
*/
|
*/
|
||||||
class WordContent : public IWordBase {
|
class WordContent : public IWordBase {
|
||||||
private:
|
private:
|
||||||
int row_n, col_n, doc_offset;
|
int row_n, col_n;
|
||||||
|
uint64_t doc_offset;
|
||||||
QString text_n, path_p;
|
QString text_n, path_p;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WordContent(int r, int c, int pos, const QString& t, const QString& p);
|
WordContent(int r, int c, uint64_t pos, const QString& t, const QString& p);
|
||||||
|
|
||||||
// WordBase interface
|
// WordBase interface
|
||||||
public:
|
public:
|
||||||
virtual QString file() const override;
|
virtual QString file() const override;
|
||||||
virtual int position() const override;
|
virtual uint64_t position() const override;
|
||||||
virtual QString content() const override;
|
virtual QString content() const override;
|
||||||
virtual int row() const override;
|
virtual int row() const override;
|
||||||
virtual int column() const override;
|
virtual int column() const override;
|
||||||
|
@ -75,7 +76,7 @@ namespace lib_token {
|
||||||
|
|
||||||
// 通过 IWordBase 继承
|
// 通过 IWordBase 继承
|
||||||
QString file() const override;
|
QString file() const override;
|
||||||
virtual int position() const override;
|
virtual uint64_t position() const override;
|
||||||
QString content() const override;
|
QString content() const override;
|
||||||
int row() const override;
|
int row() const override;
|
||||||
int column() const override;
|
int column() const override;
|
||||||
|
@ -143,7 +144,7 @@ namespace lib_token {
|
||||||
*/
|
*/
|
||||||
class LIBTOKEN_EXPORT WordReader {
|
class LIBTOKEN_EXPORT WordReader {
|
||||||
private:
|
private:
|
||||||
QList<std::shared_ptr<const IWordBase>> parse_line(int start_pos, int row, const QString& line_text, const QString& path) const;
|
QList<std::shared_ptr<const IWordBase>> parse_line(uint64_t start_pos, int row, const QString& line_text, const QString& path) const;
|
||||||
QList<std::shared_ptr<const IWordBase>> extract_from(const QString& path) const;
|
QList<std::shared_ptr<const IWordBase>> extract_from(const QString& path) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -4,12 +4,12 @@ using namespace example_novel;
|
||||||
using namespace lib_token;
|
using namespace lib_token;
|
||||||
|
|
||||||
|
|
||||||
TokenContent::TokenContent(int r, int c, int pos, const QString& t, const QString& p, std::shared_ptr<const ITokenDefine> paramType)
|
TokenContent::TokenContent(int r, int c, uint64_t pos, const QString& t, const QString& p, std::shared_ptr<const ITokenDefine> paramType)
|
||||||
: row_n(r), col_n(c), doc_offset(pos), text_n(t), path_p(p), type_def(paramType) {}
|
: row_n(r), col_n(c), doc_offset(pos), text_n(t), path_p(p), type_def(paramType) {}
|
||||||
|
|
||||||
QString TokenContent::file() const { return path_p; }
|
QString TokenContent::file() const { return path_p; }
|
||||||
|
|
||||||
int lib_token::TokenContent::position() const {
|
uint64_t lib_token::TokenContent::position() const {
|
||||||
return doc_offset;
|
return doc_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@ namespace lib_token {
|
||||||
std::shared_ptr<const ITokenDefine> type_def;
|
std::shared_ptr<const ITokenDefine> type_def;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TokenContent(int r, int c, int pos, const QString& t, const QString& p, std::shared_ptr<const ITokenDefine> paramType);
|
TokenContent(int r, int c, uint64_t pos, const QString& t, const QString& p, std::shared_ptr<const ITokenDefine> paramType);
|
||||||
|
|
||||||
// WordBase interface
|
// WordBase interface
|
||||||
public:
|
public:
|
||||||
virtual QString file() const override;
|
virtual QString file() const override;
|
||||||
virtual int position() const override;
|
virtual uint64_t position() const override;
|
||||||
virtual QString content() const override;
|
virtual QString content() const override;
|
||||||
virtual int row() const override;
|
virtual int row() const override;
|
||||||
virtual int column() const override;
|
virtual int column() const override;
|
||||||
|
|
Loading…
Reference in New Issue