HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
skeleton_placeholder_node.hpp
1// Copyright Take Vos 2020.
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
14
16 skeleton_node(std::move(location)), expression(std::move(expression))
17 {
18 }
19
20 [[nodiscard]] bool should_left_align() const noexcept override
21 {
22 return false;
23 }
24
25 void post_process(formula_post_process_context &context) override
26 {
27 try {
28 expression->post_process(context);
29
30 } catch (std::exception const &e) {
31 throw operation_error(std::format("{}: Could not post process placeholder.\n{}", location, e.what()));
32 }
33 }
34
35 std::string string() const noexcept override
36 {
37 return std::format("<placeholder {}>", *expression);
38 }
39
40 datum evaluate(formula_evaluation_context &context) override
41 {
42 hilet output_size = context.output_size();
43
44 hilet tmp = evaluate_expression(context, *expression, location);
45 if (tmp.is_break()) {
46 throw operation_error(std::format("{}: Found #break not inside a loop statement.", location));
47
48 } else if (tmp.is_continue()) {
49 throw operation_error(std::format("{}: Found #continue not inside a loop statement.", location));
50
51 } else if (tmp.is_undefined()) {
52 return {};
53
54 } else {
55 // When a function returns, it should not have written data to the output.
56 context.set_output_size(output_size);
57 context.write(static_cast<std::string>(tmp));
58 return {};
59 }
60 }
61};
62
63} // 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_placeholder_node.hpp:12
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_placeholder_node.hpp:40
bool should_left_align() const noexcept override
Should any spaces on the left side of a statement be removed?
Definition skeleton_placeholder_node.hpp:20
T move(T... args)
T what(T... args)