当前位置: 首页>>代码示例>>C++>>正文


C++ Struct::addField方法代码示例

本文整理汇总了C++中Struct::addField方法的典型用法代码示例。如果您正苦于以下问题:C++ Struct::addField方法的具体用法?C++ Struct::addField怎么用?C++ Struct::addField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Struct的用法示例。


在下文中一共展示了Struct::addField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Struct

mxArray *mxCreateStructArray(int ndim, const int *dims, int nfields, const char **field_names)
{
    Struct *ptr = new Struct(ndim, (int *)dims);
    for (int i = 0; i < nfields; i++)
    {
        wchar_t *name = to_wide_string(field_names[i]);
        ptr->addField(name);
        FREE(name);
    }
    return (mxArray *)ptr;
}
开发者ID:scitao,项目名称:scilab,代码行数:11,代码来源:mexlib.cpp

示例2: mxAddField

int mxAddField(mxArray *ptr, const char *fieldname)
{
    if (!mxIsStruct(ptr))
    {
        return -1;
    }
    Struct *pa = (Struct *)ptr;
    wchar_t *wfieldname = to_wide_string(fieldname);
    pa->addField(wfieldname);
    return mxGetFieldNumber(ptr, fieldname);
}
开发者ID:scitao,项目名称:scilab,代码行数:11,代码来源:mexlib.cpp

示例3: sci_testAnalysis

/*--------------------------------------------------------------------------*/
Function::ReturnValue sci_testAnalysis(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
    if (in.size() == 0)
    {
        Scierror(999, _("%s: Wrong number of input arguments: at least %d expected.\n"), "testAnalysis", 1);
        return Function::Error;
    }

    // check that arguments are a string
    unsigned int i = 1;
    Location loc;
    ast::exps_t * args = new exps_t();
    args->reserve(in.size() - 1);
    for (const auto arg : in)
    {
        if (!arg->isString() || arg->getAs<types::String>()->getSize() != 1)
        {
            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "testAnalysis", i);
            return Function::Error;
        }
        if (i > 1)
        {
            symbol::Symbol sym(arg->getAs<types::String>()->get(0));
            args->emplace_back(new ast::SimpleVar(loc, sym));
        }
        ++i;
    }

    symbol::Symbol sym(in[0]->getAs<types::String>()->get(0));
    ast::SimpleVar * var = new ast::SimpleVar(loc, sym);
    ast::CallExp ce(loc, *var, *args);

    analysis::AnalysisVisitor analysis;
    ce.accept(analysis);

    //analysis.print_info();

    analysis::TIType & t = analysis.getResult().getType();
    Struct * pOut = new Struct(1, 1);
    pOut->addField(L"type");
    pOut->get(0)->set(L"type", new String(analysis::TIType::toString(t.type).c_str()));

    pOut->addField(L"rows");
    if (t.rows.isConstant())
    {
        pOut->get(0)->set(L"rows", new Double(t.rows.getConstant()));
    }
    else
    {
        pOut->get(0)->set(L"rows", new Double(analysis::tools::NaN()));
    }

    pOut->addField(L"cols");
    if (t.cols.isConstant())
    {
        pOut->get(0)->set(L"cols", new Double(t.cols.getConstant()));
    }
    else
    {
        pOut->get(0)->set(L"cols", new Double(analysis::tools::NaN()));
    }
    out.push_back(pOut);

    //ast::DebugVisitor debugMe;
    //pExp->accept(debugMe);

    //ast::PrintVisitor printMe(std::wcout);
    //pExp->accept(printMe);

    return Function::OK;
}
开发者ID:scitao,项目名称:scilab,代码行数:72,代码来源:sci_testAnalysis.cpp


注:本文中的Struct::addField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。