void DebugBreakpointManager::SaveState(const Poco::Path& path) const
{
  Poco::XML::Document* doc = new Poco::XML::Document();
  Poco::XML::Element* breakpoints = doc->createElement(BREAKPOINTS_TAG);
  doc->appendChild(breakpoints)->release();

  for (std::set<unsigned long>::const_iterator i = m_ObjectBreakpoints.begin(); i
      != m_ObjectBreakpoints.end(); ++i)
  {
    Poco::XML::Element* objectBreakpoint = doc->createElement(OBJECT_TAG);
    breakpoints->appendChild(objectBreakpoint)->release();
    std::stringstream ss;
    ss << *i;
    objectBreakpoint->setAttribute(ID_ATTR, ss.str());

    const Object* obj = DebugUtil::GetObject(*i);
    if (obj)
    {
      objectBreakpoint->setAttribute(CLASSNAME_ATTR, obj->GetClassName());

    }
  }

  for (Poco::HashMap<int, const Object*>::ConstIterator i =
      m_SmartPointerBreakpoints.begin(); i != m_SmartPointerBreakpoints.end(); ++i)
  {
    Poco::XML::Element* spBreakpoint = doc->createElement(SMARTPOINTER_TAG);
    breakpoints->appendChild(spBreakpoint)->release();
    std::stringstream ss;
    ss << i->first;
    spBreakpoint->setAttribute(ID_ATTR, ss.str());

    const Object* obj = i->second;
    if (i->second)
    {
      spBreakpoint->setAttribute(CLASSNAME_ATTR, obj->GetClassName());
      ss.clear();
      ss << obj->GetTraceId();
      spBreakpoint->setAttribute(OBJECTID_ATTR, ss.str());
    }
  }

  Poco::FileOutputStream writer(path.toString());
  Poco::XML::DOMWriter out;
  out.setOptions(3); //write declaration and pretty print
  out.writeNode(writer, doc);

  doc->release();
}
示例#2
0
void DebugUtil::SaveState()
{
    Poco::Path path;
    if (!GetPersistencePath(path)) return;

    path.setFileName(DEBUG_UTIL_XML);

    Poco::XML::Document* doc = new Poco::XML::Document();
    Poco::XML::Element* debugutil = doc->createElement(DEBUGUTIL_TAG);
    doc->appendChild(debugutil)->release();

    for (std::set<unsigned int>::const_iterator i = m_TracedObjects.begin();
            i != m_TracedObjects.end(); ++i)
    {
        Poco::XML::Element* traceObject = doc->createElement(TRACEOBJECT_TAG);
        debugutil->appendChild(traceObject)->release();
        std::stringstream ss;
        ss << *i;
        traceObject->setAttribute(ID_ATTR, ss.str());
    }

    for (std::set<std::string>::const_iterator i = m_TracedClasses.begin();
            i != m_TracedClasses.end(); ++i)
    {
        Poco::XML::Element* traceClass = doc->createElement(TRACECLASS_TAG);
        debugutil->appendChild(traceClass)->release();
        traceClass->setAttribute(NAME_ATTR, *i);
    }

    try
    {
        Poco::FileOutputStream writer(path.toString());
        Poco::XML::DOMWriter out;
        out.setOptions(3); //write declaration and pretty print
        out.writeNode(writer, doc);

        doc->release();

        // save BreakpointManager
        path.setFileName(DebugBreakpointManager::BREAKPOINTS_XML);
        GetBreakpointManager()->SaveState(path);
    }
    catch (Poco::FileException& e)
    {
        BERRY_WARN << e.displayText();
    }

}
示例#3
0
/**
 * save XML grouping file
 */
void saveGroupingTabletoXML(Ui::MuonAnalysis& m_uiForm, const std::string& filename)
{
  std::ofstream outFile(filename.c_str());
  if (!outFile)
  {
    throw Mantid::Kernel::Exception::FileError("Unable to open file:", filename);
  }

  DOMWriter writer;
  writer.setNewLine("\n");
  writer.setOptions(XMLWriter::PRETTY_PRINT);

  Poco::XML::Document* mDoc = new Document();
  Element* rootElem = mDoc->createElement("detector-grouping");
  rootElem->setAttribute("description", m_uiForm.groupDescription->text().toStdString());
  mDoc->appendChild(rootElem);

  // loop over groups in table

  std::vector<int> groupToRow;
  whichGroupToWhichRow(m_uiForm, groupToRow);

  int num = static_cast<int>(groupToRow.size());
  for (int i = 0; i < num; i++)
  {
    Element* gElem = mDoc->createElement("group");
    gElem->setAttribute("name", m_uiForm.groupTable->item(groupToRow[i],0)->text().toStdString());
    rootElem->appendChild(gElem);
    Element* idsElem = mDoc->createElement("ids");
    idsElem->setAttribute("val", m_uiForm.groupTable->item(groupToRow[i],1)->text().toStdString());
    gElem->appendChild(idsElem);
  }

  // loop over pairs in pair table

  num = m_uiForm.pairTable->rowCount();
  for (int i = 0; i < num; i++)
  {
    QTableWidgetItem *itemName = m_uiForm.pairTable->item(i,0);
    if (!itemName)
      break;
    if ( itemName->text().isEmpty() )
      break;
    QTableWidgetItem *itemAlpha = m_uiForm.pairTable->item(i,3);
    if (!itemAlpha)
      break;
    if ( itemAlpha->text().isEmpty() )
      break;

    QComboBox* qw1 = static_cast<QComboBox*>(m_uiForm.pairTable->cellWidget(i,1));
    QComboBox* qw2 = static_cast<QComboBox*>(m_uiForm.pairTable->cellWidget(i,2));

    Element* gElem = mDoc->createElement("pair");
    gElem->setAttribute("name", itemName->text().toStdString());
    rootElem->appendChild(gElem);
    Element* fwElem = mDoc->createElement("forward-group");
    fwElem->setAttribute("val", qw1->currentText().toStdString());
    gElem->appendChild(fwElem);
    Element* bwElem = mDoc->createElement("backward-group");
    bwElem->setAttribute("val", qw2->currentText().toStdString());
    gElem->appendChild(bwElem);
    Element* alphaElem = mDoc->createElement("alpha");
    alphaElem->setAttribute("val", itemAlpha->text().toStdString());
    gElem->appendChild(alphaElem);
  } 

  // save default

  Element* gElem = mDoc->createElement("default");
  gElem->setAttribute("name", m_uiForm.frontGroupGroupPairComboBox->currentText().toStdString());
  rootElem->appendChild(gElem);

  writer.writeNode(outFile, mDoc);
}