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#include "../macros.hpp"
9
10namespace hi::inline v1 {
11
13 statement_vector children;
14
15 skeleton_top_node(parse_location location) : skeleton_node(std::move(location)), children() {}
16
19 bool append(std::unique_ptr<skeleton_node> x) noexcept override
20 {
21 append_child(children, std::move(x));
22 return true;
23 }
24
25 void post_process(formula_post_process_context &context) override
26 {
27 if (ssize(children) > 0) {
28 children.back()->left_align();
29 }
30
31 for (hilet &child : children) {
32 child->post_process(context);
33 }
34 }
35
36 datum evaluate(formula_evaluation_context &context) override
37 {
38 try {
39 return evaluate_children(context, children);
40
41 } catch (std::exception const &e) {
42 throw operation_error(std::format("{}: Could not evaluate.\n{}", location, e.what()));
43 }
44 }
45
46 std::string string() const noexcept override
47 {
48 hilet children_str = transform<std::vector<std::string>>(children, [](hilet &x) {
49 return x->string();
50 });
51 return std::format("<top {}>", join(children_str));
52 }
53};
54
55} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Definition parse_location.hpp:18
Definition skeleton_node.hpp:16
Definition skeleton_top_node.hpp:12
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_top_node.hpp:36
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_top_node.hpp:19
T move(T... args)
T what(T... args)