#pragma once #include #include #include enum class LazyType { Title, Text, Image, }; class LazyElement { public: virtual LazyType GetType() const = 0; }; class LazyTitle : public LazyElement { private: std::string m_Title; std::uint8_t m_TitleLevel; public: LazyTitle(const std::string &title, const std::uint8_t level) : m_Title(title), m_TitleLevel(level) {} virtual LazyType GetType() const override { return LazyType::Title; }; const std::string &GetTitle() const { return m_Title; } int GetTitleLevel() const { return m_TitleLevel; } }; class LazyText : public LazyElement { private: std::string m_Text; public: LazyText(const std::string &text) : m_Text(text) {} virtual LazyType GetType() const override { return LazyType::Text; }; const std::string &GetText() const { return m_Text; } }; class LazyImage : public LazyElement { private: std::string m_ImageLink; std::string m_ImageAlt; public: LazyImage(const std::string &link, const std::string &alt) : m_ImageLink(link), m_ImageAlt(alt) {} virtual LazyType GetType() const override { return LazyType::Image; }; const std::string &GetAlt() const { return m_ImageAlt; } const std::string &GetLink() const { return m_ImageLink; } }; typedef std::vector> ElementList; class LazyFile { private: ElementList m_Elements; public: void AddImage(const std::string &link, const std::string &alt) { m_Elements.push_back(std::make_unique(link, alt)); } void AddTitle(const std::string &title, const std::uint8_t level) { m_Elements.push_back(std::make_unique(title, level)); } void AddText(const std::string& text) { m_Elements.push_back(std::make_unique(text)); } const ElementList& GetElements() const { return m_Elements; } }; std::string RenderHtml(const LazyFile& lazy); LazyFile ReadLazyFile(const std::string& filePath);