blob: 578545b0313c7725f50a901afcfcb10367cfbcff (
plain) (
blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#ifndef JINJA2CPP_SRC_FUNCTION_BASE_H
#define JINJA2CPP_SRC_FUNCTION_BASE_H
#include "expression_evaluator.h"
#include "internal_value.h"
namespace jinja2
{
class FunctionBase
{
public:
bool operator==(const FunctionBase& other) const
{
return m_args == other.m_args;
}
bool operator!=(const FunctionBase& other) const
{
return !(*this == other);
}
protected:
bool ParseParams(const std::initializer_list<ArgumentInfo>& argsInfo, const CallParamsInfo& params);
InternalValue GetArgumentValue(const std::string& argName, RenderContext& context, InternalValue defVal = InternalValue());
protected:
ParsedArgumentsInfo m_args;
};
//bool operator==(const FunctionBase& lhs, const FunctionBase& rhs)
//{
// return
//}
inline bool FunctionBase::ParseParams(const std::initializer_list<ArgumentInfo>& argsInfo, const CallParamsInfo& params)
{
bool result = true;
m_args = helpers::ParseCallParamsInfo(argsInfo, params, result);
return result;
}
inline InternalValue FunctionBase::GetArgumentValue(const std::string& argName, RenderContext& context, InternalValue defVal)
{
auto argExpr = m_args[argName];
return argExpr ? argExpr->Evaluate(context) : std::move(defVal);
}
} // namespace jinja2
#endif // JINJA2CPP_SRC_FUNCTION_BASE_H
|