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


C++ xml_node::attribute方法代码示例

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


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

示例1: handler

	ProcessResult MsgTypeIqProcessHandler::handler(SessionPtr sessionPtr, const xml_node& node){
		ProcessResult result;
		ostringstream os;
		sessionPtr->delAllSupportType();
		for(xml_node msgType = node.first_child(); msgType; msgType = msgType.next_sibling()){
			if(strcmp(msgType.name(), "msgType") != 0){
				continue;
			}
			string msgTypeStr = msgType.child_value();
			boost::trim(msgTypeStr);
			if(msgTypeStr == "chat"){
				sessionPtr->addSupportType(MessageType::CHAT);
			} else if (msgTypeStr == "feed"){
				sessionPtr->addSupportType(MessageType::FEED);
			} else if (msgTypeStr == "notify"){
				sessionPtr->addSupportType(MessageType::NOTIFY);
			}
		}

		string id = node.attribute("id").value();
		string from = node.attribute("from").value();

		result.setCode(ProcessResult::HAS_RESPONSE);
		os << "<iq id='" << id << "' to='" << from << "' type='result'>"
			<< "<success/></iq>";
		result.setMsg(os.str());
		return result;
	}
开发者ID:xiaoyu-real,项目名称:Test,代码行数:28,代码来源:MsgTypeIqProcessHandler.cpp

示例2: parseBlackAreas

void Camera::parseBlackAreas(xml_node &cur) {
  if (isTag(cur.name(), "Vertical")) {

    int x = cur.attribute("x").as_int(-1);
    if (x < 0) {
      ThrowCME("Invalid x coordinate in vertical BlackArea of in camera %s %s", make.c_str(), model.c_str());
    }

    int w = cur.attribute("width").as_int(-1);
    if (w < 0) {
      ThrowCME("Invalid width in vertical BlackArea of in camera %s %s", make.c_str(), model.c_str());
    }

    blackAreas.push_back(BlackArea(x, w, true));

  } else if (isTag(cur.name(), "Horizontal")) {

    int y = cur.attribute("y").as_int(-1);
    if (y < 0) {
      ThrowCME("Invalid y coordinate in horizontal BlackArea of in camera %s %s", make.c_str(), model.c_str());
    }

    int h = cur.attribute("height").as_int(-1);
    if (h < 0) {
      ThrowCME("Invalid width in horizontal BlackArea of in camera %s %s", make.c_str(), model.c_str());
    }
    blackAreas.push_back(BlackArea(y, h, false));
  }
}
开发者ID:acarrasco,项目名称:darktable,代码行数:29,代码来源:Camera.cpp

示例3: parseCFA

void Camera::parseCFA(xml_node &cur) {
  if (isTag(cur.name(), "ColorRow")) {
    int y = cur.attribute("y").as_int(-1);
    if (y < 0 || y >= cfa.size.y) {
      ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
    }
    const char* key = cur.first_child().value();
    if ((int)strlen(key) != cfa.size.x) {
      ThrowCME("Invalid number of colors in definition for row %d in camera %s %s. Expected %d, found %d.", y, make.c_str(), model.c_str(),  cfa.size.x, strlen(key));
    }
    for (int x = 0; x < cfa.size.x; x++) {
    	char v = (char)tolower((int)key[x]);
    	if (v == 'g')
      	cfa.setColorAt(iPoint2D(x, y), CFA_GREEN);
    	else if (v == 'r')
      	cfa.setColorAt(iPoint2D(x, y), CFA_RED);
    	else if (v == 'b')
      	cfa.setColorAt(iPoint2D(x, y), CFA_BLUE);
    	else if (v == 'f')
      	cfa.setColorAt(iPoint2D(x, y), CFA_FUJI_GREEN);
    	else if (v == 'c')
      	cfa.setColorAt(iPoint2D(x, y), CFA_CYAN);
    	else if (v == 'm')
      	cfa.setColorAt(iPoint2D(x, y), CFA_MAGENTA);
    	else if (v == 'y')
      	cfa.setColorAt(iPoint2D(x, y), CFA_YELLOW);
      else 
        supported = FALSE;
    }
  }
  if (isTag(cur.name(), "Color")) {
    int x = cur.attribute("x").as_int(-1);
    if (x < 0 || x >= cfa.size.x) {
      ThrowCME("Invalid x coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
    }

    int y = cur.attribute("y").as_int(-1);
    if (y < 0 || y >= cfa.size.y) {
      ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
    }

    const char* key = cur.first_child().value();
    if (isTag(key, "GREEN"))
      cfa.setColorAt(iPoint2D(x, y), CFA_GREEN);
    else if (isTag(key, "RED"))
      cfa.setColorAt(iPoint2D(x, y), CFA_RED);
    else if (isTag(key, "BLUE"))
      cfa.setColorAt(iPoint2D(x, y), CFA_BLUE);
    else if (isTag(key, "FUJIGREEN"))
      cfa.setColorAt(iPoint2D(x, y), CFA_FUJI_GREEN);
    else if (isTag(key, "CYAN"))
      cfa.setColorAt(iPoint2D(x, y), CFA_CYAN);
    else if (isTag(key, "MAGENTA"))
      cfa.setColorAt(iPoint2D(x, y), CFA_MAGENTA);
    else if (isTag(key, "YELLOW"))
      cfa.setColorAt(iPoint2D(x, y), CFA_YELLOW);
  }
}
开发者ID:acarrasco,项目名称:darktable,代码行数:58,代码来源:Camera.cpp

示例4: Configure

	bool Camera::Configure(xml_node xml)
	{
		this->chip			= xml.attribute("chip").as_string();
		this->contextCount	= xml.attribute("contexts").as_int(1);
		this->hdr			= xml.attribute("hdr").as_bool();
		this->sizeByRange	= xml.attribute("sizeByRange").as_bool();
		this->addressSize	= xml.attribute("addressSize").as_int(1);
		this->bayerMode		= xml.attribute("bayer").as_int(0);

		for (auto &child : xml.children("register"))
		{
			int address = strtol(child.attribute("address").as_string("0x00"), nullptr, 0);

			this->registers[address] = { child, &this->transport, this->addressSize };
		}

		// Two separate loops, because the population of the register list involves
		// growing memory and therefore any references taken for the features would
		// become invalid.
		for (auto &child : xml.children("register"))
		{
			int address = strtol(child.attribute("address").as_string("0x00"), nullptr, 0);

			for (auto &feature : child.children("feature"))
			{
				this->features[feature.attribute("name").as_string()] = { feature, &this->registers[address] };
			}
		}

		for (auto &child : xml.children("alias"))
		{
			string key		= child.attribute("name").as_string();
			string feature	= child.attribute("feature").as_string();
			int context		= child.attribute("context").as_int(-1);

			if (!key.empty() && !feature.empty() && this->features.count(feature))
			{
				if (context < 0)
				{
					// If context hasn't been assigned then it should be copied across all contexts
					for (int i=0; i<this->contextCount; i++)
					{
						this->aliases[i].Set(key, this->features[feature]);
					}
				}
				else if (context < this->contextCount)
				{
					this->aliases[context].Set(key, this->features[feature]);
				}
			}
		}

		return this->features.size();
	}
开发者ID:emergent-design,项目名称:libpsinc,代码行数:54,代码来源:Camera.cpp

示例5:

/**
 * Set an attribute on an XML node.
 * In theory, XML nodes have an ordered collection of named attributes, duplicates
 * allowed. In practice, we're using it as an unordered string=>string dictionary.
 */
template<class T> static void set_attribute(xml_node &node, const char *key, T newValue)
{
	if(node.attribute(key).empty())
	{
		node.append_attribute(key).set_value(newValue);
	}
	else
	{
		node.attribute(key).set_value(newValue);
	}
}
开发者ID:unclok,项目名称:Perception,代码行数:16,代码来源:ProxyHelper.cpp

示例6:

hw_Button::hw_Button( xml_node button )
{
	bname=button.attribute("name").value();
	baction=button.attribute("action").value();
	P=button.child_value("P");
	DDR=button.child_value("DDR");
	PIN=button.child_value("PIN");
	PORT=button.child_value("PORT");
	if( button.child_value("Active")=="high" )
		active=high;
	else
		active=low;
}
开发者ID:kiranrajmohan,项目名称:lcd-menu-creator,代码行数:13,代码来源:hw_Button.cpp

示例7: loadNode

void AlphaInputBox::loadNode(xml_node node) {

	TextBox::loadNode(node);

	if (node.attribute("default") != NULL) {

		string def = node.attribute("default").as_string();
		wstringstream wss;
		wss << def.c_str();
		userInput = wss.str();

	}
}
开发者ID:TheDizzler,项目名称:RPGEngine,代码行数:13,代码来源:AlphaInputBox.cpp

示例8: parseStandardMaterial

void TgcSceneParser::parseStandardMaterial(TgcMaterialData* material, const xml_node &matNode)
{
	material->name = matNode.attribute("name").as_string();
    material->type = matNode.attribute("type").as_string();
	material->subMaterialsCount = 0;

    //Material values
	string ambientStr = matNode.child("ambient").child_value();
    TgcParserUtils::parseFloat4Array(ambientStr, material->ambientColor);
    TgcParserUtils::divFloatArrayValues(material->ambientColor, 4, 255.0f);

    string diffuseStr = matNode.child("diffuse").child_value();
    TgcParserUtils::parseFloat4Array(diffuseStr, material->diffuseColor);
    TgcParserUtils::divFloatArrayValues(material->diffuseColor, 4, 255.0f);

    string specularStr = matNode.child("specular").child_value();
    TgcParserUtils::parseFloat4Array(specularStr, material->specularColor);
    TgcParserUtils::divFloatArrayValues(material->specularColor, 4, 255.0f);

    string opacityStr = matNode.child("opacity").child_value();
    material->opacity = TgcParserUtils::parseFloat(opacityStr) / 100.0f;

    xml_node alphaBlendEnableNode = matNode.child("alphaBlendEnable");
    if (alphaBlendEnableNode != NULL)
    {
        material->alphaBlendEnable = TgcParserUtils::parseBool(alphaBlendEnableNode.child_value());
    }
            
	//Bitmap values
    xml_node bitmapNode = matNode.child("bitmap");
    if (bitmapNode != NULL)
    {
		material->fileName = bitmapNode.child_value();

        //TODO: formatear correctamente TILING y OFFSET
		string uvTilingStr = bitmapNode.attribute("uvTiling").as_string();
        TgcParserUtils::parseFloat2Array(uvTilingStr, material->uvTiling);

        string uvOffsetStr = bitmapNode.attribute("uvOffset").as_string();
        TgcParserUtils::parseFloat2Array(uvOffsetStr, material->uvOffset);
    }
    else
    {
        material->fileName = "";
        //material.uvTiling = null;
        //material.uvOffset = null;
    }
}
开发者ID:dgu123,项目名称:Janua,代码行数:48,代码来源:TgcSceneParser.cpp

示例9: load_gdimm_process

void gdipp_setting::load_gdimm_process(const xpath_node_set &process_nodes)
{
	// backward iterate so that first-coming process settings overwrites last-coming ones

	xpath_node_set::const_iterator node_iter = process_nodes.end();
	node_iter--;

	for (size_t i = 0; i < process_nodes.size(); i++, node_iter--)
	{
		// only store the setting items which match the current process name

		const xml_node curr_proc = node_iter->node();
		const xml_attribute name_attr = curr_proc.attribute(L"name");

		bool process_matched = name_attr.empty();
		if (!process_matched)
		{
			const wregex name_ex(name_attr.value(), regex_flags);
			process_matched = regex_match(_process_name, name_ex);
		}

		if (process_matched)
		{
			for (xml_node::iterator set_iter = node_iter->node().begin(); set_iter != node_iter->node().end(); set_iter++)
				parse_gdimm_setting_node(*set_iter, _process_setting);
		}
	}
}
开发者ID:Carye,项目名称:gdipp,代码行数:28,代码来源:setting.cpp

示例10: parseID

void Camera::parseID( xml_node &cur )
{
  if (isTag(cur.name(), "ID")) {
    pugi::xml_attribute id_make = cur.attribute("make");
    if (id_make) {
      canonical_make = string(id_make.as_string());
    } else
      ThrowCME("CameraMetadata: Could not find make for ID for %s %s camera.", make.c_str(), model.c_str());

    pugi::xml_attribute id_model = cur.attribute("model");
    if (id_model) {
      canonical_model = string(id_model.as_string());
    } else
      ThrowCME("CameraMetadata: Could not find model for ID for %s %s camera.", make.c_str(), model.c_str());

    canonical_id = string(cur.first_child().value());
  }
}
开发者ID:acarrasco,项目名称:darktable,代码行数:18,代码来源:Camera.cpp

示例11: WidgetInfo

WidgetInfo::WidgetInfo(xml_node& nodes, WidgetInfo* parent):
	_w(nodes),_btree(nodes.attribute("behaviour").as_string()),_parent(parent)
{
	auto i = nodes.children();
	for (auto node : nodes)
	{
		_nextNode.push_back(new WidgetInfo(node, this));
	}
}
开发者ID:blacklensama,项目名称:daiteikoku,代码行数:9,代码来源:Widget.cpp

示例12: stringAttributeFromNode

string Scene::stringAttributeFromNode(const xml_node &node, const string& attributeName)
{
	xml_attribute attr = node.attribute(attributeName.c_str());
	if(!attr){
		stringstream ss;
		ss << "node <"<< node.name() << "> has no '" << attributeName << "' attribute";
		throw invalid_argument(ss.str().c_str());
	}
	return attr.as_string();
}
开发者ID:mvignale1987,项目名称:computer-graphics,代码行数:10,代码来源:Scene.cpp

示例13: ParseItemMenu

void Settings::ParseItemMenu(const xml_node& node)
{
   ItemMenu menu;
   menu.Name = node.attribute("Name").value();
   menu.Description = node.attribute("Description").value();
   menu.Type = node.attribute("Type").value();

   for (auto child : node.children("Item"))
   {
      ItemElement item;
      item.Name = child.attribute("Name").value();
      item.Value = child.attribute("Value").value();
      item.Error = child.attribute("Error").value();
      item.Description = child.attribute("Description").value();
      menu.Items[item.Name] = item;
   }

   m_menus[menu.Name] = menu;
}
开发者ID:jahales,项目名称:BIRD,代码行数:19,代码来源:settings.cpp

示例14: parseHint

void Camera::parseHint( xml_node &cur )
{
  if (isTag(cur.name(), "Hint")) {
    string hint_name, hint_value;
    pugi::xml_attribute key = cur.attribute("name");
    if (key) {
      hint_name = string(key.as_string());
    } else
      ThrowCME("CameraMetadata: Could not find name for hint for %s %s camera.", make.c_str(), model.c_str());

    key = cur.attribute("value");
    if (key) {
      hint_value = string(key.as_string());
    } else
      ThrowCME("CameraMetadata: Could not find value for hint %s for %s %s camera.", hint_name.c_str(), make.c_str(), model.c_str());

    hints.insert(make_pair(hint_name, hint_value));
  }
}
开发者ID:acarrasco,项目名称:darktable,代码行数:19,代码来源:Camera.cpp

示例15: add_layer

   void Tilemap::add_layer(std::map<unsigned, Surface>& tiles, xml_node node,
         int tilewidth, int tileheight)
   {
      Layer layer;
      int width  = node.attribute("width").as_int();
      int height = node.attribute("height").as_int();

      if (!width || !height)
         throw std::logic_error("Layer is empty.");

#if 0
      std::cerr << "Adding layer:" <<
         " Name: " << node.attribute("name").value() <<
         " Width: " << width <<
         " Height: " << height << std::endl;
#endif

      Utils::xml_node_walker walk{node.child("data"), "tile", "gid"};
      int index = 0;
      for (auto& gid_str : walk)
      {
         Pos pos = Pos(index % width, index / width);

         unsigned gid = Utils::stoi(gid_str);
         if (gid)
         {
            Blit::Surface surf = tiles[gid];
            surf.rect().pos = pos * Pos(tilewidth, tileheight);

            layer.cluster.vec().push_back({surf, Pos()});

            if (Utils::find_or_default(surf.attr(), "collision", "") == "true")
               collisions.insert(pos);
         }

         index++;
      }

      layer.attr = get_attributes(node.child("properties"), "property");
      layer.name = node.attribute("name").value();
      m_layers.push_back(std::move(layer));
   }
开发者ID:libretro,项目名称:Dinothawr,代码行数:42,代码来源:tilemap.cpp


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