本文整理汇总了C++中Struct::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Struct::get方法的具体用法?C++ Struct::get怎么用?C++ Struct::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Struct
的用法示例。
在下文中一共展示了Struct::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
mxArray *mxGetFieldByNumber(const mxArray *ptr, int lindex, int field_number)
{
if (!mxIsStruct(ptr))
{
return NULL;
}
if (lindex >= mxGetNumberOfElements(ptr) || lindex < 0)
{
return NULL;
}
if (field_number >= mxGetNumberOfFields(ptr) || field_number < 0)
{
return NULL;
}
Struct *pa = (Struct *)ptr;
String *names = pa->getFieldNames();
SingleStruct *s = pa->get(lindex);
return (mxArray *)s->get(names->get(field_number));
}
示例2: 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;
}