summaryrefslogtreecommitdiff
path: root/src/tag.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/tag.hh')
-rw-r--r--src/tag.hh42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/tag.hh b/src/tag.hh
new file mode 100644
index 0000000..ce7f149
--- /dev/null
+++ b/src/tag.hh
@@ -0,0 +1,42 @@
+#ifndef TAG_HH
+#define TAG_HH
+
+#include <memory>
+#include <string>
+#include <string_view>
+
+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<Tag> 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> 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