Ejemplo n.º 1
0
	void WriteChannel (QXmlStreamWriter& w,
			const ChannelShort& cs, const QList<Item_ptr>& items)
	{
		w.writeStartElement ("section");
			w.writeAttribute ("id", QString::number (cs.ChannelID_));
			w.writeStartElement ("title");
				w.writeTextElement ("p", FixContents (cs.Title_));
			w.writeEndElement ();
			w.writeTextElement ("annotation",
					Export2FB2Dialog::tr ("%n unread item(s)", "", cs.Unread_));
			Q_FOREACH (Item_ptr item, items)
			{
				w.writeStartElement ("title");
					w.writeStartElement ("p");
					w.writeComment ("p");
					w.device ()->write (FixContents (item->Title_).toUtf8 ());
					w.writeEndElement ();
				w.writeEndElement ();

				bool hasDate = item->PubDate_.isValid ();
				bool hasAuthor = item->Author_.size ();
				if (hasDate || hasAuthor)
				{
					w.writeStartElement ("epigraph");
						if (hasDate)
							w.writeTextElement ("p",
									Export2FB2Dialog::tr ("Published on %1")
										.arg (item->PubDate_.toString ()));
						if (hasAuthor)
							w.writeTextElement ("p",
									Export2FB2Dialog::tr ("By %1")
										.arg (item->Author_));
					w.writeEndElement ();
					w.writeEmptyElement ("empty-line");
				}

				w.writeStartElement ("p");
					w.writeComment ("p");
					w.device ()->write (FixContents (item->Description_).toUtf8 ());
				w.writeEndElement ();

				w.writeEmptyElement ("empty-line");
			}
Ejemplo n.º 2
0
void Argument1DString::writeData(QXmlStreamWriter &xmlWriter)
{
  xmlWriter.writeStartElement("Argument1D");
  {
    xmlWriter.writeAttribute("Id" , id());
    xmlWriter.writeAttribute("Caption" , caption());
    xmlWriter.writeAttribute("IsOptional" , isOptional() ? "True" : "False");

    for(const QString& comment : comments())
    {
      xmlWriter.writeComment(comment);
    }
    //write value definition;
    valueDefinitionInternal()->writeData(xmlWriter);

    xmlWriter.writeStartElement("Dimensions");
    {
      xmlWriter.writeStartElement("Dimension");
      {
        xmlWriter.writeAttribute("Id" , m_dimension->id());
        xmlWriter.writeAttribute("Caption" , m_dimension->caption());
        xmlWriter.writeAttribute("Length" , QString::number(length()));
      }
      xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Values");
    {
      int ind[1] = {0};
      int str[1] = {length()};
      QString* values = new QString[length()];
      getValues(ind,str,values);


      for(int i = 0 ; i < length() ; i++)
      {
        xmlWriter.writeStartElement("Value");
        {
          xmlWriter.writeCharacters(values[i]);
        }
        xmlWriter.writeEndElement();
      }

      delete[] values;
    }
    xmlWriter.writeEndElement();
  }
  xmlWriter.writeEndElement();
}
Ejemplo n.º 3
0
bool ErrorReport::WriteReport(const fs::path & fileName) {
	
	fs::path fullPath = m_ReportFolder / fileName;
	
	QFile file(fullPath.string().c_str());
	if(!file.open(QIODevice::WriteOnly)) {
		m_DetailedError = "Unable to open report manifest for writing.";
		return false;
	}
	
	QXmlStreamWriter xml;
	xml.setDevice(&file);
	xml.setAutoFormatting(true);
	xml.writeStartDocument();
	xml.writeStartElement("CrashReport");
		
		xml.writeComment("Information related to the crashed process");
		xml.writeStartElement("Process");
			xml.writeTextElement("Path", m_pCrashInfo->executablePath);
			xml.writeTextElement("Version", m_pCrashInfo->executableVersion);
			if(m_ProcessMemoryUsage != 0) {
				xml.writeTextElement("MemoryUsage", QString::number(m_ProcessMemoryUsage));
			}
			xml.writeTextElement("Architecture", m_ProcessArchitecture);
			if(m_RunningTimeSec > 0) {
				xml.writeTextElement("RunningTime", QString::number(m_RunningTimeSec));
			}
			xml.writeTextElement("CrashDateTime", m_CrashDateTime.toString("dd.MM.yyyy hh:mm:ss"));
		xml.writeEndElement();

		xml.writeComment("Information related to the OS");
		xml.writeStartElement("OS");
			if(!m_OSName.isEmpty()) {
				xml.writeTextElement("Name", m_OSName);
			}
			if(!m_OSArchitecture.isEmpty()) {
				xml.writeTextElement("Architecture", m_OSArchitecture);
			}
			if(!m_OSDistribution.isEmpty()) {
				xml.writeTextElement("Distribution", m_OSDistribution);
			}
		xml.writeEndElement();

		xml.writeComment("List of files generated by the crash reporter");
		xml.writeComment("Note that some of these files could have been manually excluded from the report");
		xml.writeStartElement("Files");
		for(FileList::const_iterator it = m_AttachedFiles.begin();
		    it != m_AttachedFiles.end(); ++it) {
			xml.writeTextElement("File", it->path.string().c_str());
		}
		xml.writeEndElement();

		xml.writeComment("Variables attached by the crashed process");
		xml.writeStartElement("Variables");
		for(int i = 0; i < m_pCrashInfo->nbVariables; ++i)
		{
			xml.writeStartElement("Variable");
			xml.writeAttribute("Name", m_pCrashInfo->variables[i].name);
			xml.writeAttribute("Value", m_pCrashInfo->variables[i].value);
			xml.writeEndElement();
		}
		xml.writeEndElement();
		
	xml.writeEndElement();
	xml.writeEndDocument();
	
	file.close();

	AddFile(fullPath);
	
	return true;
}