pixwhile/blankie/serializer.h

37 lines
931 B
C
Raw Normal View History

2023-04-03 09:32:26 +00:00
#pragma once
#include <string>
#include <vector>
#include <variant>
#include <utility>
namespace blankie {
namespace html {
struct Element;
struct HTMLString {
HTMLString() = default;
explicit HTMLString(std::string str_) : str(std::move(str_)) {}
std::string str;
};
2023-04-03 09:32:26 +00:00
typedef std::pair<const char*, std::string> Attribute;
typedef std::variant<Element, const char*, std::string, HTMLString> Node;
2023-04-03 09:32:26 +00:00
struct Element {
const char* tag;
std::vector<Attribute> attributes;
std::vector<Node> nodes;
Element(const char* tag_) : tag(tag_) {}
Element(const char* tag_, std::vector<Node> nodes_)
: tag(tag_), nodes(std::move(nodes_)) {}
Element(const char* tag_, std::vector<Attribute> attributes_, std::vector<Node> nodes_)
: tag(tag_), attributes(std::move(attributes_)), nodes(std::move(nodes_)) {}
std::string serialize() const;
};
2023-04-10 14:06:27 +00:00
} // namespace html
} // namespace blankie