void XMLConfiguration::save(std::ostream& ostr) const
{
	Poco::XML::DOMWriter writer;
	writer.setNewLine("\n");
	writer.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
	writer.writeNode(ostr, _pDocument);
}
void XMLConfiguration::save(const std::string& path) const
{
	Poco::XML::DOMWriter writer;
	writer.setNewLine("\n");
	writer.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
	writer.writeNode(path, _pDocument);
}
コード例 #3
0
ファイル: ofXml.cpp プロジェクト: 8morikazuto/openFrameworks
string ofXml::toString() const
{
    ostringstream stream;
    
    Poco::XML::DOMWriter writer;
    writer.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
    if(document) {
        try {
            writer.writeNode( stream, getPocoDocument() );
        } catch( exception & e ) {
            ofLogError("ofXml") << "toString(): " << e.what();
        }
    } else if(element){
        element->normalize();
        writer.writeNode( stream, element );
    }
    
    string tmp = stream.str();
    
    // don't know how else to get rid of the hidden <#text></#text> nodes :/
    ofStringReplace(tmp, "<#text>", "");
    ofStringReplace(tmp, "</#text>", "");
    
    return tmp;
}
コード例 #4
0
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();
}
コード例 #5
0
ファイル: berryDebugUtil.cpp プロジェクト: robotdm/MITK
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();
    }

}
コード例 #6
0
std::string Pothos::Topology::toDotMarkup(const std::string &request)
{
    //parse request arguments
    const auto result = Poco::JSON::Parser().parse(request.empty()?"{}":request);
    auto configObj = result.extract<Poco::JSON::Object::Ptr>();
    const auto portConfig = configObj->optValue<std::string>("port", "connected");

    //get a JSON dump of the topology
    const auto dumpResult = Poco::JSON::Parser().parse(this->dumpJSON(request));
    const auto topObj = dumpResult.extract<Poco::JSON::Object::Ptr>();
    const auto connsArray = topObj->getArray("connections");
    const auto blocksObj = topObj->getObject("blocks");
    std::vector<std::string> blockIds; blocksObj->getNames(blockIds);

    std::ostringstream os;
    os << "digraph flat_flows {" << std::endl;
    os << "    rankdir=LR;" << std::endl;
    os << "    node [shape=record, fontsize=10];" << std::endl;

    for (const auto &blockId : blockIds)
    {
        const auto blockObj = blocksObj->getObject(blockId);

        //form xml
        Poco::AutoPtr<Poco::XML::Document> xmlDoc(new Poco::XML::Document());
        auto nodeTable = xmlDoc->createElement("table");
        xmlDoc->appendChild(nodeTable);
        nodeTable->setAttribute("border", "0");
        nodeTable->setAttribute("cellpadding", "0");
        nodeTable->setAttribute("cellspacing", "0");
        auto nodeTr = xmlDoc->createElement("tr");
        nodeTable->appendChild(nodeTr);

        const bool enbFilter = portConfig == "connected";
        const auto inputPorts = getConnectedPortInfos(topObj, blockId, enbFilter, true);
        const auto outputPorts = getConnectedPortInfos(topObj, blockId, enbFilter, false);

        if (inputPorts->size() > 0)
        {
            nodeTr->appendChild(portInfoToElem(xmlDoc, inputPorts, "in"));
        }
        {
            auto nodeTd = xmlDoc->createElement("td");
            nodeTd->setAttribute("border", "0");
            nodeTr->appendChild(nodeTd);
            auto table = xmlDoc->createElement("table");
            nodeTd->appendChild(table);
            table->setAttribute("border", "0");
            table->setAttribute("cellspacing", "0");
            auto tr = xmlDoc->createElement("tr");
            table->appendChild(tr);
            auto td = xmlDoc->createElement("td");
            td->setAttribute("border", "1");
            td->setAttribute("bgcolor", "azure");
            tr->appendChild(td);
            auto name = blockObj->getValue<std::string>("name");
            if (name.empty()) name = "Empty Name";
            td->appendChild(xmlDoc->createTextNode(name));
        }
        if (outputPorts->size() > 0)
        {
            nodeTr->appendChild(portInfoToElem(xmlDoc, outputPorts, "out"));
        }

        //dot node entry
        os << "    ";
        os << std::hash<std::string>()(blockId);
        os << "[" << std::endl;
        os << "    shape=none," << std::endl;
        os << "    label=<" << std::endl;
        Poco::XML::DOMWriter write;
        write.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
        write.writeNode(os, xmlDoc);
        os << "    >" << std::endl;
        os << "];" << std::endl;
    }

    for (size_t c_i = 0; c_i < connsArray->size(); c_i++)
    {
        const auto conn = connsArray->getObject(c_i);
        os << "    ";
        os << std::hash<std::string>()(conn->getValue<std::string>("srcId"));
        os << ":__out__" << conn->getValue<std::string>("srcName");
        os << " -> ";
        os << std::hash<std::string>()(conn->getValue<std::string>("dstId"));
        os << ":__in__" << conn->getValue<std::string>("dstName");
        os << ";" << std::endl;
    }

    os << "}" << std::endl;
    return os.str();
}