94 lines
3.1 KiB
C++
94 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "libparse.h"
|
|
#include <ast_novel.h>
|
|
|
|
namespace example_novel {
|
|
|
|
class LIBPARSE_EXPORT FragmentExistsCheck : public lib_parse::CheckProvider {
|
|
private:
|
|
void exists_check(std::shared_ptr<const ast_gen::GlobalElement> root, std::shared_ptr<const ast_gen::ElementAccess> target) const;
|
|
|
|
public:
|
|
// 通过 CheckProvider 继承
|
|
virtual void validCheck(std::shared_ptr<const ast_gen::ElementAccess> root) const override;
|
|
virtual QString name() const override {
|
|
return u8"FragmentExistsCheck";
|
|
}
|
|
};
|
|
|
|
|
|
class StorySortHelper;
|
|
class FragmentSortHelper;
|
|
class LIBPARSE_EXPORT FragmentOrdersCheck : public lib_parse::CheckProvider {
|
|
protected:
|
|
QList<std::shared_ptr<StorySortHelper>> stories_list;
|
|
|
|
void elements_link_build(const QList<std::shared_ptr<StorySortHelper>>& stories);
|
|
void sort_cycle_check(const QList<std::shared_ptr<FragmentSortHelper>>& tracks, std::shared_ptr<FragmentSortHelper> current,
|
|
int story_sort_source);
|
|
|
|
std::shared_ptr<FragmentSortHelper> peaks_appoint_element(std::shared_ptr<FragmentSortHelper> refer_n) const;
|
|
|
|
// CheckProvider interface
|
|
public:
|
|
virtual void validCheck(std::shared_ptr<const ast_gen::ElementAccess> root) const override;
|
|
virtual QString name() const override {
|
|
return u8"FragmentOrdersCheck";
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @brief 情节排序辅助类
|
|
*/
|
|
class LIBPARSE_EXPORT FragmentSortHelper : public std::enable_shared_from_this<FragmentSortHelper> {
|
|
public:
|
|
enum class Type {
|
|
REFER, ELEMENT
|
|
};
|
|
|
|
FragmentSortHelper(std::shared_ptr<const ast_gen::ElementAccess> node_bind, int story_sort);
|
|
|
|
Type nodeType() const;
|
|
std::shared_ptr<const ast_gen::ElementAccess> nodeBind() const;
|
|
int storySort() const;
|
|
|
|
std::shared_ptr<FragmentSortHelper> next() const;
|
|
void attachNext(std::shared_ptr<FragmentSortHelper> fragment);
|
|
|
|
void assignSibling(std::shared_ptr<FragmentSortHelper> other);
|
|
QList<std::shared_ptr<FragmentSortHelper>> siblings() const;
|
|
|
|
|
|
private:
|
|
Type type_marks;
|
|
int story_sort;
|
|
std::shared_ptr<const ast_gen::ElementAccess> element_bind;
|
|
std::shared_ptr<FragmentSortHelper> next_attachment;
|
|
QList<std::shared_ptr<FragmentSortHelper>> siblings_store;
|
|
};
|
|
|
|
/**
|
|
* @brief 故事排序辅助类
|
|
*/
|
|
class LIBPARSE_EXPORT StorySortHelper {
|
|
private:
|
|
std::shared_ptr<const ast_gen::ElementAccess> story_bind;
|
|
std::shared_ptr<FragmentSortHelper> fragments_bind;
|
|
|
|
public:
|
|
StorySortHelper(std::shared_ptr<const ast_gen::ElementAccess> story_bind);
|
|
|
|
std::shared_ptr<const example_novel::StoryDefine> storyElement() const;
|
|
QString storyName() const;
|
|
int sortValue() const;
|
|
|
|
std::shared_ptr<FragmentSortHelper> fragmentSort() const;
|
|
void attachFragmentSort(std::shared_ptr<FragmentSortHelper> refer);
|
|
|
|
std::shared_ptr<FragmentSortHelper> fragment(const QString& name) const;
|
|
};
|
|
|
|
|
|
} // namespace example_novel
|