路径重置完成

This commit is contained in:
codeboss 2024-03-31 13:59:17 +08:00
parent af4dde1629
commit 31ed703644
9 changed files with 75 additions and 18 deletions

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:16.3782516Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:51.9907375Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:17.0264292Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.0532400Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,5 @@
#include "htmlprint.h"
#include <QDir>
using namespace example_novel;
using namespace printer;
@ -119,7 +120,7 @@ void tools_printer::build_storyline(std::shared_ptr<StoryLine> line, std::shared
}return;
case example_novel::NovelNode::FragmentRefer: {
auto refer_node = std::dynamic_pointer_cast<const example_novel::FragmentRefers>(novel_node->element());
auto refer_fragment = this->fragment_defines[refer_node->signature().mid(1)];
auto refer_fragment = this->fragment_defines[refer_node->referSignature()];
auto inst = std::make_shared<FragmentRef>(novel_node);
refer_fragment->appendRefers(inst);
line->append(inst);
@ -131,23 +132,57 @@ void tools_printer::build_storyline(std::shared_ptr<StoryLine> line, std::shared
}
}
void tools_printer::build_volumeline(std::shared_ptr<StoryVolume> line, std::shared_ptr<const ast_gen::ElementAccess> novel_node)
void tools_printer::build_volumeline(std::shared_ptr<StoryVolume> volume, std::shared_ptr<const ast_gen::ElementAccess> novel_node)
{
if (!novel_node) {
for (auto& inst_c : line->accessPeers()->children())
build_volumeline(line, inst_c);
for (auto& inst_c : volume->accessPeers()->children())
build_volumeline(volume, inst_c);
}
else {
if (example_novel::NovelNode::FragmentRefer == (example_novel::NovelNode)novel_node->element()->typeMark()) {
auto refer_node = std::dynamic_pointer_cast<const example_novel::FragmentRefers>(novel_node->element());
auto refer_fragment = this->fragment_defines[refer_node->signature().mid(1)];
auto refer_fragment = this->fragment_defines[refer_node->referSignature()];
auto inst = std::make_shared<FragmentRef>(novel_node);
refer_fragment->appendRefers(inst);
line->append(inst);
volume->append(inst);
return;
}
for (auto& inst_c : novel_node->children())
build_volumeline(line, inst_c);
build_volumeline(volume, inst_c);
}
}
void printer::tools_printer::fragments_anchors_define(const QList<std::shared_ptr<Fragment>>& list, const QDir & destdir) {
for (auto &it : list) {
auto address_x = QString::number((qulonglong)it->accessPeers()->element().get());
it->setHtmlRefer(destdir.absoluteFilePath(QString("%1.html").arg(address_x)));
}
}
std::function<void(const QList<std::shared_ptr<Element>>&, const QDir &)> refers_refresh =
[&](const QList<std::shared_ptr<Element>> &items, const QDir &destdir){
for (auto &item : items) {
auto refer = std::dynamic_pointer_cast<FragmentRef>(item);
if (refer) {
auto address_x = QString::number((qulonglong)refer->accessPeers()->element().get());
refer->setHtmlRefer(destdir.absoluteFilePath(QString("%1.html").arg(address_x)));
}
}
};
void printer::tools_printer::storylines_anchors_define(const QList<std::shared_ptr<StoryLine>>& list, const QDir & destdir) {
for (auto &it : list) {
auto address_x = QString::number((qulonglong)it->accessPeers()->element().get());
it->setHtmlRefer(destdir.absoluteFilePath(QString("%1.html").arg(address_x)));
refers_refresh(it->elements(), destdir);
}
}
void printer::tools_printer::volumes_anchors_define(const QList<std::shared_ptr<StoryVolume>>& list, const QDir & destdir) {
for (auto &it : list) {
auto address_x = QString::number((qulonglong)it->accessPeers()->element().get());
it->setHtmlRefer(destdir.absoluteFilePath(QString("%1.html").arg(address_x)));
refers_refresh(it->elements(), destdir);
}
}

View File

@ -57,7 +57,6 @@ namespace printer {
public:
StoryLine(std::shared_ptr<const ast_gen::ElementAccess> handle);
// ͨ¹ý Group ¼Ì³Ð
QString toHTML() const override;
@ -67,7 +66,6 @@ namespace printer {
public:
StoryVolume(std::shared_ptr<const ast_gen::ElementAccess> handle);
// ͨ¹ý Group ¼Ì³Ð
QString toHTML() const override;
@ -106,7 +104,7 @@ namespace printer {
class tools_printer {
private:
public:
QHash<QString, std::shared_ptr<Fragment>> fragment_defines;
QHash<QString, std::shared_ptr<StoryLine>> storyline_defines;
QHash<QString, std::shared_ptr<StoryVolume>> volume_defines;
@ -118,5 +116,9 @@ namespace printer {
void build_storyline(std::shared_ptr<StoryLine> line, std::shared_ptr<const ast_gen::ElementAccess> novel_node = nullptr);
void build_volumeline(std::shared_ptr<StoryVolume> line, std::shared_ptr<const ast_gen::ElementAccess> novel_node = nullptr);
void fragments_anchors_define(const QList<std::shared_ptr<Fragment>> &list, const QDir &destdir);
void storylines_anchors_define(const QList<std::shared_ptr<StoryLine>> &list, const QDir &destdir);
void volumes_anchors_define(const QList<std::shared_ptr<StoryVolume>> &list, const QDir &destdir);
};
}

View File

@ -7,8 +7,10 @@
#include <libtoken.h>
#include <syntax_novel.h>
#include <tokens_novel.h>
#include <QDir>
#include "novelparser.h"
#include "htmlprint.h"
using namespace example_novel;
@ -22,6 +24,19 @@ int main(int argc, char* argv[]) {
auto parser = std::make_shared<NovelParser>();
auto novel_accesstree = parser->parse(files);
printer::tools_printer tool;
tool.build_fragments(novel_accesstree);
tool.build_refers_network(novel_accesstree);
auto dest = QDir::current();
dest.mkdir("storylines");
dest.mkdir("volumes");
dest.mkdir("fragments");
tool.fragments_anchors_define(tool.fragment_defines.values(), QDir(dest.filePath("fragments")));
tool.storylines_anchors_define(tool.storyline_defines.values(), QDir(dest.filePath("storylines")));
tool.volumes_anchors_define(tool.volume_defines.values(), QDir(dest.filePath("volumes")));
std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_print =
[&](std::shared_ptr<const ast_gen::ElementAccess> node, int intend) {
auto name = node->element()->signature();

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:17.4728899Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.1001219Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:17.7556506Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.1782463Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -35,6 +35,10 @@ QString FragmentRefers::storyRefer() const { return story_ref; }
QString FragmentRefers::fragmentRefer() const { return fragm_ref; }
QString FragmentRefers::referSignature() const {
return story_ref + u8"&" + fragm_ref;
}
int FragmentRefers::typeMark() const { return (int)NovelNode::FragmentRefer; }
bool example_novel::FragmentRefers::isAnonymous() const

View File

@ -57,6 +57,7 @@ namespace example_novel
QString storyRefer() const;
QString fragmentRefer() const;
QString referSignature() const;
// SyntaxElement interface
public:

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:17.9061468Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.3344976Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:18.2310593Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.5226570Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -2,9 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:17.1430384Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.2094883Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-03-28T12:35:17.3463137Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-03-31T05:42:52.3032378Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>