#ifndef STORYBOARDDOCUMENTPARSER_H
#define STORYBOARDDOCUMENTPARSER_H

#include "ParseFrame.h"
#include "SyntaxBase.h"
#include "XSyntaxBase.h"


namespace Parse {
    // =====================================================================
    /**
     * @brief 作品大纲节点
     */
    class NodeStoryBoard : public Result::NamedNode
    {
    public:
        NodeStoryBoard(Result::DocCore *doc, const QString &name);
        virtual ~NodeStoryBoard() = default;

        void setIndex(const QString &val);
        QString index() const;
        int indexValue(bool &valid) const;

        // DesNode interface
    public:
        virtual bool check(QList<ErrorMessage> &reasons) const override;
        virtual QString toString() const override;

    private:
        QString index_store;
    };

    /**
     * @brief 大纲解析器
     */
    class NodeStoryBoardParser : public Syntax::XSyntaxBase
    {
    public:
        NodeStoryBoardParser(Result::ParseCore *core);
        virtual ~NodeStoryBoardParser() = default;

        Result::ParseCore* project() const;

    private:
        Result::ParseCore *const project_ins;
    };

    // ======================================================================
    /**
     * @brief 情节引用块
     */
    class NodeStoryFragmentRefer : public Result::NamedNode
    {
    public:
        NodeStoryFragmentRefer(NodeStoryBoard *const parent_node, const QString &name);
        virtual ~NodeStoryFragmentRefer() = default;

    public:
        void setUnit(const QString &name);
        QString unit() const;

        QString fragment() const;

        // DesNode interface
    public:
        virtual bool check(QList<ErrorMessage> &reasons) const override;
        virtual QString toString() const override;

        virtual QList<QString> name() const override;

    private:
        QString fragment_name;
        QString unit_name_store;
    };

    class NodeStoryFragmentReferParser : public Syntax::XSyntaxBase
    {
    public:
        NodeStoryFragmentReferParser(XSyntaxBase *parent);

    };


    class StoryBoardDocumentParser : public Syntax::ParseFrame
    {
    public:
        StoryBoardDocumentParser(Result::ParseCore *core);
    };
}


#endif // STORYBOARDDOCUMENTPARSER_H
