OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLFormulaRegistry.hpp
Go to the documentation of this file.
1/*
2 * OpenXLSX-NX - Modern High-Performance C++ Excel Library
3 *
4 * Original work Copyright (c) 2018-2025, Kenneth Troldal Balslev and OpenXLSX contributors
5 * Modified work Copyright (c) 2026, Curry Tang and OpenXLSX-NX contributors
6 *
7 * Distributed under the BSD 3-Clause License.
8 * See LICENSE.md in the project root or https://opensource.org/licenses/BSD-3-Clause
9 */
10
11#ifndef OPENXLSX_XLFORMULAREGISTRY_HPP
12#define OPENXLSX_XLFORMULAREGISTRY_HPP
13
14#include <cstdint>
15#include <memory>
16#include <string>
17#include <string_view>
18#include <ankerl/unordered_dense.h>
19#include "XLFormulaFunction.hpp"
20
21namespace OpenXLSX
22{
24 using is_transparent = void;
25 auto operator()(std::string_view str) const noexcept -> uint64_t {
26 return ankerl::unordered_dense::hash<std::string_view>{}(str);
27 }
28 };
29
30 class XLFormulaRegistry
31 {
32 public:
33 static XLFormulaRegistry& getInstance();
34
35 void registerFunction(std::string name, std::shared_ptr<XLFormulaFunction> func);
36
37 const XLFormulaFunction* lookup(std::string_view name) const;
38
39 const ankerl::unordered_dense::map<std::string, std::shared_ptr<XLFormulaFunction>, FormulaStringViewHash, std::equal_to<>>& getFunctions() const;
40
41 private:
42 XLFormulaRegistry() = default;
43 ankerl::unordered_dense::map<std::string, std::shared_ptr<XLFormulaFunction>, FormulaStringViewHash, std::equal_to<>> m_functions;
44 };
45
46 // Linker-safe group registration declarations
56}
57
58#endif // OPENXLSX_XLFORMULAREGISTRY_HPP
Abstract formula function interface (session-aware, array-capable).
Definition XLFormulaFunction.hpp:28
Definition XLFormulaRegistry.hpp:31
void registerFunction(std::string name, std::shared_ptr< XLFormulaFunction > func)
Definition XLFormulaRegistry.cpp:36
static XLFormulaRegistry & getInstance()
Definition XLFormulaRegistry.cpp:18
const ankerl::unordered_dense::map< std::string, std::shared_ptr< XLFormulaFunction >, FormulaStringViewHash, std::equal_to<> > & getFunctions() const
Definition XLFormulaRegistry.cpp:85
const XLFormulaFunction * lookup(std::string_view name) const
Definition XLFormulaRegistry.cpp:44
Definition IXLCellProvider.hpp:24
void registerTextFunctions(XLFormulaRegistry &registry)
Definition XLFormulaText.cpp:365
void registerInfoFunctions(XLFormulaRegistry &registry)
Definition XLFormulaInfo.cpp:756
void registerLogicalFunctions(XLFormulaRegistry &registry)
Definition XLFormulaLogical.cpp:147
void registerDateTimeFunctions(XLFormulaRegistry &registry)
Definition XLFormulaDateTime.cpp:351
void registerMathFunctions(XLFormulaRegistry &registry)
Definition XLFormulaMath.cpp:1226
void registerFinancialFunctions(XLFormulaRegistry &registry)
Definition XLFormulaFinancial.cpp:339
void registerStatisticalFunctions(XLFormulaRegistry &registry)
Definition XLFormulaStatistical.cpp:1399
void registerArrayFunctions(XLFormulaRegistry &registry)
Definition XLFormulaArray.cpp:581
void registerEngineeringFunctions(XLFormulaRegistry &registry)
Definition XLFormulaEngineering.cpp:641
Definition XLFormulaRegistry.hpp:23
void is_transparent
Definition XLFormulaRegistry.hpp:24
auto operator()(std::string_view str) const noexcept -> uint64_t
Definition XLFormulaRegistry.hpp:25