HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
skeleton_top_node.hpp
1// Copyright Take Vos 2020-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "skeleton_node.hpp"
8
9namespace hi::inline v1 {
10
12 statement_vector children;
13
14 skeleton_top_node(parse_location location) : skeleton_node(std::move(location)), children() {}
15
18 bool append(std::unique_ptr<skeleton_node> x) noexcept override
19 {
20 append_child(children, std::move(x));
21 return true;
22 }
23
24 void post_process(formula_post_process_context &context) override
25 {
26 if (ssize(children) > 0) {
27 children.back()->left_align();
28 }
29
30 for (hilet &child : children) {
31 child->post_process(context);
32 }
33 }
34
36 {
37 try {
38 return evaluate_children(context, children);
39
40 } catch (std::exception const &e) {
41 throw operation_error(std::format("{}: Could not evaluate.\n{}", location, e.what()));
42 }
43 }
44
45 std::string string() const noexcept override
46 {
47 hilet children_str = transform<std::vector<std::string>>(children, [](hilet &x) {
48 return x->string();
49 });
50 return std::format("<top {}>", join(children_str));
51 }
52};
53
54} // namespace hi::inline v1
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
A dynamic data type.
Definition datum.hpp:224
Definition formula_evaluation_context.hpp:16
Definition formula_post_process_context.hpp:19
Definition parse_location.hpp:18
Definition skeleton_node.hpp:16
Definition skeleton_top_node.hpp:11
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_top_node.hpp:35
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_top_node.hpp:18
T move(T... args)
T what(T... args)