void RawStruct<RPG::TreeMap>::WriteXml(const RPG::TreeMap& ref, XmlWriter& stream) { stream.BeginElement("TreeMap"); stream.BeginElement("maps"); Struct<RPG::MapInfo>::WriteXml(ref.maps, stream); stream.EndElement("maps"); stream.BeginElement("tree_order"); stream.Write<std::vector<int> >(ref.tree_order); stream.EndElement("tree_order"); stream.WriteNode<int>("active_node", ref.active_node); stream.BeginElement("start"); Struct<RPG::Start>::WriteXml(ref.start, stream); stream.EndElement("start"); stream.EndElement("TreeMap"); }
void writePalettes(XmlWriter& xml, const NamedList<PaletteInput>& palettes) { for (const auto& p : palettes) { xml.writeTag("palette"); xml.writeTagAttribute("name", p.name); xml.writeTagAttributeFilename("image", p.paletteImageFilename); xml.writeTagAttribute("rows-per-frame", p.rowsPerFrame); xml.writeTagAttribute("skip-first", p.skipFirstFrame); if (p.animationDelay > 0) { xml.writeTagAttribute("animation-delay", p.animationDelay); } xml.writeCloseTag(); } }
void Glissando::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(xml.spannerId(this))); if (_showText && !_text.isEmpty()) xml.tag("text", _text); xml.tag("subtype", int(_glissandoType)); writeProperty(xml, P_ID::PLAY); writeProperty(xml, P_ID::GLISSANDO_STYLE); SLine::writeProperties(xml); xml.etag(); }
/** writes a surface value. */ void iom_file::writeSurface(XmlWriter &out, IomObject &obj) { /* object: MULTISURFACE [INCOMPLETE] surface // if incomplete; multi surface values object: SURFACE boundary object: BOUNDARY polyline object: POLYLINE <SURFACE> <BOUNDARY> <POLYLINE .../> <POLYLINE .../> </BOUNDARY> <BOUNDARY> <POLYLINE .../> <POLYLINE .../> </BOUNDARY> </SURFACE> */ out.startElement(tags::get_SURFACE(),0,0); bool clipped=obj->getConsistency()==IOM_INCOMPLETE; for(int surfacei=0;surfacei<obj->getAttrValueCount(tags::get_surface());surfacei++){ if(clipped){ out.startElement(tags::get_CLIPPED(),0,0); }else{ // an unclipped surface should have only one surface element if(surfacei>0){ iom_issueerr("unclipped surface with multi 'surface' elements"); break; } } IomObject surface=obj->getAttrObj(tags::get_surface(),surfacei); for(int boundaryi=0;boundaryi<surface->getAttrValueCount(tags::get_boundary());boundaryi++){ IomObject boundary=surface->getAttrObj(tags::get_boundary(),boundaryi); out.startElement(tags::get_BOUNDARY(),0,0); for(int polylinei=0;polylinei<boundary->getAttrValueCount(tags::get_polyline());polylinei++){ IomObject polyline=boundary->getAttrObj(tags::get_polyline(),polylinei); writePolyline(out,polyline,true); } out.endElement(/*BOUNDARY*/); } if(clipped){ out.endElement(/*CLIPPED*/); } } out.endElement(/*SURFACE*/); }
void writeXmlTestCase(XmlWriter& writer, const Test& test) { writer.beginElement("testcase"); writer.attribute("name", test.name()); if (test.assertions() != 0) { writer.attribute("assertions", (int64_t)test.assertions()); writer.attribute("name", "NONE"); writer.attribute("time", test.elapsedTime()); auto& errors = test.errors(); for (auto it = begin(errors); it != end(errors); ++it) writeXmlError(writer, *it); } writer.endElement(); }
void StaffTextBase::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(this); for (ChannelActions s : _channelActions) { int channel = s.channel; for (QString name : s.midiActionNames) xml.tagE(QString("MidiAction channel=\"%1\" name=\"%2\"").arg(channel).arg(name)); } for (int voice = 0; voice < VOICES; ++voice) { if (!_channelNames[voice].isEmpty()) xml.tagE(QString("channelSwitch voice=\"%1\" name=\"%2\"").arg(voice).arg(_channelNames[voice])); } if (_setAeolusStops) { for (int i = 0; i < 4; ++i) xml.tag(QString("aeolus group=\"%1\"").arg(i), aeolusStops[i]); } if (swing()) { QString swingUnit; if (swingParameters()->swingUnit == MScore::division / 2) swingUnit = TDuration(TDuration::DurationType::V_EIGHTH).name(); else if (swingParameters()->swingUnit == MScore::division / 4) swingUnit = TDuration(TDuration::DurationType::V_16TH).name(); else swingUnit = TDuration(TDuration::DurationType::V_ZERO).name(); int swingRatio = swingParameters()->swingRatio; xml.tagE(QString("swing unit=\"%1\" ratio= \"%2\"").arg(swingUnit).arg(swingRatio)); } if (capo() != 0) xml.tagE(QString("capo fretId=\"%1\"").arg(capo())); TextBase::writeProperties(xml); xml.etag(); }
void OutputTestCases( XmlWriter& xml, const Stats& stats ) { std::vector<TestCaseStats>::const_iterator it = stats.m_testCaseStats.begin(); std::vector<TestCaseStats>::const_iterator itEnd = stats.m_testCaseStats.end(); for(; it != itEnd; ++it ) { XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); xml.writeAttribute( "classname", it->m_className ); xml.writeAttribute( "name", it->m_name ); xml.writeAttribute( "time", "tbd" ); OutputTestResult( xml, *it ); std::string stdOut = trim( it->m_stdOut ); if( !stdOut.empty() ) xml.scopedElement( "system-out" ).writeText( stdOut, false ); std::string stdErr = trim( it->m_stdErr ); if( !stdErr.empty() ) xml.scopedElement( "system-err" ).writeText( stdErr, false ); } }
void Workspace::writeMenuBar(XmlWriter& xml, QMenuBar* mb) { // Loop through each menu in menubar. For each menu, call writeMenu. xml.stag("MenuBar"); if (!mb) mb = mscore->menuBar(); for (QAction* action : mb->actions()) { if (action->isSeparator()) xml.tag("action", ""); else if (action->menu()) { xml.stag("Menu name=\"" + findStringFromMenu(action->menu()) + "\""); writeMenu(xml, action->menu()); xml.etag(); } else xml.tag("action", findStringFromAction(action)); } xml.etag(); }
void TimeSig::write(XmlWriter& xml) const { xml.stag("TimeSig"); writeProperty(xml, P_ID::TIMESIG_TYPE); Element::writeProperties(xml); xml.tag("sigN", _sig.numerator()); xml.tag("sigD", _sig.denominator()); if (stretch() != Fraction(1,1)) { xml.tag("stretchN", stretch().numerator()); xml.tag("stretchD", stretch().denominator()); } writeProperty(xml, P_ID::NUMERATOR_STRING); writeProperty(xml, P_ID::DENOMINATOR_STRING); if (!_groups.empty()) _groups.write(xml); writeProperty(xml, P_ID::SHOW_COURTESY); writeProperty(xml, P_ID::SCALE); xml.etag(); }
void MidiCoreEvent::write(XmlWriter& xml) const { switch(_type) { case ME_NOTEON: xml.tagE(QString("note-on channel=\"%1\" pitch=\"%2\" velo=\"%3\"") .arg(_channel).arg(_a).arg(_b)); break; case ME_NOTEOFF: xml.tagE(QString("note-off channel=\"%1\" pitch=\"%2\" velo=\"%3\"") .arg(_channel).arg(_a).arg(_b)); break; case ME_CONTROLLER: if (_a == CTRL_PROGRAM) { if (_channel == 0) { xml.tagE(QString("program value=\"%1\"").arg(_b)); } else { xml.tagE(QString("program channel=\"%1\" value=\"%2\"") .arg(channel()).arg(_b)); } } else { if (channel() == 0) { xml.tagE(QString("controller ctrl=\"%1\" value=\"%2\"") .arg(_a).arg(_b)); } else { xml.tagE(QString("controller channel=\"%1\" ctrl=\"%2\" value=\"%3\"") .arg(channel()).arg(_a).arg(_b)); } } break; default: qDebug("MidiCoreEvent::write: unknown type"); break; } }
void writeXmlError(XmlWriter& writer, const Error& error) { if (error.type() == Error::UnhandledException) writer.beginElement("error"); else writer.beginElement("failure"); writer.attribute("message", error.message()); writer.attribute("type", Error::levelName(error.type())); writer.characterData(error.file()); writer.characterData("["); writer.characterData((int)error.lineNo()); writer.characterData("]"); auto& context = error.context(); for (auto c = begin(context); c != end(context); ++c) { writer.characterData("\n"); writer.characterData(c->text()); } writer.endElement(); }
void LightReaderWriter::writeFlagsOn(std::shared_ptr<XmlChunk> lightChunk, const Light *light, XmlWriter &xmlWriter) const { std::shared_ptr<XmlChunk> produceShadowChunk = xmlWriter.createChunk(PRODUCE_SHADOW_TAG, XmlAttribute(), lightChunk); produceShadowChunk->setBoolValue(light->isProduceShadow()); }
void Page::write(XmlWriter& xml) const { xml.stag("Page"); foreach(System* system, _systems) { system->write(xml); }
void Ambitus::write(XmlWriter& xml) const { xml.stag(this); xml.tag(Pid::HEAD_GROUP, int(_noteHeadGroup), int(NOTEHEADGROUP_DEFAULT)); xml.tag(Pid::HEAD_TYPE, int(_noteHeadType), int(NOTEHEADTYPE_DEFAULT)); xml.tag(Pid::MIRROR_HEAD,int(_dir), int(DIR_DEFAULT)); xml.tag("hasLine", _hasLine, true); xml.tag(Pid::LINE_WIDTH, _lineWidth, LINEWIDTH_DEFAULT); xml.tag("topPitch", _topPitch); xml.tag("topTpc", _topTpc); xml.tag("bottomPitch",_bottomPitch); xml.tag("bottomTpc", _bottomTpc); if (_topAccid.accidentalType() != AccidentalType::NONE) { xml.stag("topAccidental"); _topAccid.write(xml); xml.etag(); } if (_bottomAccid.accidentalType() != AccidentalType::NONE) { xml.stag("bottomAccidental"); _bottomAccid.write(xml); xml.etag(); } Element::writeProperties(xml); xml.etag(); }
void LightReaderWriter::writePropertiesOn(std::shared_ptr<XmlChunk> lightChunk, const Light *light, XmlWriter &xmlWriter) const { std::shared_ptr<XmlChunk> ambientColorChunk = xmlWriter.createChunk(AMBIENT_COLOR_TAG, XmlAttribute(), lightChunk); ambientColorChunk->setPoint3Value(light->getAmbientColor()); }
////////////////////////////////////////////////////////////////////////////////////////// ///Creates the XML database file from a set of filepaths and returns number of new paths int FileSniffer::createDatabase(std::set<std::string>& filelist) { int count=0; try{ XmlWriter writer; //create new xml writer.addDeclaration(); writer.start("filelist"); newfilesList.clear(); for (std::set<std::string>::iterator it=filelist.begin(); it != filelist.end(); it++) //add all paths in fileset to the xml { if(!isInExcluded(*it)) { count++; XmlWriter childnode; childnode.start("filepath"); //add filepath tag for each path childnode.addBody(*it); //add path childnode.end(); //add ending tag writer.addBody(childnode.xml()); newfilesList.insert(*it); } } writer.end(); std::ofstream myfile; //create new file and write the xml in it myfile.open (databaseFilePath.c_str()); myfile << writer.xml(); myfile.close(); StoreResult(); } catch(std::exception ex) { std::cout << "\n " << ex.what() << "\n\n"; } return count; }
void MALItem::serialize(XmlWriter& writer) const { writer.startElement("MALitem"); writer.writeAttribute("version", "1"); using std::to_string; writer.writeElement("series_itemdb_id", to_string(series_itemdb_id)); writer.writeElement("series_title", series_title); writer.writeElement("series_preferred_title", series_preferred_title); writer.writeElement("series_date_begin", series_date_begin); writer.writeElement("series_date_end", series_date_end); writer.writeElement("image_url", image_url); writer.startElement("series_synonyms"); std::for_each(std::begin(series_synonyms), std::end(series_synonyms), std::bind(&XmlWriter::writeElement, std::ref(writer), "series_synonym", std::placeholders::_1)); writer.endElement(); writer.writeElement("series_synopsis", series_synopsis ); writer.startElement("tags"); std::for_each(std::begin(tags), std::end(tags), std::bind(&XmlWriter::writeElement, std::ref(writer), "tag", std::placeholders::_1)); writer.endElement(); writer.writeElement("date_start", date_start); writer.writeElement("date_finish", date_finish); writer.writeElement("id", to_string(id)); writer.writeElement("last_updated", to_string(last_updated)); writer.writeElement("score", to_string(score)); writer.writeElement("enable_reconsuming", to_string(enable_reconsuming)); writer.writeElement("fansub_group", fansub_group); writer.writeElement("comments", comments); writer.writeElement("downloaded_items", to_string(downloaded_items)); writer.writeElement("times_consumed", to_string(times_consumed)); writer.writeElement("reconsume_value", to_string(reconsume_value)); writer.writeElement("priority", to_string(priority)); writer.writeElement("enable_discussion", to_string(enable_discussion)); writer.writeElement("has_details", to_string(has_details)); writer.endElement(); }
//! \internal void XmlPreferencesPrivate::writeSection(XmlWriter& out, const QString& name, const Section& section) { QHash<QString,QString> attrs; attrs.insert("name", name); out.writeOpenTag("section", attrs); attrs.clear(); for (Section::ConstIterator sectionIterator = section.constBegin(); sectionIterator != section.constEnd(); ++sectionIterator) { const EncVariant& v = sectionIterator.value(); attrs.insert("name", sectionIterator.key()); switch (v.data.type()) { case QVariant::String : attrs.insert("type", "string"); out.writeTaggedString("setting", v.data.toString(), attrs); break; case QVariant::StringList : { attrs.insert("type", "stringlist"); out.writeOpenTag("setting", attrs); attrs.clear(); QStringList list = v.data.toStringList(); for (int i = 0; i < list.size(); ++i) out.writeTaggedString("value", list.at(i), attrs); out.writeCloseTag("setting"); } break; case QVariant::Bool : attrs.insert("type", "bool"); out.writeTaggedString("setting", v.data.toBool() ? "true" : "false", attrs); break; case QVariant::Int : attrs.insert("type", "int"); out.writeTaggedString("setting", QString::number(v.data.toInt()), attrs); break; case QVariant::LongLong : attrs.insert("type", "int64"); out.writeTaggedString("setting", QString::number(v.data.toLongLong()), attrs); break; case QVariant::Rect : { attrs.insert("type", "rect"); QRect rect = v.data.toRect(); QString s = QString("%1;%2;%3;%4").arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height()); out.writeTaggedString("setting", s, attrs); } break; case QVariant::Point : { attrs.insert("type", "point"); QPoint point = v.data.toPoint(); QString s = QString("%1;%2").arg(point.x()).arg(point.y()); out.writeTaggedString("setting", s, attrs); } break; case QVariant::Size : { attrs.insert("type", "size"); QSize size = v.data.toSize(); QString s = QString("%1;%2").arg(size.width()).arg(size.height()); out.writeTaggedString("setting", s, attrs); } break; case QVariant::ByteArray : { attrs.insert("type", "bytearray"); const QByteArray ba = v.data.toByteArray(); switch (v.encoding) { case XmlPreferences::Base64: attrs.insert("encoding", "base64"); out.writeTaggedString("setting", Base64::encode(ba), attrs); break; default: attrs.insert("encoding", "csv"); QString s; for (uint i = 0; i < (uint) ba.size(); ++i) (i != 0) ? s += "," + QString::number((uint)ba.at(i), 16) : s += QString::number((uint)ba.at(i), 16); out.writeTaggedString("setting", s, attrs); } attrs.clear(); } break; case QVariant::BitArray : { attrs.insert("type", "bitarray"); const QBitArray ba = v.data.toBitArray(); attrs.insert("size", QString::number(ba.size())); switch (v.encoding) { case XmlPreferences::Base64: attrs.insert("encoding", "base64"); out.writeTaggedString("setting", Base64::encode(ba), attrs); break; default: attrs.insert("encoding", "csv"); QString s; for (uint i = 0; i < (uint) ba.size(); ++i) (i != 0) ? s += ba.testBit(i) ? ",1" : ",0" : s += ba.testBit(i) ? "1" : "0"; out.writeTaggedString("setting", s, attrs); } attrs.clear(); } break; #ifndef QT_CORE_ONLY case QVariant::Color : attrs.insert("type", "color"); out.writeTaggedString("setting", v.data.value<QColor>().name(), attrs); break; #endif // QT_CORE_ONLY default: ; } } out.writeCloseTag("section"); }
void main() { //mOut("Testing XmlWriter"); //mOut("================="); //mOut("creating XML writer object:"); XmlWriter wtr; //mOut("adding XML declaration:"); wtr.addDeclaration(); //mOut(wtr.xml()); //mOut("adding comment:"); wtr.addComment("top level comment"); //mOut(wtr.xml()); //mOut("adding root element:"); wtr.start("root"); //mOut(wtr.xml()); //mOut("adding attributes:"); wtr.addAttribute("att1","val1"); wtr.addAttribute("att2","val2"); //mOut(wtr.xml()); //mOut("adding comment:"); wtr.addComment("comment in root's body"); //mOut(wtr.xml()); //mOut("Creating self-closing element:"); XmlWriter sub1; sub1.start("child1 /"); // mOut(sub1.xml()); //mOut("adding attribute:"); sub1.addAttribute("c1name","c1value"); XmlWriter subsub1; subsub1.start("grand"); subsub1.addBody("test grandchild"); subsub1.end(); sub1.addBody(subsub1.xml()); //mOut(sub1.xml()); //mOut("adding child to root's body:"); wtr.addBody(sub1.xml()); //mOut(wtr.xml()); //mOut("adding another comment"); wtr.addComment("another root's body comment"); //mOut(wtr.xml()); //mOut("adding string to root's body:"); wtr.addBody("root's body"); //mOut(wtr.xml()); //mOut("closing root element:\n"); wtr.end(); mOut(wtr.xml()); mOut("\n writing XML to file \"Test.xml\":"); std::ofstream out("test.xml"); if(out.good()) { out << wtr.xml().c_str(); out.close(); } std::cout << std::endl; /* mOut("creating composite element:"); XmlWriter cwtr, bcwtr1, bcwtr2; std::string temp = bcwtr1.element("child1","child1's body") .element("child2","child2's body").xml(); std::cout << "\n " << bcwtr1.xml(); bcwtr1.clear(); std::cout << "\n " << cwtr.start("parent") .addBody(bcwtr1.element("child1","child1's body").xml()) .addBody(bcwtr2.element("child2","body2").xml()) .end().xml(); std::cout << "\n\n";*/ }
void ScoreElement::writeProperty(XmlWriter& xml, P_ID id) const { xml.tag(id, getProperty(id), propertyDefault(id)); }
void SceneAI::writeOn(const std::shared_ptr<XmlChunk> &chunk, XmlWriter &xmlWriter) const { std::shared_ptr<XmlChunk> navMeshConfigChunk = xmlWriter.createChunk(NAV_MESH_CONFIG_TAG, XmlAttribute(), chunk); NavMeshConfigWriter().writeOn(navMeshConfigChunk, navMeshConfig, xmlWriter); }
void testStartTimeWrite(const StartTimeSample& startTimeSample, XmlWriter& writer) { const string actualXml = writer.save(startTimeSample.second); EXPECT_THAT(remove_xml_tag(actualXml), Eq(startTimeSample.first)); }
void XmlElement::serielize(XmlWriter &writer, int tab) const { // name for (int i = 0; i < tab; ++i) writer.write_text("\t"); writer.start_element(_name.c_str()); // attributes for (const_attr_iter_t iter = _attrs.begin(), end = _attrs.end(); iter != end; ++iter) { writer.write_attribute(iter->first.c_str(), iter->second.c_str()); } // text bool has_child = false; if (!_text.empty()) { if (tab >= 0) { std::string text; trim(_text.c_str(), &text); if (!text.empty()) { writer.write_text("\n"); for (int i = 0; i < tab + 1; ++i) writer.write_text("\t"); writer.write_text(text.c_str()); has_child = true; } } else { writer.write_text(_text.c_str()); has_child = true; } } // children and comments const size_t comments_size = _comments.size(); size_t comment_pos = 0; for (size_t i = 0, csize = _children.size(); i < csize; ++i) { // serialize comment while (comment_pos < comments_size && _comments.at(comment_pos).pos <= i) { if (tab >= 0) { writer.write_text("\n"); for (int j = 0; j < tab + 1; ++j) writer.write_text("\t"); } writer.write_comment(_comments.at(comment_pos).text.c_str()); ++comment_pos; has_child = true; } // children element rc_ptr<XmlElement> c = _children.at(i); if (c.is_null()) continue; if (tab >= 0) writer.write_text("\n"); c->serielize(writer, tab >= 0 ? tab + 1 : tab); has_child = true; } // tail comments while (comment_pos < comments_size) { if (tab >= 0) { writer.write_text("\n"); for (int j = 0; j < tab + 1; ++j) writer.write_text("\t"); } writer.write_comment(_comments.at(comment_pos).text.c_str()); ++comment_pos; has_child = true; } // finish if (has_child && tab >= 0) { writer.write_text("\n"); for (int i = 0; i < tab; ++i) writer.write_text("\t"); } writer.end_element(); }
////////////////////////////////////////////////////////////// ///Stores results of analysis into a text file void FileSniffer::StoreResult() { try{ std::stringstream ss; ss<<newfilesList.size(); XmlWriter writer; //create new xml writer.addDeclaration(); writer.start("filelist"); XmlWriter childnode1; childnode1.start("listsize"); //add filepath tag for each path childnode1.addBody(ss.str()); //add path childnode1.end(); //add ending tag writer.addBody(childnode1.xml()); for (std::set<std::string>::iterator it=newfilesList.begin(); it != newfilesList.end(); it++) //add all paths in fileset to the xml { XmlWriter childnode; childnode.start("filepath"); //add filepath tag for each path childnode.addBody(*it); //add path childnode.end(); //add ending tag writer.addBody(childnode.xml()); } writer.end(); std::ofstream myfile; //create new file and write the xml in it myfile.open (resultFilePath.c_str()); myfile << writer.xml(); myfile.close(); } catch(std::exception ex) { std::cout << "\n " << ex.what() << "\n\n"; } }
void iom_file::writeAttr(XmlWriter &out, IomObject &obj,int attr) { int valueCount=obj->getAttrValueCount(attr); if(valueCount>0){ const XMLCh *val=obj->getAttrPrim(attr,0); // not a primitive? if(!val){ IomObject child=obj->getAttrObj(attr,0); // some special cases if(child->getTag()==tags::get_COORD()){ // COORD out.startElement(attr,0,0); writeCoord(out,child); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one COORD value allowed"); } }else if(child->getTag()==tags::get_POLYLINE()){ // POLYLINE out.startElement(attr,0,0); writePolyline(out,child,false); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one POLYLINE value allowed"); } }else if(child->getTag()==tags::get_MULTISURFACE()){ // MULTISURFACE out.startElement(attr,0,0); writeSurface(out,child); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one MULTISURFACE value allowed"); } }else{ // normal case const XMLCh *ref=child->getRefOid(); bool isRef= ref ? true : false; // Reference-attribute or Role or EmbeddedLink? if(isRef){ const XMLCh *extref=0; const XMLCh *bid=0; XMLCh itoabuf[40]; const XMLCh *orderpos=0; if(ref){ if(child->getRefOrderPos()>0){ XMLString::binToText( child->getRefOrderPos(),itoabuf,sizeof(itoabuf)-1,10); orderpos=itoabuf; } } bid=child->getRefBid(); if(bid){ extref=ref; ref=0; } XmlWrtAttr refAttr[]={ XmlWrtAttr(ref ? ustrings::get_REF() :0, ref,true) ,XmlWrtAttr(extref ? ustrings::get_EXTREF() :0, extref,true) ,XmlWrtAttr(bid ? ustrings::get_BID() :0, bid,true) ,XmlWrtAttr(orderpos ? ustrings::get_ORDER_POS():0, orderpos) }; out.startElement(attr,refAttr,sizeof(refAttr)/sizeof(refAttr[0])); if(child->getAttrCount()>0){ out.startElement(child->getTag(),0,0); writeAttrs(out,child); out.endElement(/*child*/); } out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one reference value allowed"); } }else{ // struct out.startElement(attr,0,0); int valuei=0; while(1){ out.startElement(child->getTag(),0,0); writeAttrs(out,child); out.endElement(/*child*/); valuei++; if(valuei>=valueCount){ break; } child=obj->getAttrObj(attr,valuei); } out.endElement(/*attr*/); } } }else{ out.startElement(attr,0,0); out.characters(val); out.endElement(/*attr*/); if(valueCount>1){ iom_issueerr("max one primitive-type value allowed"); } } } }
std::string AnimeSerializer::serialize(const Anime& anime) const { XmlWriter writer; writer.startDoc(); writer.startElement("entry"); writer.writeElement("episode", std::to_string(anime.episodes)); writer.writeElement("status", std::to_string(static_cast<int>(anime.status))); writer.writeElement("score", std::to_string(anime.score)); writer.writeElement("downloaded_episodes", std::to_string(anime.downloaded_items)); if (anime.has_details) { writer.writeElement("storage_type", std::to_string(static_cast<int>(anime.storage_type))); writer.writeElement("storage_value", std::to_string(anime.storage_value)); writer.writeElement("times_rewatched", std::to_string(anime.times_consumed)); writer.writeElement("rewatch_value", std::to_string(static_cast<int>(anime.reconsume_value))); } auto start = Glib::Date(); start.set_parse(anime.date_start); if (start.valid()) { writer.writeElement("date_start", start.format_string("%m%d%Y")); } auto finish = Glib::Date(); finish.set_parse(anime.date_finish); if (finish.valid()) { writer.writeElement("date_finish", finish.format_string("%m%d%Y")); } if (anime.has_details) { writer.writeElement("priority", std::to_string(static_cast<int>(anime.priority))); writer.writeElement("enable_discussion", anime.enable_discussion?"1":"0"); } writer.writeElement("enable_rewatching", anime.enable_reconsuming?"1":"0"); if (anime.has_details) { writer.writeElement("comments", anime.comments); writer.writeElement("fansub_group", anime.fansub_group); } std::string tags; auto iter = anime.tags.begin(); bool was_first = true; while (iter != anime.tags.end()) { if (!was_first) tags += ", "; tags += *iter; was_first = false; ++iter; } writer.writeElement("tags", tags); writer.writeElement("rewatch_episode", std::to_string(anime.rewatch_episode)); writer.endDoc(); return writer.getString(); }
/** write all baskets to an xml file. */ int iom_file::save() { // build class/attribute list if(ilibasket.isNull()){ iom_issueerr("model required to save data"); return IOM_ERR_ILLEGALSTATE; } buildTagList(); // read rest of file (before we overwrite it!) IomIterator bi=new iom_iterator(this); while(!bi->next_basket().isNull()){ ; // empty } // open file for write XmlWriter out; int ind=0; out.open(filename);out.printNewLine(); // write header XmlWrtAttr trsfAttr[]={XmlWrtAttr(ustrings::get_xmlns(),ustrings::get_NS_INTERLIS22())}; out.printIndent(ind); out.startElement(tags::get_TRANSFER(),trsfAttr,sizeof(trsfAttr)/sizeof(trsfAttr[0]));out.printNewLine(); { ind++; out.printIndent(ind); XStr version("2.2"); XmlWrtAttr headAttr[]={ XmlWrtAttr(ustrings::get_VERSION(),version.unicodeForm()) ,XmlWrtAttr(ustrings::get_SENDER(),getHeadSecSender()) }; out.startElement(tags::get_HEADERSECTION(),headAttr,sizeof(headAttr)/sizeof(headAttr[0]));out.printNewLine(); { ind++; out.printIndent(ind); out.startElement(tags::get_ALIAS(),0,0);out.printNewLine(); { ind++; ind--; } out.printIndent(ind); out.endElement(/*ALIAS*/);out.printNewLine(); out.printIndent(ind); out.startElement(tags::get_COMMENT(),0,0); out.characters(getHeadSecComment()); out.endElement(/*COMMENT*/);out.printNewLine(); ind--; } out.printIndent(ind); out.endElement(/*HEADERSECTION*/);out.printNewLine(); ind--; } // write DATASECTION { ind++; out.printIndent(ind); out.startElement(tags::get_DATASECTION(),0,0);out.printNewLine(); { ind++; // write all baskets for(std::vector<IomBasket>::size_type basketi=0;basketi<basketv.size();basketi++){ IomBasket basket=basketv.at(basketi); const XMLCh *topics=basket->getTopics(); const XMLCh *kind=encodeBasketKind(basket->getKind()); const XMLCh *startstate=basket->getKind()!=IOM_FULL ? basket->getStartState() : 0; const XMLCh *endstate=basket->getKind()!=IOM_FULL ? basket->getEndState() : 0; const XMLCh *consistency=encodeConsistency(basket->getConsistency()); XmlWrtAttr basketAttr[]={ XmlWrtAttr(ustrings::get_BID(),basket->getOid(),true) ,XmlWrtAttr(topics ? ustrings::get_TOPICS():0,topics) ,XmlWrtAttr(kind ? ustrings::get_KIND():0 ,kind) ,XmlWrtAttr(startstate ? ustrings::get_STARTSTATE():0,startstate) ,XmlWrtAttr(endstate ? ustrings::get_ENDSTATE():0,endstate) ,XmlWrtAttr(consistency ? ustrings::get_CONSISTENCY():0,consistency) }; out.printIndent(ind); if(basket->getTag()==0){ iom_issueerr("basket requires a TOPIC name"); return IOM_ERR_ILLEGALSTATE; } out.startElement(basket->getTag(),basketAttr,sizeof(basketAttr)/sizeof(basketAttr[0]));out.printNewLine(); { ind++; // write all objects IomIterator obji=new iom_iterator(basket); IomObject obj=obji->next_object(); while(!obj.isNull()){ out.printIndent(ind); const XMLCh *bid=obj->getBid(); const XMLCh *ops=encodeOperation(obj->getOperation()); const XMLCh *consistency=encodeConsistency(basket->getConsistency()); XmlWrtAttr objAttr[]={ XmlWrtAttr(ustrings::get_TID(),obj->getOid(),true) ,XmlWrtAttr(bid ? ustrings::get_BID():0,bid,true) ,XmlWrtAttr(ops ? ustrings::get_OPERATION():0 ,ops) ,XmlWrtAttr(consistency ? ustrings::get_CONSISTENCY():0,consistency) }; out.startElement(obj->getTag(),objAttr,sizeof(objAttr)/sizeof(objAttr[0])); writeAttrs(out,obj); out.endElement(/*object*/);out.printNewLine(); obj=obji->next_object(); } ind--; } out.printIndent(ind); out.endElement(/*basket*/);out.printNewLine(); } ind--; } out.printIndent(ind); out.endElement(/*DATASECTION*/);out.printNewLine(); ind--; } out.printIndent(ind); out.endElement(/*TRANSFER*/);out.printNewLine(); // close file out.close(); return 0; }
void Event::write(XmlWriter& xml) const { switch(_type) { case ME_NOTE: xml.tagE(QString("note tick=\"%1\" channel=\"%2\" len=\"%3\" pitch=\"%4\" velo=\"%5\"") .arg(_ontime).arg(_channel).arg(_duration).arg(_a).arg(_b)); break; case ME_NOTEON: xml.tagE(QString("note-on tick=\"%1\" channel=\"%2\" pitch=\"%3\" velo=\"%4\"") .arg(_ontime).arg(_channel).arg(_a).arg(_b)); break; case ME_NOTEOFF: xml.tagE(QString("note-off tick=\"%1\" channel=\"%2\" pitch=\"%3\" velo=\"%4\"") .arg(_ontime).arg(_channel).arg(_a).arg(_b)); break; case ME_CONTROLLER: if (_a == CTRL_PROGRAM) { if ((_ontime == -1) && (_channel == 0)) { xml.tagE(QString("program value=\"%1\"").arg(_b)); } else { xml.tagE(QString("program tick=\"%1\" channel=\"%2\" value=\"%3\"") .arg(ontime()).arg(channel()).arg(_b)); } } else { if ((ontime() == -1) && (channel() == 0)) { xml.tagE(QString("controller ctrl=\"%1\" value=\"%2\"") .arg(_a).arg(_b)); } else { xml.tagE(QString("controller tick=\"%1\" channel=\"%2\" ctrl=\"%3\" value=\"%4\"") .arg(ontime()).arg(channel()).arg(_a).arg(_b)); } } break; case ME_SYSEX: xml.stag(QString("sysex tick=\"%1\" len=\"%2\"").arg(ontime()).arg(_len)); xml.dump(_len, _edata); xml.etag(); break; case ME_META: switch(metaType()) { case META_TRACK_NAME: xml.tag(QString("TrackName tick=\"%1\"").arg(ontime()), QString((char*)(edata()))); break; case META_LYRIC: xml.tag(QString("Lyric tick=\"%1\"").arg(ontime()), QString((char*)(edata()))); break; case META_KEY_SIGNATURE: { const char* keyTable[] = { "Ces", "Ges", "Des", "As", "Es", "Bes", "F", "C", "G", "D", "A", "E", "B", "Fis", "Cis" }; int key = (char)(_edata[0]) + 7; if (key < 0 || key > 14) { qDebug("bad key signature %d", key); key = 0; } QString sex(_edata[1] ? "Minor" : "Major"); QString keyName(keyTable[key]); xml.tag(QString("Key tick=\"%1\" key=\"%2\" sex=\"%3\"").arg(ontime()).arg(_edata[0]).arg(_edata[1]), QString("%1 %2").arg(keyName).arg(sex)); } break; case META_TIME_SIGNATURE: xml.tagE(QString("TimeSig tick=\"%1\" num=\"%2\" denom=\"%3\" metro=\"%4\" quarter=\"%5\"") .arg(ontime()) .arg(int(_edata[0])) .arg(int(_edata[1])) .arg(int(_edata[2])) .arg(int(_edata[3]))); break; case META_TEMPO: { unsigned tempo = _edata[2] + (_edata[1] << 8) + (_edata[0] << 16); xml.tagE(QString("Tempo tick=\"%1\" value=\"%2\"").arg(ontime()).arg(tempo)); } break; default: xml.stag(QString("Meta tick=\"%1\" type=\"%2\" len=\"%3\" name=\"%4\"") .arg(ontime()).arg(metaType()).arg(_len).arg(midiMetaName(metaType()))); xml.dump(_len, _edata); xml.etag(); break; } break; } }
xmlwriterblock::xmlwriterblock(QFile* file , Patient* blockpatient) { XmlWriter xw (file); xw.setAutoNewLine( true ); const QString index = blockpatient->index; const QString prenom = blockpatient->prenom; const QString nomjeunefille = blockpatient->nomdejeunefille; const QString nom = blockpatient->nom; const QString datedenaissance = blockpatient->datedenaissance; const QString datededeces= blockpatient->datededeces; const QString adresse = blockpatient->adresse; const QString ville = blockpatient->ville; const QString region = blockpatient->region; const QString codepostal = blockpatient->codepostal; const QString pays = blockpatient->pays; const QString telephone1 = blockpatient->telephone1; const QString telephone2 = blockpatient->telephone2; const QString telephone3 = blockpatient->telephone3; const QString courriel = blockpatient->courriel; const QString telecopie = blockpatient->telecopie; const QString textelibre = blockpatient->textelibre; const QString marque = blockpatient->marque; const QString codeinternat = blockpatient->codeinternat; const QString datededebut = blockpatient->datededebut; const QString datedefin = blockpatient->datedefin; const QString formatage = blockpatient->formatage; const QString indexdeconfiance = blockpatient->indexdeconfiance; xw.newLine(); xw.writeRaw("<!-- Patient block -->"); xw.newLine(); AttrMap attrPatient; attrPatient.insert( "emrUid", index); attrPatient.insert( "firstname" , prenom); attrPatient.insert( "birthname" , nom); attrPatient.insert( "secondname", nomjeunefille); attrPatient.insert( "dob", datedenaissance); attrPatient.insert( "dod", datededeces); xw.writeOpenTag("Patient", attrPatient); xw.writeRaw("<!-- Contact -->"); xw.newLine(); AttrMap attrAdress; attrAdress.insert( "ad", adresse); attrAdress.insert( "city", ville); attrAdress.insert( "county", region); attrAdress.insert( "zip" , codepostal); attrAdress.insert( "state" , pays); xw.writeOpenTag( "Address", attrAdress); AttrMap attrContact; attrContact.insert( "tel1", telephone1); attrContact.insert( "tel2", telephone2); attrContact.insert( "tel3" , telephone3); attrContact.insert( "fax" , telecopie); attrContact.insert("mail" , courriel); xw.writeOpenTag( "Contact", attrContact); xw.writeRaw( "<!-- PMHx -->"); xw.newLine(); xw.writeOpenTag("PMHx"); xw.writeOpenTag("PMH_Item"); xw.writeRaw("<!-- use FreeText or Encoded not both -->"); xw.newLine(); xw.writeTaggedString( "FreeText", textelibre, AttrMap() ); AttrMap attrEncoded; attrEncoded.insert("label", marque); attrEncoded.insert( "icd10" , codeinternat); xw.writeOpenTag( "Encoded" , attrEncoded); xw.writeTaggedString( "DateStart", datededebut, AttrMap("format", formatage) ); xw.writeTaggedString( "DateEnd", datedefin, AttrMap("format", formatage) ); xw.writeTaggedString( "ConfidenceIndex", indexdeconfiance, AttrMap() ); xw.writeCloseTag("PMH_Item"); xw.writeCloseTag("PMHx"); xw.writeRaw("<!-- Populate Form items -->"); xw.newLine(); xw.writeCloseTag("Patient"); xw.newLine(); }
void Map::writeSceneAIOn(const std::shared_ptr<XmlChunk> &chunk, XmlWriter &xmlWriter) const { std::shared_ptr<XmlChunk> aiElementsListChunk = xmlWriter.createChunk(AI_ELEMENTS_TAG, XmlAttribute(), chunk); sceneAI->writeOn(aiElementsListChunk, xmlWriter); }