void GUI::ClientListComponent::writeClientDetailsToXML()
{
	File f=File(csplayerxmlFilePath);
	XmlDocument xmlDoc(f);
	//Csplayer to take document of XMLDocument
	ScopedPointer<XmlElement>  Csplayer;
	Csplayer=xmlDoc.getDocumentElement();
	
	if(File(csplayerxmlFilePath).exists())//if csPlayer.scp is exist.....
		 if(Csplayer)//if CsPlayer.scp is not blank....
			Csplayer->removeChildElement(Csplayer->getChildByName("Clients"), true);

	Csplayer=new XmlElement("CsPlayer");
	XmlElement  * clientElement =new XmlElement("Clients");
	Csplayer->addChildElement(clientElement);
	for(int row = 0; row < clientInfoArray.size(); row++)
	{
		Configurations::ClientInfo  tempClientInfo;
		tempClientInfo = clientInfoArray.getReference (row);
		XmlElement * clientNode = new XmlElement ("Client");
		tempClientInfo.toXML(clientNode);
		
		Csplayer->getChildByName("Clients")->addChildElement(clientNode);
	}
	Csplayer->writeToFile(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + "csPlayer.scp", String::empty);	
}
bool Wiinnertag::ReadXML(const string &filepath)
{
	TiXmlDocument xmlDoc(filepath.c_str());
	if(!xmlDoc.LoadFile())
		return false;

	TiXmlElement * node =  xmlDoc.FirstChildElement("Tag");

	while(node != NULL)
	{
		const char * URL = node->Attribute("URL");
		const char * Key = node->Attribute("Key");

		if(URL && Key)
		{
			int size = tagList.size();
			tagList.resize(size+1);
			tagList[size].first = URL;
			tagList[size].second = Key;
		}

		node = node->NextSiblingElement();
	}

	return true;
}
void rpi_control::readXML(QString i){


    QDomDocument xmlDoc("Control");
    xmlDoc.setContent(i);

    QDomElement docElem = xmlDoc.documentElement();
    readDomElement(docElem);

    /*if (docElem.tagName() == "Servo" ) { type_v = SERVO;}
    else if (docElem.tagName() == "BidirectionalMotor" ) { type_v = BIMOTOR;}
    else if (docElem.tagName() == "EscMotor" ) { type_v = ESCMOTOR;}*/


  /*  QDomNode n = docElem.firstChild();
    while(!n.isNull()) {
        QDomElement e = n.toElement(); // try to convert the node to an element.
        if(!e.isNull()) {
	    qDebug() << e.tagName();
            if (e.tagName() == "value") {
		setValue(e.text().toInt());
                //value_v = e.text().toInt();
            }
        }
        n = n.nextSibling();
    }*/


}
Exemple #4
0
void LoadFile(char* zName)
{
	TiXmlDocument xmlDoc(zName);
	xmlDoc.LoadFile();

	SoccerSerializer* poSerializer = new SoccerSerializer(&xmlDoc);
	poSerializer->Deserialize();
	delete poSerializer;
}
QStringList rpi_device::functionTest(){
    QStringList ret;
    rpi_device testDev1;
    testDev1.setAddress(37);
    testDev1.setDevice("Sensor");
    testDev1.setId(12);
    testDev1.setNode(67);
    testDev1.setPhiDev(34.23);
    testDev1.setThetaDev(182.35);
    testDev1.setSigmaDev(28.65);
    testDev1.setType(RPI_PRESSURE);
    testDev1.setXDev(-34.2);
    testDev1.setYDev(12.45);
    testDev1.setZDev(0.32);

    if ( (testDev1.address() != 37) ) ret << "Address Not Set";
    if ( (testDev1.device() != "Sensor") ) ret << "Device Name Not Set";
    if ( (testDev1.id() != 12) ) ret << "Id Not Set";
    if ( (testDev1.node() != 67) ) ret << "Node Not Set";
    if ( (testDev1.phiDev() != 34.23) ) ret << "Phi Not Set";
    if ( (testDev1.thetaDev() != 182.35) ) ret << "theta Not Set";
    if ( (testDev1.sigmaDev() != 28.65) ) ret << "Sigma Not Set";
    if ( (testDev1.type() != RPI_PRESSURE) ) ret << "Type Not Set";
    if ( (testDev1.xDev() != -34.2) ) ret << "x not set";
    if ( (testDev1.yDev() != 12.45) ) ret << "y not set";
    if ( (testDev1.zDev() != 0.32) ) ret << "z not set";

    rpi_device testDevEqual(testDev1);

    if (!(testDevEqual == testDev1)) {
        if (testDevEqual.errorString().size())
            ret << "Dev Equal Test";
        ret << testDevEqual.errorString();}

    QDomDocument xmlDoc("TestDevice");
    QDomElement root = xmlDoc.createElement("TestDevice");
    xmlDoc.appendChild(root);

    testDev1.addtoDomDoc(xmlDoc,root);
    QString xmlStr=  xmlDoc.toString();
    QDomDocument xmlDoc2("TestDevice");
    xmlDoc2.setContent(xmlStr);
    QDomElement docElem = xmlDoc2.documentElement();

    rpi_device testDevXml ;
    testDevXml.readDomElement(docElem);

    if (!(testDevXml == testDev1)) {
        if (testDevXml.errorString().size())
            ret << "Dev XML Test";
        ret << testDevXml.errorString();}


    return ret;
}
Exemple #6
0
bool CGameWorld::init()
{
	m_iTime = Sys_GetTime();


	const char* pFilePath = "setup.xml";

	TiXmlDocument xmlDoc(pFilePath);
	if (!xmlDoc.LoadFile())
	{
		CORE("init:","load setup.xml error");
		return false;
	}
	TiXmlElement *root = xmlDoc.RootElement();  
	if (root==NULL)
	{
		CORE("init:","init error RootElement");
		return false;
	}
	


	if (!initConfig(root->FirstChildElement("config")))
	{
		CORE("init:","initConfig error");
		return false;
	}

	if (!initNet(root->FirstChildElement("net")))
	{
		CORE("init:","initNet error");
		return false;
	}

	if (!initDB(root->FirstChildElement("db")))
	{
		CORE("init:","initDB error");
		return false;
	}

	if (!initData())
	{
		return false;
	}


	return true;

}
QString rpi_control::toXML(bool values,bool conf){
    QString name = "Control";
    switch (type_v) {
        case SERVO : { name = "Servo"; break;}
        case BIMOTOR :{ name = "BidirectionalMotor"; break;}
        case ESCMOTOR :{ name = "EscMotor"; break;}\
        default : { break;}
    }
    QDomDocument xmlDoc(name);
    QDomElement root = xmlDoc.createElement(name);
    xmlDoc.appendChild(root);
    addtoDomDoc(xmlDoc,root,values,conf);
    return xmlDoc.toString();

}
Exemple #8
0
void CFileView::SaveProject()
{
	if(CGlobalVariable::m_bIsProjectExist == false)
		return;

	CString strPathName = CGlobalVariable::m_strProjectPath + CGlobalVariable::m_strProjectName + _T(".uiproj");
	TiXmlDocument xmlDoc(StringConvertor::WideToAnsi(strPathName));
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);

	TiXmlElement xmlElem("DirectUIProject");
	xmlElem.SetAttribute("Name", StringConvertor::WideToUtf8(CGlobalVariable::m_strProjectName));
	xmlElem.SetAttribute("Version", StringConvertor::WideToUtf8(UIDESIGNER_VERSION));
	TiXmlNode* pNode = xmlDoc.InsertEndChild(xmlElem);

	SaveUITree(m_wndFileView.GetRootItem(), pNode->ToElement());
	xmlDoc.SaveFile();
}
QString rpi_request::toXML() {
    QDomDocument xmlDoc("request");
    QDomElement root = xmlDoc.createElement("request");
    QDomElement erequest = xmlDoc.createElement("request");
    QDomText trequest = xmlDoc.createTextNode(request());
    QDomElement ereply = xmlDoc.createElement("reply");
    xmlDoc.appendChild(root);
    root.appendChild(erequest);
    erequest.appendChild(trequest);
    root.appendChild(ereply);
    for (int k=0;k<reply().size();k++) {
        QDomElement ereplyk = xmlDoc.createElement("reply");
        QDomText treplyk = xmlDoc.createTextNode(reply()[k]);
        ereply.appendChild(treplyk);
        ereply.appendChild(ereplyk);
    }

    return xmlDoc.toString();
}
Exemple #10
0
xml::document applyResults( void )
{
    std::string         xsltDoc(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
            "version=\"1.0\">"
            "<xsl:output method=\"html\" indent=\"yes\"/>"
            "<xsl:template match=\"/\">"
                "<html><body>asd</body></html>"
            "</xsl:template>"
            "</xsl:stylesheet>" );

    std::string         xmlDoc( "<root/>" );
    xslt::stylesheet    style( xsltDoc.c_str(), xsltDoc.size() );
    xml::document       doc( xmlDoc.c_str(), xmlDoc.size(), NULL );
    xml::document       result = style.apply( doc );

    return result;
}
void CDataProcess::ReadXmlInfo(CString strPath)
{
	try
	{
		m_ConferenceSourceList.clear();
		ConferenceSource conferenceSource;
		TiXmlDocument xmlDoc(strPath);
		xmlDoc.LoadFile() ;
		TiXmlElement* xmlRootElement = 0;
		xmlRootElement = xmlDoc.RootElement();
		if (xmlRootElement == NULL)
			return;
		TiXmlElement* xmlConfElement = xmlRootElement->FirstChildElement();
		while (xmlConfElement)
		{
			conferenceSource.ConfId = xmlConfElement->FirstChildElementText("ConfId");
			conferenceSource.ConfName = xmlConfElement->FirstChildElementText("ConfName");
			conferenceSource.StartTime = xmlConfElement->FirstChildElementText("StartTime");
			conferenceSource.EndTime = xmlConfElement->FirstChildElementText("EndTime");
			conferenceSource.Department = xmlConfElement->FirstChildElementText("Department");
			TiXmlElement* xmlRoomElement = xmlConfElement->FirstChildElement("Room");
			if (xmlRoomElement)
			{
				conferenceSource.Room.RoomName = xmlRoomElement->FirstChildElementText("RoomName");
			}		
			conferenceSource.ParticipantNumber = xmlConfElement->FirstChildElementText("ParticipantNumber");
			conferenceSource.ConfState = xmlConfElement->FirstChildElementText("ConfState");
			conferenceSource.ConfType = xmlConfElement->FirstChildElementText("ConfType");
			m_ConferenceSourceList.push_back(conferenceSource);
			xmlConfElement = xmlConfElement->NextSiblingElement();
		}
	}
	catch (CException* e)
	{
	}
	catch(...){}
}
void GUI::ClientListComponent::readClientDetailsFromXML()
{
	if(File(csplayerxmlFilePath).exists())//if File CsPlayer.scp is exist
	{
		File f=File(csplayerxmlFilePath);
		XmlDocument xmlDoc(f);
		// Csplayer to take document of XMLDocument
		ScopedPointer<XmlElement>  Csplayer;
		Csplayer = xmlDoc.getDocumentElement();
	    if(Csplayer) //if CsPlayer.scp file is not blank....
		{   
			XmlElement * clientElement = Csplayer->getChildByName("Clients")->getChildByName("Client");
			while(clientElement)
			{
				Configurations::ClientInfo  tempClientInfo;
				tempClientInfo.fromXML(clientElement);
				// Add clientInformation into Array
				clientInfoArray.add(tempClientInfo);
				clientElement = clientElement->getNextElement();
			}
			clientListBox->updateContent();
		}
	}
}
void RemoteArchiveModel::replyFinished(QNetworkReply *reply)
{
    d_corpora.clear();
    emit layoutChanged();
    
    QNetworkReply::NetworkError error = reply->error();
    if (error != QNetworkReply::NoError)
    {
        QString errorValue(networkErrorToString(error));
        
        emit networkError(errorValue);
        
        reply->deleteLater();
        
        return;
    }
    
    QByteArray xmlData(reply->readAll());
    QScopedPointer<xmlDoc, XmlDocDeleter> xmlDoc(
        xmlReadMemory(xmlData.constData(), xmlData.size(), 0, 0, 0));
    if (xmlDoc == 0) {
        emit processingError("could not parse the corpus archive index.");
        return;
    }
    
    xmlNodePtr root = xmlDocGetRootElement(xmlDoc.data());
    if (QString::fromUtf8(reinterpret_cast<char const *>(root->name)) !=
        QString("corpusarchive")) {
        emit processingError("the corpus archive index has an incorrect root node.");
        return;
    }
    
    for (xmlNodePtr child = root->children; child != 0; child = child->next)
    {
        if (QString::fromUtf8(reinterpret_cast<char const *>(child->name)) !=
            QString("corpus"))
            continue;
        
        QString name(childValue(xmlDoc.data(), child->children, reinterpret_cast<xmlChar const *>("filename")));

        if (name.isNull())
            continue;
        
        // Chop the extension, we do not want to bother users.
        if (name.endsWith(DOWNLOAD_EXTENSION))
            name.chop(DOWNLOAD_EXTENSION.length());
        
        // Retrieve and verify file size.
        QString fileSizeStr = childValue(xmlDoc.data(), child->children, reinterpret_cast<xmlChar const *>("filesize"));
        if (fileSizeStr.isNull())
            continue;

        // Attempt to convert the size to a number.
        bool ok = true;
        size_t fileSize = fileSizeStr.toULong(&ok);
        if (!ok)
            continue;
        
        double fileSizeMB = fileSize / (1024 * 1024);
        
        RemoteArchiveEntry corpus;
        corpus.name = name;
        corpus.sentences = childValue(xmlDoc.data(), child->children, reinterpret_cast<xmlChar const *>("sentences")).toULong();
        corpus.size = fileSizeMB;
        corpus.description = childValue(xmlDoc.data(), child->children, reinterpret_cast<xmlChar const *>("shortdesc"));
        corpus.longDescription = childValue(xmlDoc.data(), child->children, reinterpret_cast<xmlChar const *>("desc")).trimmed();
        corpus.checksum = childValue(xmlDoc.data(), child->children, reinterpret_cast<xmlChar const *>("sha1"));
        
        d_corpora.push_back(corpus);        
    }

    emit layoutChanged();
    
    emit retrievalFinished();

    reply->deleteLater();
}
    void SkeletonAnimationManager::_animationsHaveLoaded(void* params)
    {
		FileManager::ReadFileCallbackParameters* rcp = (FileManager::ReadFileCallbackParameters*)params;
		
        if(rcp->result == ResultCode_OK)
        {
            // check to see if there is an animation load list
            std::set< std::string >* animationsToLoad = 0;
            
            if( rcp->userData.keyExists( ANIMATION_LIST_POINTER_KEY ) )
            {
                const Property* prop = rcp->userData.getValueForKey( ANIMATION_LIST_POINTER_KEY );
                animationsToLoad = prop->asPointer< std::set< std::string> >();
            }
            
            XMLDocument xmlDoc(rcp->buffer, rcp->length, "Animations");
            
            if(xmlDoc)
            {
                Property property;                
                if(xmlDoc.getRootIterator().getAttribute( "curveCollection", property ) )
                {
                    setCurveCollectionName( property.asString() );
                    if( animationsToLoad )
                    {
                        CurveManager::getManager().loadCurveCollection( getCurveCollectionName(),
                                                                        CallbackPtr(),
                                                                        *animationsToLoad );
                    }
                    else
                    {
                        CurveManager::getManager().loadCurveCollection(getCurveCollectionName());
                    }
                }
                
                XMLDocument::NamedIterator animationIt = xmlDoc.getNamedIteratorTo( "Animation" );
                
                while( animationIt )
                {
                    // we need to compare the animation name to the list of animations we want to
                    // export to see if we should export it...
                    bool shouldAddAnimation = true;
                    if( animationsToLoad )
                    {
                        Property aniNameProp;
                        animationIt.getAttribute( "name", aniNameProp );
                        std::string animationName = aniNameProp.asString();
                        
                        if( animationsToLoad->find( animationName ) == animationsToLoad->end() )
                        {
                            // this animation isn't in the load list, skip it
                            shouldAddAnimation = false;
                        }
                    }
                    
                    if( shouldAddAnimation )
                    {
                        Animation* ani =
                            Animation::createAnimationFromXmlNode( XMLDocument::Iterator(
                                                                    animationIt.getCurrentNode() ),
                                                                   mSkeleton );
                        
                        addAnimation(ani);
                    }
                    
                    ++animationIt;
                }
            }
            
            // we created a dynamic copy of the set because we need it to last through functions,
            // so we pass it through by pointer and delete it on this end
            if( animationsToLoad )
            {
                delete animationsToLoad;
            }
            
            delete [] rcp->buffer;
        }
    }
Exemple #15
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();
}
Exemple #16
0
Status FileManager::save( Object* object, QString strFileName )
{
    QStringList debugDetails = QStringList() << "FileManager::save" << QString( "strFileName = " ).append( strFileName );
    if ( object == nullptr ) { return Status( Status::INVALID_ARGUMENT, debugDetails << "object parameter is null" ); }

    QFileInfo fileInfo( strFileName );
    if ( fileInfo.isDir() ) { return Status( Status::INVALID_ARGUMENT, debugDetails << "strFileName points to a directory", tr( "Invalid Save Path" ), tr( "The file path you have specified (\"%1\") points to a directory, so the file cannot be saved." ).arg( fileInfo.absoluteFilePath() ) ); }
    if ( fileInfo.exists() && !fileInfo.isWritable() ) { return Status( Status::INVALID_ARGUMENT, debugDetails << "strFileName points to a file that is not writable", tr( "Invalid Save Path" ), tr( "The file path you have specified (\"%1\") cannot be written to, so the file cannot be saved. Please make sure that you have sufficient permissions to save to that location and try again." ).arg( fileInfo.absoluteFilePath() ) ); }

    QString strTempWorkingFolder;
    QString strMainXMLFile;
    QString strDataFolder;

    bool isOldFile = strFileName.endsWith( PFF_OLD_EXTENSION );
    if ( isOldFile )
    {
        qCDebug( mLog ) << "Save in Old Pencil File Format (*.pcl) !";

        strMainXMLFile = strFileName;
        strDataFolder = strMainXMLFile + "." + PFF_OLD_DATA_DIR;
    }
    else
    {
        qCDebug( mLog ) << "Save in New zipped Pencil File Format (*.pclx) !";

        strTempWorkingFolder = object->workingDir();
        Q_ASSERT( QDir( strTempWorkingFolder ).exists() );
        debugDetails << QString( "strTempWorkingFolder = " ).append( strTempWorkingFolder );

        qCDebug( mLog ) << "Temp Folder=" << strTempWorkingFolder;
        strMainXMLFile = QDir( strTempWorkingFolder ).filePath( PFF_XML_FILE_NAME );
        strDataFolder = QDir( strTempWorkingFolder ).filePath( PFF_OLD_DATA_DIR );
    }

    QFileInfo dataInfo( strDataFolder );
    if ( !dataInfo.exists() )
    {
        QDir dir( strDataFolder ); // the directory where filePath is or will be saved
        // creates a directory with the same name +".data"
        if( !dir.mkpath( strDataFolder ) )
        {
            debugDetails << QString( "dir.absolutePath() = %1" ).arg( dir.absolutePath() );
            if( isOldFile ) {
                return Status( Status::ERROR_FILE_CANNOT_OPEN, debugDetails, tr( "Cannot Create Data Directory" ), tr( "Cannot create the data directory at \"%1\". Please make sure that you have sufficient permissions to save to that location and try again. Alternatively try saving as pclx format." ).arg( strDataFolder ) );
            }
            else {
                return Status( Status::FAIL, debugDetails, tr("Internal Error"), tr( "Cannot create the data directory at temporary location \"%1\". Please make sure that you have sufficient permissions to save to that location and try again. Alternatively try saving as pcl format." ).arg( strDataFolder ) );
            }
        }
    }
    if( !dataInfo.isDir() )
    {
        debugDetails << QString( "dataInfo.absoluteFilePath() = ").append(dataInfo.absoluteFilePath());
        if( isOldFile ) {
            return Status( Status::ERROR_FILE_CANNOT_OPEN, debugDetails, tr( "Cannot Create Data Directory" ), tr( "Cannot use the path \"%1\" as a data directory since that currently points to a file. Please move or delete that file and try again. Alternatively try saving with the pclx format." ).arg( dataInfo.absoluteFilePath() ) );
        }
        else {
            return Status( Status::FAIL, debugDetails, tr( "Internal Error" ), tr( "Cannot use the data directory at temporary location \"%1\" since it is a file. Please move or delete that file and try again. Alternatively try saving with the pcl format." ).arg( dataInfo.absoluteFilePath() ) );
        }
    }

    // save data
    int layerCount = object->getLayerCount();
    debugDetails << QString("layerCount = %1").arg(layerCount);
    qCDebug( mLog ) << QString( "Total layers = %1" ).arg( layerCount );

    bool isOkay = true;
    for ( int i = 0; i < layerCount; ++i )
    {
        Layer* layer = object->getLayer( i );
        qCDebug( mLog ) << QString( "Saving Layer %1" ).arg( i ).arg( layer->mName );

        //progressValue = (i * 100) / nLayers;
        //progress.setValue( progressValue );
        debugDetails << QString("layer[%1] = Layer[id=%2, name=%3, type=%4]").arg( i ).arg( layer->id() ).arg( layer->name() ).arg( layer->type() );
        switch ( layer->type() )
        {
        case Layer::BITMAP:
        case Layer::VECTOR:
        case Layer::SOUND:
        {
            Status st = layer->save( strDataFolder );
            if( !st.ok() )
            {
                isOkay = false;
                QStringList layerDetails = st.detailsList();
                for ( QString detail : layerDetails )
                {
                    detail.prepend( "&nbsp;&nbsp;" );
                }
                debugDetails << QString( "- Layer[%1] failed to save" ).arg( i ) << layerDetails;
            }
            break;
        }
        case Layer::CAMERA:
            break;
        case Layer::UNDEFINED:
        case Layer::MOVIE:
            Q_ASSERT( false );
            break;
        }
        if( !isOkay )
        {
            return Status( Status::FAIL, debugDetails, tr( "Internal Error" ), tr( "An internal error occurred while trying to save the file. Some or all of your file may not have saved." ) );
        }
    }

    // save palette
    object->savePalette( strDataFolder );

    // -------- save main XML file -----------
    QScopedPointer<QFile> file( new QFile( strMainXMLFile ) );
    if ( !file->open( QFile::WriteOnly | QFile::Text ) )
    {
        return Status::ERROR_FILE_CANNOT_OPEN;
    }

    QDomDocument xmlDoc( "PencilDocument" );
    QDomElement root = xmlDoc.createElement( "document" );
    xmlDoc.appendChild( root );

    // save editor information
    //QDomElement editorElement = createDomElement( xmlDoc );
    //root.appendChild( editorElement );
    qCDebug( mLog ) << "Save Editor Node.";

    // save object
    QDomElement objectElement = object->saveXML( xmlDoc );
    root.appendChild( objectElement );
    qCDebug( mLog ) << "Save Object Node.";

    const int IndentSize = 2;

    QTextStream out( file.data() );
    xmlDoc.save( out, IndentSize );

    if ( !isOldFile )
    {
        qCDebug( mLog ) << "Now compressing data to PFF - PCLX ...";

        bool ok = JlCompress::compressDir( strFileName, strTempWorkingFolder );
        if ( !ok )
        {
            return Status::FAIL;
        }

        qCDebug( mLog ) << "Compressed. File saved.";
    }

    object->setFilePath( strFileName );
    object->setModified( false );

    return Status::OK;
}
Exemple #17
0
bool CDVDStateSerializer::DVDToXMLState( std::string &xmlstate, const dvd_state_t *state )
{
    char buffer[256];
    TiXmlDocument xmlDoc("navstate");

    TiXmlElement eRoot("navstate");
    eRoot.SetAttribute("version", 1);


    {   TiXmlElement eRegisters("registers");

        for( int i = 0; i < 24; i++ )
        {

            if( state->registers.SPRM[i] )
            {   TiXmlElement eReg("sprm");
                eReg.SetAttribute("index", i);

                {   TiXmlElement eValue("value");
                    sprintf(buffer, "0x%hx", state->registers.SPRM[i]);
                    eValue.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eValue);
                }

                eRegisters.InsertEndChild(eReg);
            }
        }

        for( int i = 0; i < 16; i++ )
        {
            if( state->registers.GPRM[i] || state->registers.GPRM_mode[i] || state->registers.GPRM_time[i].tv_sec || state->registers.GPRM_time[i].tv_usec )
            {   TiXmlElement eReg("gprm");
                eReg.SetAttribute("index", i);

                {   TiXmlElement eValue("value");
                    sprintf(buffer, "0x%hx", state->registers.GPRM[i]);
                    eValue.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eValue);
                }

                {   TiXmlElement eMode("mode");
                    sprintf(buffer, "0x%c", state->registers.GPRM_mode[i]);
                    eMode.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eMode);
                }

                {   TiXmlElement eTime("time");
                    {   TiXmlElement eValue("tv_sec");
                        sprintf(buffer, "%ld", state->registers.GPRM_time[i].tv_sec);
                        eValue.InsertEndChild( TiXmlText( buffer ) );
                        eTime.InsertEndChild( eValue ) ;
                    }

                    {   TiXmlElement eValue("tv_usec");
                        sprintf(buffer, "%ld", (long int)state->registers.GPRM_time[i].tv_usec);
                        eValue.InsertEndChild( TiXmlText( buffer ) );
                        eTime.InsertEndChild( eValue ) ;
                    }
                    eReg.InsertEndChild(eTime);
                }
                eRegisters.InsertEndChild(eReg);
            }
        }
        eRoot.InsertEndChild(eRegisters);
    }

    {   TiXmlElement element("domain");
        sprintf(buffer, "%d", state->domain);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("vtsn");
        sprintf(buffer, "%d", state->vtsN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("pgcn");
        sprintf(buffer, "%d", state->pgcN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("pgn");
        sprintf(buffer, "%d", state->pgN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("celln");
        sprintf(buffer, "%d", state->cellN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("cell_restart");
        sprintf(buffer, "%d", state->cell_restart);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("blockn");
        sprintf(buffer, "%d", state->blockN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement rsm("rsm");

        {   TiXmlElement element("vtsn");
            sprintf(buffer, "%d", state->rsm_vtsN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("blockn");
            sprintf(buffer, "%d", state->rsm_blockN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("pgcn");
            sprintf(buffer, "%d", state->rsm_pgcN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("celln");
            sprintf(buffer, "%d", state->rsm_cellN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement regs("registers");

            for( int i = 0; i < 5; i++ )
            {
                TiXmlElement reg("sprm");
                reg.SetAttribute("index", i);

                {   TiXmlElement element("value");
                    sprintf(buffer, "0x%hx", state->rsm_regs[i]);
                    element.InsertEndChild( TiXmlText(buffer) );
                    reg.InsertEndChild(element);
                }

                regs.InsertEndChild(reg);
            }
            rsm.InsertEndChild(regs);
        }
        eRoot.InsertEndChild(rsm);
    }


    xmlDoc.InsertEndChild(eRoot);

    std::stringstream stream;
    stream << xmlDoc;
    xmlstate = stream.str();
    return true;
}
int		tinyxml_WriteChannelList()
{
	char szFile[MAX_PATH_LENGTH] = {0,};
	int ret = VSRM_GetPath(szFile, MAX_PATH_LENGTH);
	if (ret < 0)		return -2;

#ifdef _WIN32
	strcat(szFile, "\\");
#else
	strcat(szFile, "/");
#endif
	strcat(szFile, "EasyNVR.xml");

	char szCharset[16] = {0,};

	strcpy(szCharset, "UTF-8");
	//if (_app_param.language==1001)	strcpy(szCharset, "gb2312");
	//else if (_app_param.language==1000)	strcpy(szCharset, "UTF-8");

	TiXmlDocument xmlDoc( szFile );
	TiXmlDeclaration Declaration( "1.0", szCharset, "yes" );
	xmlDoc.InsertEndChild( Declaration );

	TiXmlElement* pRootElm = NULL;
	pRootElm = new TiXmlElement( "CHANNEL_LIST" );


		TiXmlElement *pGroup = new TiXmlElement("GROUP");
		TiXmlElement *pGroupName = new TiXmlElement("NAME");
		TiXmlElement *pPushAddr = new TiXmlElement("PUSH_ADDR");

		TiXmlText *pName = new TiXmlText("group1");
		TiXmlText *pPushAddrText = new TiXmlText("192.168.1.7");

		pGroupName->InsertEndChild(*pName);
		pGroup->InsertEndChild(*pGroupName);

		pPushAddr->InsertEndChild(*pPushAddrText);
		pGroup->InsertEndChild(*pPushAddr);


			TiXmlElement *pDevice = new TiXmlElement("CHANNEL");
			{
				TiXmlElement *pChannelId = new TiXmlElement("ID");
				TiXmlText* pText = new TiXmlText("1");
				pChannelId->InsertEndChild(*pText);
				pDevice->InsertEndChild(*pChannelId);
				delete pText;
				delete pChannelId;
			}
			{
				TiXmlElement *pChannelId = new TiXmlElement("URL");
				TiXmlText* pText = new TiXmlText("rtsp://192.168.1.186:8557");
				pChannelId->InsertEndChild(*pText);
				pDevice->InsertEndChild(*pChannelId);
				delete pText;
				delete pChannelId;
			}

			pGroup->InsertEndChild(*pDevice);
			delete pDevice;


		pRootElm->InsertEndChild(*pGroup);
		delete pGroup;
		delete pGroupName;
		delete pName;
		delete pPushAddr;
		delete pPushAddrText;
	xmlDoc.InsertEndChild(*pRootElm) ;

	//xmlDoc.Print() ;
	if (xmlDoc.SaveFile())
	{
	}

	delete pRootElm;

	return 0;
}
void rpi_request::readXML(QString i) {
    QDomDocument xmlDoc("request");
    xmlDoc.setContent(i);
    QDomElement docElem = xmlDoc.documentElement();
}
Exemple #20
0
	void Puppet::Load(const std::string &filename, Entity *entity)
	{
		this->filename = filename;
		animations.clear();
		// delete parts?
		parts.clear();
		
		TiXmlDocument xmlDoc(Assets::GetContentPath() + filename);
		
		if (xmlDoc.LoadFile())
		{
			/// TextureAtlas
			TiXmlElement *xmlTextureAtlas = xmlDoc.FirstChildElement("TextureAtlas");
			if (xmlTextureAtlas)
			{
				textureAtlas = new TextureAtlas();
				textureAtlas->Load(xmlTextureAtlas);
			}
			
			/// Parts
			TiXmlElement *xmlParts = xmlDoc.FirstChildElement("Parts");
			if (xmlParts)
			{
				LoadParts(xmlParts, entity);
			}

			/// Animations
			TiXmlElement *xmlAnimations = xmlDoc.FirstChildElement("Animations");
			if (xmlAnimations)
			{
				/// Animation
				TiXmlElement *xmlAnimation = xmlAnimations->FirstChildElement("Animation");
				while (xmlAnimation)
				{
					Animation animation;
                    XMLFileNode xmlFileNodeKeyFrameAnim(xmlAnimation);
					animation.Load(&xmlFileNodeKeyFrameAnim);

					/// PartKeyFrames
					TiXmlElement *xmlPartKeyFrames = xmlAnimation->FirstChildElement("PartKeyFrames");
					while (xmlPartKeyFrames)
					{
						PartKeyFrames partKeyFrames;
						partKeyFrames.SetPuppet(this);
                        XMLFileNode xmlFileNodeKeyFramePart(xmlPartKeyFrames);
						partKeyFrames.Load(&xmlFileNodeKeyFramePart);

						/// KeyFrame
						TiXmlElement *xmlKeyFrame = xmlPartKeyFrames->FirstChildElement("KeyFrame");
						while (xmlKeyFrame)
						{
							KeyFrame keyFrame;
                            XMLFileNode xmlFileNodeKeyFrame(xmlKeyFrame);
							keyFrame.Load(&xmlFileNodeKeyFrame);
							partKeyFrames.AddKeyFrame(keyFrame);

							xmlKeyFrame = xmlKeyFrame->NextSiblingElement("KeyFrame");
						}

						animation.AddPartKeyFrames(partKeyFrames);

						xmlPartKeyFrames = xmlPartKeyFrames->NextSiblingElement("PartKeyFrames");
					}

					animation.RefreshDuration();
					animations.push_back(animation);

					xmlAnimation = xmlAnimation->NextSiblingElement("Animation");
				}
			}
		}
		else
		{
			Debug::Log("Warning: Could not open puppet file: " + Assets::GetContentPath() + filename);
			Debug::Log("         " + std::string(xmlDoc.ErrorDesc()));
			printf("         Row: %d\n", xmlDoc.ErrorRow());
		}
	}
Exemple #21
0
/* qparam filename Filepath of the XML file */
bool RomXML::LoadRomXMLData(const char* filename)
{
	Name.clear();
	Coder.clear();
	Version.clear();
	ShortDescription.clear();
	LongDescription.clear();
	Releasedate.clear();

	TiXmlDocument xmlDoc(filename);
	if(!xmlDoc.LoadFile())
		return false;

	TiXmlElement *appNode =  xmlDoc.FirstChildElement("app");
	if(!appNode)
		return false;

	TiXmlElement *node = NULL;

	node = appNode->FirstChildElement("name");
	if(node && node->FirstChild() && node->FirstChild()->Value())
		Name = node->FirstChild()->Value();

	node = appNode->FirstChildElement("coder");
	if(node && node->FirstChild() && node->FirstChild()->Value())
		Coder = node->FirstChild()->Value();

	node = appNode->FirstChildElement("version");
	if(node && node->FirstChild() && node->FirstChild()->Value())
		Version = node->FirstChild()->Value();

	node = appNode->FirstChildElement("short_description");
	if(node && node->FirstChild() && node->FirstChild()->Value())
		ShortDescription = node->FirstChild()->Value();

	node = appNode->FirstChildElement("long_description");
	if(node && node->FirstChild() && node->FirstChild()->Value())
		LongDescription = node->FirstChild()->Value();

	char ReleaseText[200];
	memset(ReleaseText, 0, sizeof(ReleaseText));

	node = appNode->FirstChildElement("release_date");
	if(node && node->FirstChild() && node->FirstChild()->Value())
		snprintf(ReleaseText, sizeof(ReleaseText), node->FirstChild()->Value());

	int len = (strlen(ReleaseText) - 6); //length of the date string without the 200000 at the end
	if (len == 8)
		snprintf(ReleaseText, sizeof(ReleaseText), "%c%c/%c%c/%c%c%c%c", ReleaseText[4], ReleaseText[5], ReleaseText[6], ReleaseText[7], ReleaseText[0], ReleaseText[1], ReleaseText[2], ReleaseText[3]);
	else if (len == 6)
		snprintf(ReleaseText, sizeof(ReleaseText), "%c%c/%c%c%c%c", ReleaseText[4], ReleaseText[5], ReleaseText[0], ReleaseText[1], ReleaseText[2], ReleaseText[3]);
	else
		snprintf(ReleaseText, sizeof(ReleaseText), "%s", ReleaseText);

	Releasedate = ReleaseText;

	node = appNode->FirstChildElement("arguments");
	if(!node)
		return true;

	TiXmlElement *argNode = node->FirstChildElement("arg");

	while(argNode)
	{
		if(argNode->FirstChild() && argNode->FirstChild()->Value())
			Arguments.push_back(std::string(argNode->FirstChild()->Value()));

		argNode = argNode->NextSiblingElement();
	}

	return true;
}
Exemple #22
0
void ExportTask::run()
{
    if( ! _outputFile.open(QIODevice::WriteOnly)) {
        LOG_WARNING(QString("Unable to open %1 in write mode").arg(_outputFile.fileName()));
        emit finished(tr("The file %1 can't be opened for writing").arg(_outputFile.fileName()));
        return;
    }

    emit currentStatusChanged(QString("Start to write the file"));
    QXmlStreamWriter xmlDoc(&_outputFile);
    xmlDoc.setAutoFormatting(true);
    xmlDoc.writeStartDocument("1.0", false);

    xmlDoc.writeStartElement("NML");
    // TODO: Configure the correct version number
    xmlDoc.writeAttribute("VERSION", "15");

    xmlDoc.writeEmptyElement("HEAD");
    xmlDoc.writeAttribute("COMPANY", "www.native-instruments.com");
    xmlDoc.writeAttribute("PROGRAM", "Traktor");

    xmlDoc.writeEmptyElement("MUSICFOLDERS");

    xmlDoc.writeStartElement("COLLECTION");
    xmlDoc.writeAttribute("ENTRIES", QString::number(_records.count()));
    for(QSqlRecord record : _records) {
        writeCollectionEntry(xmlDoc, record);
    }
    xmlDoc.writeEndElement(); // COLLECTION

    xmlDoc.writeEmptyElement("SETS");
    xmlDoc.writeAttribute("ENTRIES", "0");

    xmlDoc.writeStartElement("PLAYLISTS");
    xmlDoc.writeStartElement("NODE");
    xmlDoc.writeAttribute("NAME", "$ROOT");
    xmlDoc.writeAttribute("TYPE", "FOLDER");
    xmlDoc.writeStartElement("SUBNODES");
    xmlDoc.writeAttribute("COUNT", "1");
    xmlDoc.writeStartElement("NODE");
    xmlDoc.writeAttribute("NAME", QFileInfo(_outputFile).completeBaseName());
    xmlDoc.writeAttribute("TYPE", "PLAYLIST");
    xmlDoc.writeStartElement("PLAYLIST");
    if(_exportPlaylist) {
        xmlDoc.writeAttribute("ENTRIES", QString::number(_records.count()));
        xmlDoc.writeAttribute("TYPE", "LIST");

        for(QSqlRecord record : _records) {
            writePlaylistEntry(xmlDoc, record);
        }
    } else {
        xmlDoc.writeAttribute("ENTRIES", "0");
        xmlDoc.writeAttribute("TYPE", "LIST");
    }
    xmlDoc.writeEndElement(); // PLAYLIST
    xmlDoc.writeEndElement(); // NODE
    xmlDoc.writeEndElement(); // SUBNODES
    xmlDoc.writeEndElement(); // NODE
    xmlDoc.writeEndElement(); // PLAYLISTS

    xmlDoc.writeEndElement(); // NML
    xmlDoc.writeEndDocument();

    _outputFile.close();

    QString finalState = tr("File %1 has been correctly written. Now you can import the generated "
                            "collection in Traktor. Don't forget to set priority on information "
                            "from this collection instead of the one you already have.")
                         .arg(QFileInfo(_outputFile).fileName());
    emit finished(finalState);
}