HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
formula_filter_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 "formula_binary_operator_node.hpp"
8#include "formula_post_process_context.hpp"
9#include "formula_name_node.hpp"
10
11namespace tt {
12
15 formula_name_node* rhs_name;
16
19 {
20 rhs_name = dynamic_cast<formula_name_node*>(this->rhs.get());
21 if (rhs_name == nullptr) {
22 tt_error_info().set<"parse_location">(location);
23 throw parse_error(fmt::format("Expecting a name token on the right hand side of a filter operator. got {}.", rhs));
24 }
25 }
26
29
30 filter = context.get_filter(rhs_name->name);
31 if (!filter) {
32 tt_error_info().set<"parse_location">(location);
33 throw parse_error("Could not find filter .{}().", rhs_name->name);
34 }
35 }
36
37 datum evaluate(formula_evaluation_context& context) const override {
38 auto lhs_ = lhs->evaluate(context);
39 try {
40 return {filter(static_cast<std::string>(lhs_))};
41 } catch (...) {
42 error_info(true).set<"parse_location">(location);
43 throw;
44 }
45 }
46
47 std::string string() const noexcept override {
48 return fmt::format("({} ! {})", *lhs, *rhs);
49 }
50};
51
52}
Error information passed alongside an error code or exception.
Definition error_info.hpp:81
error_info & set(Arg &&value) noexcept
Set an information for a given tag.
Definition error_info.hpp:144
Exception thrown during parsing on an error.
Definition exception.hpp:21
Definition formula_binary_operator_node.hpp:11
void post_process(formula_post_process_context &context) override
Resolve function and method pointers.
Definition formula_binary_operator_node.hpp:18
Definition formula_evaluation_context.hpp:16
Definition formula_filter_node.hpp:13
void post_process(formula_post_process_context &context) override
Resolve function and method pointers.
Definition formula_filter_node.hpp:27
datum evaluate(formula_evaluation_context &context) const override
Evaluate an rvalue.
Definition formula_filter_node.hpp:37
Definition formula_name_node.hpp:11
Definition formula_post_process_context.hpp:18
Definition parse_location.hpp:16
T get(T... args)
T move(T... args)