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


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

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


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

示例1: WriteChannelized

bool AttChannelized::WriteChannelized(  pugi::xml_node element ) {
    bool wroteAttribute = false;
    if (this->HasMidiChannel()) {
        element.append_attribute("midi.channel") = StrToStr(this->GetMidiChannel()).c_str();
        wroteAttribute = true;
    }
    if (this->HasMidiDuty()) {
        element.append_attribute("midi.duty") = StrToStr(this->GetMidiDuty()).c_str();
        wroteAttribute = true;
    }
    if (this->HasMidiPort()) {
        element.append_attribute("midi.port") = StrToStr(this->GetMidiPort()).c_str();
        wroteAttribute = true;
    }
    if (this->HasMidiTrack()) {
        element.append_attribute("midi.track") = IntToStr(this->GetMidiTrack()).c_str();
        wroteAttribute = true;
    }
    return wroteAttribute;
}
开发者ID:maximumspatium,项目名称:verovio,代码行数:20,代码来源:atts_midi.cpp

示例2: WriteMidiinstrument

bool AttMidiinstrument::WriteMidiinstrument(  pugi::xml_node element ) {
    bool wroteAttribute = false;
    if (this->HasMidiInstrnum()) {
        element.append_attribute("midi.instrnum") = StrToStr(this->GetMidiInstrnum()).c_str();
        wroteAttribute = true;
    }
    if (this->HasMidiInstrname()) {
        element.append_attribute("midi.instrname") = StrToStr(this->GetMidiInstrname()).c_str();
        wroteAttribute = true;
    }
    if (this->HasMidiPan()) {
        element.append_attribute("midi.pan") = StrToStr(this->GetMidiPan()).c_str();
        wroteAttribute = true;
    }
    if (this->HasMidiVolume()) {
        element.append_attribute("midi.volume") = StrToStr(this->GetMidiVolume()).c_str();
        wroteAttribute = true;
    }
    return wroteAttribute;
}
开发者ID:maximumspatium,项目名称:verovio,代码行数:20,代码来源:atts_midi.cpp

示例3: SetTextAttribute

void SetTextAttribute(pugi::xml_node node, const char* name, const wxString& value)
{
	wxASSERT(node);

	wxScopedCharBuffer utf8 = value.utf8_str();
	if (!utf8)
		return;

	auto attribute = node.attribute(name);
	if (!attribute) {
		attribute = node.append_attribute(name);
	}
	attribute.set_value(utf8);
}
开发者ID:aswinpj,项目名称:FileZilla,代码行数:14,代码来源:xmlfunctions.cpp

示例4: CopyXmlNode

void XmlTools::CopyXmlNode(const pugi::xml_node& srcNode, pugi::xml_node& dstNode)
{
    for (const pugi::xml_attribute& attr : srcNode.attributes())
    {
        auto attrCopy = dstNode.append_attribute(attr.name());
        attrCopy.set_value(attr.value());
    }
    for (const pugi::xml_node& node : srcNode.children())
    {
        auto nodeCopy = dstNode.append_child(node.name());
        CopyXmlNode(node, nodeCopy);
    }
    auto nodeText = srcNode.text();
    dstNode.text().set(nodeText.as_string());
}
开发者ID:mathgame,项目名称:MathGame,代码行数:15,代码来源:XmlTools.cpp

示例5: SetError

void Response::SetError(pugi::xml_node errorNode, ErrorCode errorCode, const char *errorString)
{
	pugi::xml_attribute errorCodeAttr = errorNode.attribute("code");
	if (!errorCodeAttr)
	{
		errorCodeAttr = errorNode.append_attribute("code");
	}
	if (errorCodeAttr.set_value(errorCode))
	{
		pugi::xml_node errorStringNode = errorNode.first_child();
		if (!errorStringNode)
		{
			errorStringNode = errorNode.append_child(pugi::node_pcdata);
		}
		errorStringNode.set_value(errorString);
	}
}
开发者ID:Vanuan,项目名称:iviLink,代码行数:17,代码来源:Response.cpp

示例6: BuildClassAttribute

void SObjDefAttr::BuildClassAttribute( pugi::xml_node & xmlNode, LPCWSTR pszClassName)
{
    LPCWSTR pszBaseClassName=SApplication::getSingleton().BaseClassNameFromClassName(pszClassName);
    if(!pszBaseClassName) return;

    if(HasKey(pszBaseClassName))
    {
        pugi::xml_node xmlNodeAttrs = GetKeyObject(pszBaseClassName);
        pugi::xml_attribute attr=xmlNodeAttrs.first_attribute();
        while(attr)
        {
            if(!xmlNode.attribute(attr.name()))
                xmlNode.append_attribute(attr.name()).set_value(attr.value());
            attr=attr.next_attribute();
        }
    }
    BuildClassAttribute(xmlNode,pszBaseClassName);
}
开发者ID:FuckGOV,项目名称:soui,代码行数:18,代码来源:SObjDefAttr.cpp

示例7: getID

void engine::Component::save(pugi::xml_node& node)
{
  node.append_attribute("ID") = getID();
  saveData(node);
  //throw std::runtime_error("XML storing not implemented for component"+getName());
}  
开发者ID:Benjamin-L,项目名称:Dinosauria,代码行数:6,代码来源:component.cpp

示例8: write_mesh

//-----------------------------------------------------------------------------
void XMLMesh::write_mesh(const Mesh& mesh, pugi::xml_node mesh_node)
{
  // Add mesh attributes
  const CellType::Type _cell_type = mesh.type().cell_type();
  const std::string cell_type = CellType::type2string(_cell_type);
  mesh_node.append_attribute("celltype") = cell_type.c_str();
  mesh_node.append_attribute("dim") = (unsigned int) mesh.geometry().dim();

  // Add vertices node
  pugi::xml_node vertices_node = mesh_node.append_child("vertices");
  vertices_node.append_attribute("size") = (unsigned int) mesh.num_vertices();

  // Write each vertex
  for (VertexIterator v(mesh); !v.end(); ++v)
  {
    pugi::xml_node vertex_node = vertices_node.append_child("vertex");
    vertex_node.append_attribute("index") = (unsigned int) v->index();

    const Point p = v->point();
    switch (mesh.geometry().dim())
    {
      case 1:
        vertex_node.append_attribute("x")
            = boost::str(boost::format("%.15e") % p.x()).c_str();
        break;
      case 2:
        vertex_node.append_attribute("x")
            = boost::str(boost::format("%.15e") % p.x()).c_str();
        vertex_node.append_attribute("y")
            = boost::str(boost::format("%.15e") % p.y()).c_str();
        break;
      case 3:
        vertex_node.append_attribute("x")
            = boost::str(boost::format("%.15e") % p.x()).c_str();
        vertex_node.append_attribute("y")
            = boost::str(boost::format("%.15e") % p.y()).c_str();
        vertex_node.append_attribute("z")
            = boost::str(boost::format("%.15e") % p.z()).c_str();
        break;
      default:
        dolfin_error("XMLMesh.cpp",
                     "write mesh to XML file",
                     "The XML mesh file format only supports 1D, 2D and 3D meshes");
    }
  }

  // Add cells node
  pugi::xml_node cells_node = mesh_node.append_child("cells");
  cells_node.append_attribute("size") = (unsigned int) mesh.num_cells();

  // Add each cell
  for (CellIterator c(mesh); !c.end(); ++c)
  {
    pugi::xml_node cell_node = cells_node.append_child(cell_type.c_str());
    cell_node.append_attribute("index") = (unsigned int) c->index();

    const unsigned int* vertices = c->entities(0);
    dolfin_assert(vertices);

    switch (_cell_type)
    {
    case CellType::interval:
      cell_node.append_attribute("v0") = (unsigned int) vertices[0];
      cell_node.append_attribute("v1") = (unsigned int) vertices[1];
      break;
    case CellType::triangle:
      cell_node.append_attribute("v0") = (unsigned int) vertices[0];
      cell_node.append_attribute("v1") = (unsigned int) vertices[1];
      cell_node.append_attribute("v2") = (unsigned int) vertices[2];
      break;
    case CellType::tetrahedron:
      cell_node.append_attribute("v0") = (unsigned int) vertices[0];
      cell_node.append_attribute("v1") = (unsigned int) vertices[1];
      cell_node.append_attribute("v2") = (unsigned int) vertices[2];
      cell_node.append_attribute("v3") = (unsigned int) vertices[3];
      break;
    default:
      dolfin_error("XMLMesh.cpp",
                   "write mesh to XML file",
                   "Unknown cell type (%u)", _cell_type);
    }
  }
}
开发者ID:YannCobigo,项目名称:dolfin,代码行数:84,代码来源:XMLMesh.cpp

示例9:

bool j1Audio::SaveData(pugi::xml_node& audioConfig)
{
	audioConfig.append_attribute("volume").set_value(volume);
	return true;
}
开发者ID:weprikjm,项目名称:2DEngineCITM,代码行数:5,代码来源:j1Audio.cpp

示例10: positionToXml

void LeapHander::positionToXml(pugi::xml_node &node,Leap::Vector position) {
	node.append_attribute("X").set_value(position.x);
	node.append_attribute("Y").set_value(position.y);
	node.append_attribute("Z").set_value(position.z);
}
开发者ID:Lucklyric,项目名称:EM-Leap,代码行数:5,代码来源:leaphander.cpp

示例11: frame

void LeapHander::frame(pugi::xml_node &frameNode){
	Leap::Frame currentFrame = m_sampleListener.frame();
	m_lock.lock();
	frameNode.append_attribute("id").set_value(currentFrame.id());
	pugi::xml_node handList = frameNode.append_child("hands");
	HandList hands = currentFrame.hands();
	
	for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
		// Get the first hand
		const Hand hand = *hl;
		pugi::xml_node handNode = handList.append_child("hand");
		handNode.append_attribute("id").set_value(hand.id());
		std::string handType;
		if (hand.isLeft()) {
			handType = "Left";
		}
		else {
			handType = "Right";
		}
		handNode.append_attribute("type").set_value(handType.c_str());
		
		pugi::xml_node positionNode = handNode.append_child("position");
		positionToXml(positionNode, hand.palmPosition());
		
		/*pugi::xml_node normalNode = handNode.append_child("normal");
		positionToXml(normalNode, hand.palmNormal());

		pugi::xml_node directionNode = handNode.append_child("direction");
		positionToXml(directionNode, hand.direction());

		pugi::xml_node rotationNode = handNode.append_child("basis");
		rotationToXml(rotationNode, hand.basis());*/
		//// Get fingers
		pugi::xml_node fingerList = handNode.append_child("fingers");
		const FingerList fingers = hand.fingers();
		for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
			const Finger finger = *fl;
			pugi::xml_node fingerNode = fingerList.append_child("finger");
			fingerNode.append_attribute("id").set_value(finger.id());
			fingerNode.append_attribute("name").set_value(fingerNames[finger.type()].c_str());
			pugi::xml_node boneList = fingerNode.append_child("bones");
			

			// Get finger bones
			for (int b = 0; b < 4; ++b) {
				Bone::Type boneType = static_cast<Bone::Type>(b);
				Bone bone = finger.bone(boneType);
				pugi::xml_node boneNode = boneList.append_child("bone");
				boneNode.append_attribute("length").set_value(bone.length());
				boneNode.append_attribute("name").set_value(boneNames[boneType].c_str());

				pugi::xml_node prevJoint = boneNode.append_child("prevJoint");
				positionToXml(prevJoint, bone.prevJoint());

				pugi::xml_node nextJoint = boneNode.append_child("nextJoint");
				positionToXml(nextJoint, bone.nextJoint());

				/*pugi::xml_node rotation = boneNode.append_child("basis");
				rotationToXml(rotation, bone.basis());*/
			}
		}
	}
	m_lock.unlock();
}
开发者ID:Lucklyric,项目名称:EM-Leap,代码行数:64,代码来源:leaphander.cpp


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