mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Add static constructor
This commit is contained in:
@ -35,15 +35,6 @@
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
std::map<std::wstring, std::vector<bool>> FutureFunctionArgs =
|
||||
{
|
||||
{
|
||||
L"_xlfn.DAYS",{0,1,1}
|
||||
},
|
||||
{
|
||||
L"_xlfn.NETWORKDAYS.INTL",{0, 0, 0, 1, 0}
|
||||
}
|
||||
};
|
||||
|
||||
const bool FutureFunctionParser::GetFutureFunction(std::wstring& functionName)
|
||||
{
|
||||
@ -52,7 +43,8 @@ namespace XLS
|
||||
{
|
||||
tempName = L"_xlfn." + tempName;
|
||||
}
|
||||
if(FutureFunctionArgs.find(tempName) != FutureFunctionArgs.end())
|
||||
auto functions = init();
|
||||
if(functions.FutureFunctions.find(tempName) != functions.FutureFunctions.end())
|
||||
{
|
||||
functionName = tempName;
|
||||
return true;
|
||||
@ -63,12 +55,25 @@ namespace XLS
|
||||
std::vector<bool> FutureFunctionParser::GetArgumentList( const std::wstring& functionName)
|
||||
{
|
||||
std::vector<bool> argVector;
|
||||
auto findedFunc = FutureFunctionArgs.find(functionName);
|
||||
if(findedFunc != FutureFunctionArgs.end())
|
||||
auto functions = init();
|
||||
auto findedFunc = functions.FutureFunctions.find(functionName);
|
||||
if(findedFunc != functions.FutureFunctions.end())
|
||||
{
|
||||
argVector = findedFunc->second;
|
||||
}
|
||||
return argVector;
|
||||
}
|
||||
|
||||
} // namespace XLS
|
||||
FutureFunctionParser& FutureFunctionParser::init()
|
||||
{
|
||||
static FutureFunctionParser parser;
|
||||
return parser;
|
||||
}
|
||||
|
||||
FutureFunctionParser::FutureFunctionParser()
|
||||
{
|
||||
FutureFunctions.emplace (L"_xlfn.DAYS", std::vector<bool>{0,1,1});
|
||||
FutureFunctions.emplace(L"_xlfn.NETWORKDAYS.INTL",std::vector<bool>{0, 0, 0, 1, 0});
|
||||
}
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
@ -45,6 +45,11 @@ public:
|
||||
static const bool GetFutureFunction(std::wstring& functionName);
|
||||
static std::vector<bool> GetArgumentList( const std::wstring& functionName);
|
||||
|
||||
private:
|
||||
FutureFunctionParser();
|
||||
static FutureFunctionParser& init();
|
||||
std::map<std::wstring, std::vector<bool>> FutureFunctions;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user