File size: 733 Bytes
17f5b5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include "binding_property.h"
#include "cppgen.h"

template <class T>
T bindable<T>::eval(const UIContext& ctx) const {
    if (empty())
        return {};
    if (has_value())
        return value();
    const auto *var = ctx.codeGen->GetVar(str);
    if (var) {
        T val;
        std::istringstream is(var->init);
        if (is >> std::boolalpha >> val)
            return val;
    }
    return {};
}

template <class T>
T field_ref<T>::eval(const UIContext &ctx) const
{
    if (empty())
        return {};
    const auto *var = ctx.codeGen->GetVar(str);
    if (!var)
        return {};
    T val;
    std::istringstream is(var->init);
    if (is >> std::boolalpha >> val)
        return val;
    return {};
}