summaryrefslogtreecommitdiff
path: root/src/tag.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /src/tag.hh
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in memroy.
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