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 throw parse_error("{}: Expecting a name token on the right hand side of a filter operator. got {}.", location, *rhs);
23 }
24 }
25
28
29 filter = context.get_filter(rhs_name->name);
30 if (!filter) {
31 throw parse_error("{}: Could not find filter .{}().", location, rhs_name->name);
32 }
33 }
34
35 datum evaluate(formula_evaluation_context& context) const override {
36 auto lhs_ = lhs->evaluate(context);
37 try {
38 return {filter(static_cast<std::string>(lhs_))};
39 } catch (std::exception const &e) {
40 throw operation_error("{}: Can not evaluate filter.\n{}", location, e.what());
41 }
42 }
43
44 std::string string() const noexcept override {
45 return std::format("({} ! {})", *lhs, *rhs);
46 }
47};
48
49}
Exception thrown during parsing on an error.
Definition exception.hpp:26
Exception thrown during execution of a dynamic operation.
Definition exception.hpp:42
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:26
datum evaluate(formula_evaluation_context &context) const override
Evaluate an rvalue.
Definition formula_filter_node.hpp:35
Definition formula_name_node.hpp:11
Definition formula_post_process_context.hpp:19
Definition parse_location.hpp:17
T get(T... args)
T move(T... args)
T what(T... args)