#ifndef TAG_HH #define TAG_HH #include #include #include class Renderable { public: virtual ~Renderable() = default; virtual void render(std::string* out) const = 0; protected: Renderable() = default; }; class Tag : public virtual Renderable { public: static std::unique_ptr create(std::string name, std::string content = std::string()); virtual std::string_view name() const = 0; virtual bool empty() const = 0; virtual bool has_attr(std::string const& name) const = 0; virtual Tag* attr(std::string name, std::string value) = 0; virtual Tag* add(std::string content) = 0; // Does not clear attributes. virtual Tag* clear_content() = 0; // These return the new child tag, not this. virtual Tag* add(std::unique_ptr tag) = 0; virtual Tag* add_tag(std::string name, std::string content = std::string()); protected: Tag() = default; Tag(Tag const&) = delete; Tag& operator=(Tag const&) = delete; }; #endif // TAG_HH