| 58 | }; |
| 59 | |
| 60 | struct Element { |
| 61 | StringBox name; |
| 62 | std::vector<std::pair<StringBox, Value>> attributes; |
| 63 | std::vector<Element> children; |
| 64 | |
| 65 | Element(const char* name) : name(STRING_LITERAL(name)) {} |
| 66 | |
| 67 | template<typename T> |
| 68 | Element& attribute(const char* name, const T& value) { |
| 69 | attributes.emplace_back(std::make_pair(STRING_LITERAL(name), Value(value))); |
| 70 | return *this; |
| 71 | } |
| 72 | |
| 73 | Element& attribute(const char* name, const char* value) { |
| 74 | return attribute(name, STRING_LITERAL(value)); |
| 75 | } |
| 76 | |
| 77 | Element& child(Element&& child) { |
| 78 | children.emplace_back(std::move(child)); |
| 79 | return *this; |
| 80 | } |
| 81 | |
| 82 | Element& child(const Element& child) { |
| 83 | children.emplace_back(child); |
| 84 | return *this; |
| 85 | } |
| 86 | |
| 87 | Element& setChildren(const std::vector<Element>& children) { |
| 88 | this->children = children; |
| 89 | return *this; |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | struct RenderState { |
| 94 | RawViewNodeId elementId = 0; |