⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functionlist.cpp

📁 表达式计算expression evaluate expression evaluate expression evaluate
💻 CPP
字号:
/******************************************************************************
文件名          :FunctionList.h
版本号          : 1.0
作者            : Amos Peng
生成日期        :2008-07-08
最近修改        :
功能描述        :自定义函数列表
函数列表        :

*******************************************************************************/
#include "FunctionList.h"
using namespace ExprEval;
CFunctionList::CFunctionList()
{
}
                    
// Destructor
CFunctionList::~CFunctionList()
{
    // Free function factories
    Clear();
}
            
// Add factory to list
void CFunctionList::Add(CFunctionFactory *factory)
{
    // Check it
    if(factory == 0)
        throw(CNullPointerException("FunctionList::Add"));
    
    // Make sure it does not exist
    size_type pos;
    
    for(pos  = 0; pos < m_functions.size(); pos++)
    {
        if(m_functions[pos]->GetName() == factory->GetName())
            throw(CAlreadyExistsException(factory->GetName()));
    }
    
    m_functions.push_back(factory);
}
    
// Create a node for a function
CFunctionNode* CFunctionList::Create(const string &name, CExpression *expr)
{
    // Make sure pointer exists
    if(expr == 0)
        throw(CNullPointerException("FunctionList::Create"));
    
    size_type pos;
    
    for(pos = 0; pos < m_functions.size(); pos++)
    {
        if(m_functions[pos]->GetName() == name)
        {
            // Found it
            return m_functions[pos]->Create(expr);
        }
    }
        
    // Not found
    return 0;
}
            
// FunctionList::AddDefaultFunctions is located in func.cpp
// along with the default function factories            
          
// Free function list
void CFunctionList::Clear()
{
    size_type pos;
    
    for(pos = 0; pos < m_functions.size(); pos++)
    {
        delete m_functions[pos];
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -