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


C++ AttributeIterator::hasNext方法代码示例

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


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

示例1: init

void HudScheduling::init( Ui::Menu_HUD* ui, AttributePtr<Attribute_Player> ptr_owner_player )
{
	parent = ui->label_scheduling_background->parentWidget();
	window = ui->label_scheduling_background;
	subWindow = ui->label_scheduling_subbackground;
	progressbar = ui->progressBar_scheduling_progressbar;
	advantageLabel = ui->label_priority_advantage;

	Float2 screenSize;
	screenSize.x = window->parentWidget()->width();
	screenSize.y = window->parentWidget()->height();

	// Compute sizes
	itemHeight = subWindow->height();
	itemWidth = itemHeight*0.8f;
	standardMargin = itemHeight * 0.5f;

	int maxWindowSize = parent->width() - (ui->groupBox_health->width() + ui->groupBox_ammo->width() * 3.3f);
	if(window->width() > maxWindowSize)
		window->resize( maxWindowSize , window->height());
	subWindow->resize(window->width() - 2*standardMargin, subWindow->height());
	progressbar->resize(window->width() - 2*standardMargin, progressbar->height());
	int windowHeight = standardMargin*2 + itemHeight + subWindow->height() + progressbar->height();
	window->resize(window->width(), windowHeight);
	advantageLabel->resize(itemWidth, advantageLabel->height());

	// Compute positions
	window->move(screenSize.x*0.5f - window->width()*0.5, screenSize.y - window->height() - 9);
	progressbar->move(window->x() + standardMargin, window->y() + standardMargin);
	subWindow->move(window->x() + standardMargin, progressbar->y() + progressbar->height() + standardMargin);
	
	advantageLabel->move(subWindow->x(), subWindow->y());


	//hide();
	ui->label_7->hide();
	ui->label_8->hide();
	//ui->label_priority_advantage->hide();
	progressbar->setMaximum(500);


	// Add players
	AttributeIterator<Attribute_Player> itrPlayer = ATTRIBUTE_MANAGER->player.getIterator();
	while(itrPlayer.hasNext())
	{
		AttributePtr<Attribute_Player> ptr_player = itrPlayer.getNext();
		//ptr_player->priority = 5;
		QLabel* l = new QLabel(parent);
		l->resize(itemWidth, standardMargin);
		l->move(subWindow->x() + 0.5f, subWindow->y() + 0.5f);

		// Set color based on player's color
		Float3 color = ptr_player->avatarColor;
		std::string str_backgroundColor	= "rgba("+Converter::IntToStr((int)(color.x * 255))+", "+Converter::IntToStr((int)(color.y * 255))+", "+ Converter::IntToStr((int)(color.z * 255)) +", 200);";
		std::string str_borderColor		= "rgba("+Converter::IntToStr((int)(color.x * 255))+", "+Converter::IntToStr((int)(color.y * 255))+", "+ Converter::IntToStr((int)(color.z * 255)) +", 255);";
		std::string str_sheet = "background: " + str_backgroundColor + "border: 1px solid rgba(0, 0, 0, 30); border-top: 2px solid rgba(255, 255, 255, 30); border-right: 2px solid rgba(255, 255, 255, 30);";
		l->setStyleSheet(QString(str_sheet.c_str()));

		l->show();

		// Save ref to owner player
		if(ptr_player == ptr_owner_player)
			ownerIndex = items.size();

		// Create item
		HudScheduling_Item item;
		item.label = l;
		item.ptr_player = ptr_player;
		item.setPosition(Float2(subWindow->x(), subWindow->y()));
		items.push_back(item);
	}

	// Show advantage label on top
	advantageLabel->raise();
}
开发者ID:L0mion,项目名称:xkill-source,代码行数:75,代码来源:HudScheduling.cpp

示例2: writeWithNamespaceSupport

bool DomWriter::writeWithNamespaceSupport(
   Element& e, OutputStream* os, int level, DynamicObject& nsPrefixMap)
{
   bool rval = true;

   if(level < 0)
   {
      level = mIndentLevel;
   }

   // add any entries to the current namespace prefix map
   if(e->hasMember("attributes") && e["attributes"]->getType() == Map)
   {
      AttributeIterator attrs = e["attributes"].getIterator();
      while(attrs->hasNext())
      {
         Attribute& attr = attrs->next();

         // check for an xml namespace prefix definition
         const char* attrName = attrs->getName();
         if(strncmp(attrName, "xmlns:", 6) == 0)
         {
            const char* uri = attr["value"]->getString();
            nsPrefixMap[uri] = attrName + 6;
         }
      }
   }

   // create element name, which may require using the namespace prefix map
   string elementName;
   if(e->hasMember("namespace"))
   {
      const char* ns = e["namespace"]->getString();
      if(nsPrefixMap->hasMember(ns))
      {
         // prepend prefix for given namespace
         elementName.append(nsPrefixMap[ns]->getString());
         elementName.push_back(':');
      }
   }
   elementName.append(e["name"]->getString());

   // open start element
   rval =
      ((mCompact || level == 0) ? true : os->write("\n", 1)) &&
      writeIndentation(os, level) &&
      os->write("<", 1) &&
      os->write(elementName.c_str(), elementName.length());

   // write attributes
   e["attributes"]->setType(Map);
   AttributeIterator attrs = e["attributes"].getIterator();
   while(rval && attrs->hasNext())
   {
      Attribute& attr = attrs->next();

      // create attribute name, which may require using the namespace prefix map
      string attrName;
      if(attr->hasMember("namespace"))
      {
         const char* ns = attr["namespace"]->getString();
         if(nsPrefixMap->hasMember(ns))
         {
            // prepend prefix for given namespace
            attrName.append(nsPrefixMap[ns]->getString());
            attrName.push_back(':');
         }
      }
      attrName.append(attr["name"]->getString());

      rval =
         os->write(" ", 1) &&
         os->write(attrName.c_str(), attrName.length()) &&
         os->write("=\"", 2) &&
         os->write(attr["value"]->getString(), attr["value"]->length()) &&
         os->write("\"", 1);
   }

   // close start element, if element is empty, use compact element
   e["data"]->setType(String);
   e["children"]->setType(Map);
   int dataLength = e["data"]->length();
   bool empty = (dataLength == 0 && e["children"]->length() == 0);
   rval = rval && (empty ? os->write("/>", 2) : os->write(">", 1));

   // write element data and children
   if(rval && !empty)
   {
      // write element children
      if(rval && e["children"]->length() > 0)
      {
         // serialize each child
         DynamicObjectIterator lists = e["children"].getIterator();
         while(rval && lists->hasNext())
         {
            DynamicObject& list = lists->next();
            list->setType(Array);
            ElementIterator children = list.getIterator();
            while(rval && children->hasNext())
            {
//.........这里部分代码省略.........
开发者ID:zengyuxing007,项目名称:monarch,代码行数:101,代码来源:DomWriter.cpp


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