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


C++ Var::getType方法代码示例

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


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

示例1: importFromJsonString

void Var::importFromJsonString(QString json)
{
        QJsonDocument parser = QJsonDocument::fromJson(json.toUtf8());
        Var var = fromQVariant(parser.toVariant());
        setType(var.getType());
        if(var.getType()=="list")
            List=var.List;
        if(var.getType()=="map")
            Map=var.Map;
        if(var.getType()=="string")
            String=var.String;
}
开发者ID:Aspenka,项目名称:SSD,代码行数:12,代码来源:var.cpp

示例2:

bool Var::operator == (Var var) const
{
	if(Type==var.getType())
    {
		if(Type=="string")
			if(String==var.getString())
				return true;
		if(Type=="list")
			if(List.size()==var.getList().size())
            {
				for(int i=0;i<List.size();i++)
					if(List[i]!=var.getList()[i])
						return false;
				return true;
            }
		if(Type=="map")
			if(Map.size()==var.getMap().size())
            {
                for(QMap<QString, Var>::const_iterator i = Map.constBegin();i != Map.constEnd();i++)
					if(i.value()!=var.getMap().value(i.key()))
						return false;
				return true;
            }
    }
	return false;
}
开发者ID:Aspenka,项目名称:SSD,代码行数:26,代码来源:var.cpp

示例3: importFromJsonFile

void Var::importFromJsonFile(QString filePath)
{
	QFile* file = new QFile(filePath);
	if(!file->open(QIODevice::ReadOnly))
    {
        qDebug()<<"Var::Var(QString filePath) - path is incorrect"<<filePath;
    }
	QString json = file->readAll();
	QJsonDocument parser = QJsonDocument::fromJson(json.toUtf8());
	Var var = fromQVariant(parser.toVariant());
	setType(var.getType());
	if(var.getType()=="list")
		List=var.List;		
	if(var.getType()=="map")
		Map=var.Map;		
	if(var.getType()=="string")
		String=var.String;		
}
开发者ID:Aspenka,项目名称:SSD,代码行数:18,代码来源:var.cpp

示例4: C

void bi::InputNetCDFBuffer::readMask0(const VarType type,
    Mask<ON_HOST>& mask) {
  typedef temp_host_matrix<real>::type temp_matrix_type;
  mask.resize(m.getNumVars(type), false);

  Var* var;
  int r;
  long start, len;

  /* sparse masks */
  for (r = 0; r < int(recDims.size()); ++r) {
    if (timeVars[r] < 0) {
      BOOST_AUTO(range, modelVars.equal_range(r));
      BOOST_AUTO(iter, range.first);
      BOOST_AUTO(end, range.second);

      start = 0;
      len = nc_inq_dimlen(ncid, recDims[r]);

      temp_matrix_type C(iter->second->getNumDims(), len);
      readCoords(coordVars[r], start, len, C);
      for (; iter != end; ++iter) {
        var = iter->second;
        if (var->getType() == type) {
          mask.addSparseMask(var->getId(), C.size2());
          serialiseCoords(var, C, mask.getIndices(var->getId()));
        }
      }
    }
  }

  /* dense masks */
  r = -1;  // for those vars not associated with a record dimension
  BOOST_AUTO(range, modelVars.equal_range(r));
  BOOST_AUTO(iter, range.first);
  BOOST_AUTO(end, range.second);

  for (; iter != end; ++iter) {
    var = iter->second;
    if (var->getType() == type) {
      mask.addDenseMask(var->getId(), var->getSize());
    }
  }
}
开发者ID:sbfnk,项目名称:LibBi,代码行数:44,代码来源:InputNetCDFBuffer.cpp

示例5: unite

void Var::unite(Var var)
{
	if(getType()!="map")
    {
        qDebug()<<"Var::unite current var is not a map!";
		return;
    }
	if(var.getType()!="map")
    {
        qDebug()<<"Var::unite passed var is not a map!";
		return;
    }
	Map.unite(var.Map);
}
开发者ID:Aspenka,项目名称:SSD,代码行数:14,代码来源:var.cpp

示例6: lowerTranspose

Stmt lowerTranspose(Var target, const IndexExpr* iexpr,
                    Environment* env, Storage* storage) {
  simit_iassert(isa<IndexedTensor>(iexpr->value));
  simit_iassert(isa<VarExpr>(to<IndexedTensor>(iexpr->value)->tensor));

  Var source = to<VarExpr>(to<IndexedTensor>(iexpr->value)->tensor)->var;
  auto sourceIndex = storage->getStorage(source).getTensorIndex();
  auto targetIndex = storage->getStorage(target).getTensorIndex();

  auto sourceType = source.getType().toTensor();
  auto iRange   = sourceType->getOuterDimensions()[0];

  Var  i("i",  Int);
  Var ij("ij", Int);
  Var  j("j",  Int);

  Var locVar(INTERNAL_PREFIX("locVar"), Int);
  Stmt locStmt = CallStmt::make({locVar}, intrinsics::loc(),
                                {Load::make(sourceIndex.getColidxArray(),ij), i,
                                 targetIndex.getRowptrArray(),
                                 targetIndex.getColidxArray()});
  Stmt body;
  auto blockType = *sourceType->getBlockType().toTensor();
  if (blockType.order() == 0) {  // Not blocked
    body = Store::make(target, locVar, Load::make(source, ij));
  }
  else {  // Blocked
    simit_iassert(blockType.order() == 2);
    Var ii("ii", Int);
    Var jj("jj", Int);
    auto d1 = blockType.getOuterDimensions()[0];
    auto d2 = blockType.getOuterDimensions()[1];
    Expr l1 = Length::make(d1);
    Expr l2 = Length::make(d2);

    body = Store::make(target, locVar*l1*l2 + ii*l2 + jj,
                       Load::make(source, ij*l1*l2 + ii*l2 + jj));

    body = For::make(jj, ForDomain(d2), body);
    body = For::make(ii, ForDomain(d1), body);
  }
  simit_iassert(body.defined());

  Expr start = Load::make(sourceIndex.getRowptrArray(), i);
  Expr stop  = Load::make(sourceIndex.getRowptrArray(), i+1);
  Stmt innerLoop  = ForRange::make(ij, start, stop, Block::make(locStmt, body));
  return For::make(i, iRange, innerLoop);
}
开发者ID:simit-lang,项目名称:simit,代码行数:48,代码来源:lower_transpose.cpp

示例7: append

void Var::append(Var var)
{
	if(Type=="list")
    {
		if(var.getType()=="list")
        {
			for(int i=0;i<var.size();i++)
				List.append(var[i]);
        }
		else
        {
			List.append(var);
        }
    }
	else
		qDebug()<<"Var::append - type is not list; Name = "<<Name<<"Type = "<<Type;
}
开发者ID:Aspenka,项目名称:SSD,代码行数:17,代码来源:var.cpp

示例8: blockCurrentSol

void Engine::blockCurrentSol() {
	if (outputs.size() == 0) NOT_SUPPORTED;
	Clause& c = *Reason_new(outputs.size());
	bool root_failure = true;
	for (int i = 0; i < outputs.size(); i++) {
		Var *v = (Var*) outputs[i];
		if (v->getType() == BOOL_VAR) {
			c[i] = ((BoolView*) outputs[i])->getValLit();
		} else {
			c[i] = ((IntVar*) outputs[i])->getValLit();
		}
		if (!sat.isRootLevel(var(c[i]))) root_failure = false;
		assert(sat.value(c[i]) == l_False);
	}
	if (root_failure) sat.btToLevel(0);
	sat.confl = &c;
}
开发者ID:geoffchu,项目名称:chuffed,代码行数:17,代码来源:engine.c

示例9: paramListsEqual

// When this function returns, tree must point to the last node in the SUB
// header (the return type).
bool Component::paramListsEqual(Token *&tree, Sub *sub) const {
    
    unsigned int index = 0;
    Var *var = sub->getVar(0);
    
    // Can't use an early return because of pre-requirement (see above).
    bool iseq = true;
    
    while (tree->id == DEF) {
        // Check if the pre-existing list is shorter
        if (!var) {
            iseq = false;
            tree = tree->next;
            continue;
        }
        
        const Type *type = getType(tree->child);
        std::string newname;
        
        if (!type)
            iseq = false;
        else if (*type != *var->getType())
            iseq = false;
        else if (!strEqualIdLookup(var->getName(),
                newname = tree->child->next->text)) {
        
            printf("warning: param names differ from DECLARE to SUB, "
                "using '%s' instead of '%s' (line %d)\n",
                tree->child->next->text, var->getName().c_str(),
                tree->child->next->loc.first_line);
            
            // MUST NOT call var->setName, otherwise sub's var map won't
            // get updated.
            if (!sub->setVarName(var->getName(), newname)) {
                printf("Just kidding; there was a conflict with that "
                    "name. I'm still gonna try to compile this, but you "
                    "should really consider synchronizing the names.\n");
            }
        }
        
        var = sub->getVar(++index);
        tree = tree->next;
    }
    
    SubType *subty = const_cast<SubType *>(
        static_cast<const SubType *>(sub->getType())
    );
    
    // Does it have var-args?
    if (tree->id == ELLIPSIS) {
        if ((subty->getFlags() & SubType::VARARGS) == 0)
            iseq = false;
        else if (tree->child) {
            // Is it an implicit len or null?
            if (tree->child->id == LEN &&
                    ((subty->getFlags() & SubType::VA_IMPLICIT_LEN) == 0))
                iseq = false;
            else if (tree->child->id == INTCONST &&
                    ((subty->getFlags() & SubType::VA_IMPLICIT_NULL) == 0))
                iseq = false;
        }
            
        tree = tree->next;
    } else {
        if ((subty->getFlags() & SubType::VARARGS) != 0)
            iseq = false;
    }
    
    assert(tree->id == AS && "no return type for sub");
    
    // If any of the params were not equal, it doesn't matter what the return
    // type is, and we can just return false here. Also make sure the
    // pre-existing list is the same length.
    if (!iseq || var)
        return false;
    
    // Make sure the return types are equal also.
    const Type *other_rettype = subty->getReturnType();
    
    // If you left off the return type from the SUB, it is carried over from
    // the declare, but a warning is shown.
    if (tree->child == 0) {
        if (*other_rettype != *void_type) {
            printf("warning: omitted return type, using '%s' (line %d)\n",
                other_rettype->getName().c_str(), tree->loc.first_line);
        }
        return true;
    }
    
    const Type *rettype = getType(tree->child);
    return rettype && *rettype == *other_rettype;
}
开发者ID:parkovski,项目名称:glazc,代码行数:94,代码来源:ast-build.cpp

示例10: print_controller_C

void print_controller_C(ostream& out, string component, const StateMachine& machine)
{
  out << "// Auto generated C++ code started by "<<__FILE__<<":"<<__LINE__<< endl;
  out << "// " << machine.getIdent() << ": " << machine.getShorthand() << endl;
  out << endl;
  out << "#include \"Global.h\"" << endl;
  out << "#include \"slicc_util.h\"" << endl;
  out << "#include \"" << component << "_Controller.h\"" << endl;
  out << "#include \"" << component << "_State.h\"" << endl;
  out << "#include \"" << component << "_Event.h\"" << endl;
  out << "#include \"Types.h\"" << endl;
  out << "#include \"Profiler.h\"" << endl;
  out << "#include \"Network.h\"" << endl;
  out << endl;

  out << "// static profiler defn" << endl;
  out << component << "_Profiler " << component << "_Controller::s_profiler;" << endl;
  out << endl;

  out << "// constructor" << endl;
  out << component << "_Controller::" << component << "_Controller(NodeID id, Network* network_ptr)" << endl;
  out << "{" << endl;
  out << "  m_id = id;" << endl;

  // Initialize member variables
  const Vector<Symbol*>& symbols = g_sym_table.getAllSymbols();
  for (int i=0; i < symbols.size(); i++) {
    Var* var = dynamic_cast<Var*>(symbols[i]);
    if (var == NULL || var->getMachine() != &machine) {
      continue;
    }
    out << "  // " << var->cIdent() << endl;
    if (var->existPair("network")) {
      // Network port object
      string network = var->lookupPair("network");
      string ordered =  var->lookupPair("ordered");
      string vnet =  var->lookupPair("virtual_network");
      
      out << "  m_" << var->cIdent() << "_ptr = network_ptr->get" 
          << network << "NetQueue(MachineType_" << var->getMachine()->getIdent() << ", m_id, " 
          << ordered << ", " << vnet << ");\n";
    } else if (var->getType()->existPair("primitive") || (dynamic_cast<Enum*>(var->getType()) != NULL)) {
      // Normal non-object
      out << "  m_" << var->cIdent() << "_ptr = new " << var->getType()->cIdent() << ";\n";
    } else {
      // Normal Object
      out << "  m_" << var->cIdent() << "_ptr = new " << var->getType()->cIdent();
      if (!var->getType()->existPair("non_obj")) {
        if (var->existPair("constructor_hack")) {
          string constructor_hack = var->lookupPair("constructor_hack");
          out << "(m_id, " << constructor_hack << ")";
        } else {
          out << "(m_id)";
        }
        out << ";\n";
      }
    }
    out << "  assert(m_" << var->cIdent() << "_ptr != NULL);" << endl;

    // Set to the default value
    if (var->existPair("default")) {
      out << "  (*m_" << var->cIdent() << "_ptr) = " << var->lookupPair("default") 
          << "; // Object default" << endl;
    } else if (var->getType()->hasDefault()) {
      out << "  (*m_" << var->cIdent() << "_ptr) = " << var->getType()->getDefault() 
          << "; // Type " << var->getType()->getIdent() << " default" << endl;
    }
    
    // Set ordering
    if (var->existPair("ordered")) {
      // A buffer
      string ordered =  var->lookupPair("ordered");
      out << "  m_" << var->cIdent() << "_ptr->setOrdering(" << ordered << ");\n";
    }
    
    // Set randomization
    if (var->existPair("random")) {
      // A buffer
      string value =  var->lookupPair("random");
      out << "  m_" << var->cIdent() << "_ptr->setRandomization(" << value << ");\n";
    }
    out << endl;
  }

  // Set the queue consumers
  for(int i=0; i < machine.numInPorts(); i++) {
    out << "  " << machine.getInPort(i).getCode() << ".setConsumer(this);" << endl;
  }

  out << endl;
  // Set the queue descriptions
  for(int i=0; i < machine.numInPorts(); i++) {
    out << "  " << machine.getInPort(i).getCode() 
        << ".setDescription(\"[Node \" + int_to_string(m_id) + \", " 
        << component << ", " << machine.getInPort(i).toString() << "]\");" << endl;
  }

  // Initialize the transition profiling
  out << endl;
  for(int i=0; i<machine.numTransitions(); i++) {
//.........这里部分代码省略.........
开发者ID:EgoIncarnate,项目名称:FeS2-with-DRAMSim2,代码行数:101,代码来源:machine_gen.C


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