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; }
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; }
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); }
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()); }
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); } }
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); }
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()); }
//----------------------------------------------------------------------------- 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); } } }
bool j1Audio::SaveData(pugi::xml_node& audioConfig) { audioConfig.append_attribute("volume").set_value(volume); return true; }
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); }
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(); }