41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|||
|
|
|
||
|
|
#include "engine/evaluator.hpp"
|
||
|
|
|
||
|
|
#include <functional>
|
||
|
|
#include <memory>
|
||
|
|
#include <string>
|
||
|
|
#include <string_view>
|
||
|
|
#include <unordered_map>
|
||
|
|
#include <vector>
|
||
|
|
|
||
|
|
namespace htab {
|
||
|
|
|
||
|
|
using FunctionImpl =
|
||
|
|
std::function<EvalResult(const std::vector<std::shared_ptr<Expr>>& args, const EvalContext& ctx)>;
|
||
|
|
|
||
|
|
class FunctionRegistry {
|
||
|
|
public:
|
||
|
|
static const FunctionRegistry& instance();
|
||
|
|
|
||
|
|
const FunctionImpl* find(std::string_view upper_name) const;
|
||
|
|
size_t registered_count() const { return funcs_.size(); }
|
||
|
|
|
||
|
|
void register_fn(std::string name, FunctionImpl fn);
|
||
|
|
|
||
|
|
private:
|
||
|
|
FunctionRegistry();
|
||
|
|
|
||
|
|
std::unordered_map<std::string, FunctionImpl> funcs_;
|
||
|
|
};
|
||
|
|
|
||
|
|
void register_math_trig_functions(FunctionRegistry& reg);
|
||
|
|
void register_logical_functions(FunctionRegistry& reg);
|
||
|
|
void register_statistical_functions(FunctionRegistry& reg);
|
||
|
|
void register_lookup_functions(FunctionRegistry& reg);
|
||
|
|
void register_text_functions(FunctionRegistry& reg);
|
||
|
|
void register_datetime_functions(FunctionRegistry& reg);
|
||
|
|
void register_financial_functions(FunctionRegistry& reg);
|
||
|
|
void register_database_functions(FunctionRegistry& reg);
|
||
|
|
|
||
|
|
} // namespace htab
|