#pragma once

#include "File.h"

#include "TemplateNode.h"

#include <vector>

class TemplateNode;
class TemplateTextBody;

class TemplateFile
{
public:
    TemplateFile(const Path& path);

    ~TemplateFile();

    std::string dumpContent();

    std::string getName() const;

    TemplateNode* getContent() const;

    bool hasLoaded() const;

    void loadContent();

private:
    void onTextBodyFinished(std::string working_string = {});

    void processLine(const std::string& line);

    void onFoundStatement(const std::string& statement_string);

    void onFoundBlock(const std::vector<std::string> args);

    void onFoundEndBlock(const std::vector<std::string> args);

    void onFoundExtends(const std::vector<std::string> args);

    void onFoundExpression(const std::string& expression_string);

    Path mPath;
    std::string mParentName;
    std::vector<std::string> mRawContent;
    bool mHasLoaded{false};

    unsigned mWorkingLine{ 0 };
    std::unique_ptr<TemplateNode> mRootNode;
    TemplateNode* mWorkingNode{ nullptr };
    std::unique_ptr<TemplateTextBody> mWorkingTextBody;
};
