コード例 #1
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::characters(const XMLChar ch[], int start, int length)
{
	if (length == 0) return;

	if (_unclosedStartTag) closeStartTag();
	_contentWritten = _contentWritten || length > 0;
	if (_inCDATA)
	{
		while (length-- > 0) writeXML(ch[start++]);
	}
	else
	{
		while (length-- > 0)
		{
			XMLChar c = ch[start++];
			switch (c)
			{
			case '"':  writeMarkup(MARKUP_QUOTENC); break;
			case '\'': writeMarkup(MARKUP_APOSENC); break;
			case '&':  writeMarkup(MARKUP_AMPENC); break;
			case '<':  writeMarkup(MARKUP_LTENC); break;
			case '>':  writeMarkup(MARKUP_GTENC); break;
			default:
				if (c >= 0 && c < 32)
				{
					if (c == '\t' || c == '\r' || c == '\n')
						writeXML(c);
					else
						throw XMLException("Invalid character token.");
				}
				else writeXML(c);
			}
		}
	}
}
コード例 #2
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId)
{
	if (!_inDTD) throw XMLException("Notation declaration not within DTD");
	if (!_inInternalDTD)
	{
		writeMarkup(" [");
		_inInternalDTD = true;
	}
	if (_options & PRETTY_PRINT)
	{
		writeNewLine();
		writeMarkup(_indent);
	}
	writeMarkup("<!NOTATION ");
	writeXML(name);
	if (systemId && !systemId->empty())
	{
		writeMarkup(" SYSTEM \"");
		writeXML(*systemId);
		writeMarkup("\"");
	}
	if (publicId && !publicId->empty())
	{
		writeMarkup(" PUBLIC \"");
		writeXML(*publicId);
		writeMarkup("\"");
	}
	writeMarkup(">");
}
コード例 #3
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName)
{
	if (!_inDTD) throw XMLException("Entity declaration not within DTD");
	if (!_inInternalDTD)
	{
		writeMarkup(" [");
		_inInternalDTD = true;
	}
	if (_options & PRETTY_PRINT)
	{
		writeNewLine();
		writeMarkup(_indent);
	}
	writeMarkup("<!ENTITY ");
	writeXML(name);
	if (!systemId.empty())
	{
		writeMarkup(" SYSTEM \"");
		writeXML(systemId);
		writeMarkup("\"");
	}
	if (publicId && !publicId->empty())
	{
		writeMarkup(" PUBLIC \"");
		writeXML(*publicId);
		writeMarkup("\"");
	}
	if (!notationName.empty())
	{
		writeMarkup(" NDATA ");
		writeXML(notationName);
	}
	writeMarkup(">");
}
コード例 #4
0
ファイル: GNEPOI.cpp プロジェクト: behrisch/sumo
void
GNEPOI::writeShape(OutputDevice& device) {
    if (getLaneParents().size() > 0) {
        // obtain fixed position over lane
        double fixedPositionOverLane = myPosOverLane > getLaneParents().at(0)->getGeometry().shape.length() ? getLaneParents().at(0)->getGeometry().shape.length() : myPosOverLane < 0 ? 0 : myPosOverLane;
        // write POILane using POI::writeXML
        writeXML(device, false, 0, getLaneParents().at(0)->getID(), fixedPositionOverLane, myPosLat);
    } else {
        writeXML(device, myGeo);
    }
}
コード例 #5
0
ファイル: web.cpp プロジェクト: jeffminton/Thesis
string Web::writeXML(Node *currNode, string prefix)
{
	string xmlOut;
	Attr *currAttributes;
	vector<string> attrKeys;

	xmlOut += prefix + "<" + currNode->getName();

	currAttributes = currNode->getAttrList();
	attrKeys = currAttributes->getKeyList();

	if(attrKeys.size() > 0)
	{
		for(int i = 0; i < attrKeys.size(); i++)
		{
			xmlOut += " " + attrKeys[i] + "=\"" + currAttributes->getAttr(attrKeys[i]) + "\"";
		}
	}

	xmlOut += ">\n";

	vector<string> children = currNode->getChildren();
	int reqGrpCount = currNode->getNumReqGrp();

	for(int i = 0; i < children.size(); i++)
	{
		xmlOut += writeXML(currNode->getChild(children[i]), prefix + '\t');
	}

	if(reqGrpCount > 0)
	{
		for(int i = 0; i < reqGrpCount; i++)
		{
			xmlOut += writeXML(currNode->getReqGrp(i), prefix + '\t');
		}
	}

	if(currNode->getName() == "reqgrp")
	{
		vector<string> reqConcept = currNode->getReqConcept();
		vector<string> reqParent = currNode->getReqParent();

		for(int i = 0; i < reqConcept.size(); i++)
		{
			xmlOut += prefix + '\t' + "<req parent=\"" + reqParent[i] + "\">" + reqConcept[i] + "</req>\n";
		}
	}

	xmlOut += prefix + "</" + currNode->getName() + ">\n";
	
	return xmlOut;
}
コード例 #6
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeName(const XMLString& prefix, const XMLString& localName)
{
	if (prefix.empty())
	{
		writeXML(localName);
	}
	else
	{
		writeXML(prefix); 
		writeMarkup(MARKUP_COLON); 
		writeXML(localName);
	}
}
コード例 #7
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::processingInstruction(const XMLString& target, const XMLString& data)
{
	if (_unclosedStartTag) closeStartTag();
	prettyPrint();
	writeMarkup("<?");
	writeXML(target);
	if (!data.empty())
	{
		writeMarkup(MARKUP_SPACE);
		writeXML(data);
	}
	writeMarkup("?>");
	if (_depth == 0)
		writeNewLine();
}
コード例 #8
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeEndElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname)
{
	if (_unclosedStartTag && !(_options & CANONICAL_XML))
	{
		writeMarkup(MARKUP_SLASHGT);
		_unclosedStartTag = false;
	}
	else
	{
		if (_unclosedStartTag)
		{
			writeMarkup(MARKUP_GT);
			_unclosedStartTag = false;
		}
		writeMarkup(MARKUP_LTSLASH);
		if (!localName.empty())
		{
			XMLString prefix = _namespaces.getPrefix(namespaceURI);
			writeName(prefix, localName);
		}
		else
		{
			writeXML(qname);
		}
		writeMarkup(MARKUP_GT);
	}
	_namespaces.popContext();
}
コード例 #9
0
ファイル: web.cpp プロジェクト: jeffminton/Thesis
bool Web::writeXML(string xmlFilePath)
{
	if(xmlFilePath[xmlFilePath.length() - 1] != '/')
	{
		xmlFilePath += "/";
	}
	
	ofstream conceptXMLFile, wordXMLFile;
	
	conceptXMLFile.open((xmlFilePath + "concepts.xml").c_str(), ofstream::out);
	wordXMLFile.open((xmlFilePath + "words.xml").c_str(), ofstream::out);

	if(conceptXMLFile.fail() || wordXMLFile.fail())
	{
		fprintf(outFile, "conceptFile status: %d\nwordFile status: %d\n", (int) conceptXMLFile.fail(), (int) wordXMLFile.fail());
		return false;
	}

	string conceptXMLOut = writeXML(root, "");
	string wordXMLOut = writeWordsXML();

	conceptXMLFile.write(conceptXMLOut.c_str(), conceptXMLOut.length());
	wordXMLFile.write(wordXMLOut.c_str(), wordXMLOut.length());
	
	conceptXMLFile.close();
	wordXMLFile.close();

	return true;
}
コード例 #10
0
ファイル: parameterDialog.cpp プロジェクト: cacunas/VAT
void ParameterDialog::on_createButton_clicked(){
    QString fileName = QFileDialog::getSaveFileName(this, "Save Config file", "./", ("xml (*.xml);; All Files (*.*)"));
    QFile file(fileName);
    QString text;
    if(file.open(QIODevice::WriteOnly|QIODevice::Text)){
        text = "<!DOCTYPE MODULE_PARAMETERS>\n<MODULE_PARAMETERS>\n";
        std::deque<ModuleInterface *>::iterator it, it_end = va->moduleSequence.end();

        for(it = va->moduleSequence.begin(); it != it_end; it++) {
            QString moduleName = (*it)->name.c_str();
            text += "<"+moduleName+">\n";
            std::deque<parameter>::iterator it_m, it_m_end = (*it)->listParameters.end();
            for(it_m = (*it)->listParameters.begin(); it_m != it_m_end ; it_m++)
                text += writeXML(*it_m);
            text += "</"+moduleName+">\n";
        }
        text += "</MODULE_PARAMETERS>";
#ifdef __COMPILE_QT5__
        file.write(text.toLatin1());
#else
        file.write(text.toAscii());
#endif
        file.close();
    }
}
コード例 #11
0
ファイル: configxml.cpp プロジェクト: patronik/magentoTools
bool ConfigXML::createDeclFile()
{    
    QDomDocument document;    
    QDomProcessingInstruction xmldecl = document.createProcessingInstruction("xml", "version=\"1.0\"");
    document.appendChild(xmldecl);

    QDomElement config = document.createElement("config");
    document.appendChild(config);

    QDomElement modules = document.createElement("modules");
    config.appendChild(modules);

    QDomElement module = document.createElement(CnMn);
    modules.appendChild(module);

    QDomElement active = document.createElement("active");    
    active.appendChild(document.createTextNode("true"));
    module.appendChild(active);

    QDomElement poolElement = document.createElement("codePool");    
    poolElement.appendChild(document.createTextNode(moduleConf->getPool()));
    module.appendChild(poolElement); 

    return writeXML(getDeclFilePath(), document);
}
コード例 #12
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::comment(const XMLChar ch[], int start, int length)
{
	if (_unclosedStartTag) closeStartTag();
	prettyPrint();
	writeMarkup("<!--");
	while (length-- > 0) writeXML(ch[start++]);
	writeMarkup("-->");
	_contentWritten = false;
}
コード例 #13
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId)
{
	writeMarkup("<!DOCTYPE ");
	writeXML(name);
	if (!publicId.empty())
	{
		writeMarkup(" PUBLIC \"");
		writeXML(publicId);
		writeMarkup("\"");
	}
	if (!systemId.empty())
	{
		writeMarkup(" SYSTEM \"");
		writeXML(systemId);
		writeMarkup("\"");
	}
	_inDTD = true;
}
コード例 #14
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeMarkup(const std::string& str) const
{
#if defined(XML_UNICODE_WCHAR_T)
	const XMLString xmlString = toXMLString(str);
	writeXML(xmlString);
#else
	_pTextConverter->write(str.data(), (int) str.size());
#endif
}
コード例 #15
0
ファイル: IexFmncFab.cpp プロジェクト: epsitech/fabmaniac
void IexFmncFab::writeXMLFile(
			const string& fullpath
			, const bool shorttags
		) {
	xmlTextWriter* wr = NULL;

	startwriteFile(fullpath, &wr);
		writeXML(wr, shorttags);
	closewriteFile(wr);
};
コード例 #16
0
/*!
    \fn CvGaborFeature::write(const char* filename) const
 */
void CvGaborFeature::write(const char* filename) const
{
  string str(filename);
  size_t found;
  found = str.find_last_of(".");
  string ext = str.substr(found+1);
  
  if ((ext.compare("xml")==0)||(ext.compare("XML")==0))  writeXML( filename );
  else if (ext.compare("txt")==0) writeTXT( filename );
  else writeTXT( filename );
}
コード例 #17
0
 /*public*/ void OperationsSetupXml::writeFile(QString name) //throw (FileNotFoundException, IOException)
 {
     if (log->isDebugEnabled()) {
         log->debug(tr("writeFile %1").arg(name));
     }
     // This is taken in large part from "Java and XML" page 368
     QFile* file = findFile(name);
     if (file == NULL) {
         file = new QFile(name);
     }
     // create root element
     doc = QDomDocument("operations-config");
     QDomProcessingInstruction xmlProcessingInstruction = doc.createProcessingInstruction("xml", "version=\"1.0\"  encoding=\"UTF-8\"");
     doc.appendChild(xmlProcessingInstruction);//    QDomElement root = QDomElement("operations-config"); // NOI18N
 //    QDomDocument doc = newDocument(root, dtdLocation + "operations-config.dtd"); // NOI18N
     //QDomDocument doc;

     QDomElement root = doc.createElement("operations-config");

     // add XSLT processing instruction
 //    java.util.Map<String, String> m = new java.util.HashMap<String, String>();
 //    m.put("type", "text/xsl"); // NOI18N
 //    m.put("href", xsltLocation + "operations-config.xsl"); // NOI18N
 //    ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m); // NOI18N
 //    doc.addContent(0, p);
     QDomProcessingInstruction p = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"/xml/XSLT/operations-config.xsl\"");
     doc.appendChild(p);
     doc.appendChild(root);
     root.appendChild(doc.createComment(tr("Written by JMRI version %1 on %1").arg(Version::getCanonicalVersion()).arg(QDateTime::currentDateTime().toString())));

     // add top-level elements
     Setup::setDoc(doc);
     root.appendChild(Setup::store());

     // add manifest header text strings
     root.appendChild(TrainManifestHeaderText::store(doc));

     // add manifest text strings
     root.appendChild(TrainManifestText::store(doc));

     // add switch list text strings
     root.appendChild(TrainSwitchListText::store(doc));

     // add control elements
     Control::setDoc(doc);
     root.appendChild(Control::store());

     writeXML(file, doc);

     // done, so can't be dirty
     setDirty(false);
 }
コード例 #18
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
{
	for (AttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it)
	{
		if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES))
		{
			writeNewLine();
			writeIndent(_depth + 1);
		}
		else
		{
			writeMarkup(MARKUP_SPACE);
		}
		writeXML(it->first);
		writeMarkup(MARKUP_EQQUOT);
		for (XMLString::const_iterator itc = it->second.begin(); itc != it->second.end(); ++itc)
		{
			XMLChar c = *itc;
			switch (c)
			{
			case '"':  writeMarkup(MARKUP_QUOTENC); break;
			case '\'': writeMarkup(MARKUP_APOSENC); break;
			case '&':  writeMarkup(MARKUP_AMPENC); break;
			case '<':  writeMarkup(MARKUP_LTENC); break;
			case '>':  writeMarkup(MARKUP_GTENC); break;
			case '\t': writeMarkup(MARKUP_TABENC); break;
			case '\r': writeMarkup(MARKUP_CRENC); break;
			case '\n': writeMarkup(MARKUP_LFENC); break;
			default:
				if (c >= 0 && c < 32)
					throw XMLException("Invalid character token.");
				else 
					writeXML(c);
			}
		}
		writeMarkup(MARKUP_QUOT);
	}
}
コード例 #19
0
ファイル: parameterDialog.cpp プロジェクト: cacunas/VAT
QString ParameterDialog::writeXML(parameter &parent){
    QString text;

    if( parent.subParam.empty()){
        text = "<"+parent.name + " value=\""+parent.value+"\"/>\n";
        return text;
    }
    std::multimap<QString, parameter>::iterator it, it_end = parent.subParam.end();
    text += "<"+parent.name + " value=\""+parent.value+"\" >\n";
    for(it = parent.subParam.begin(); it != it_end; it++){
        text += writeXML((*it).second);
    }
    text += "</"+parent.name + " >\n";
    return text;

}
コード例 #20
0
long
GUIDialog_EditViewport::onCmdSave(FXObject*, FXSelector, void* /*data*/) {
    FXString file = MFXUtils::getFilename2Write(this, "Save Viewport", ".xml", GUIIconSubSys::getIcon(ICON_EMPTY), gCurrentFolder);
    if (file == "") {
        return 1;
    }
    try {
        OutputDevice& dev = OutputDevice::getDevice(file.text());
        dev.openTag(SUMO_TAG_VIEWSETTINGS);
        writeXML(dev);
        dev.closeTag();
        dev.close();
    } catch (IOError& e) {
        FXMessageBox::error(this, MBOX_OK, "Storing failed!", "%s", e.what());
    }
    return 1;
}
コード例 #21
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
	if (!_nsContextPushed)
		_namespaces.pushContext();
	_nsContextPushed = false;
	++_elementCount;
	writeMarkup(MARKUP_LT);
	if (!localName.empty() && (qname.empty() || localName == qname))
	{
		XMLString prefix;
		if (!namespaceURI.empty() && !_namespaces.isMapped(namespaceURI))
		{
			prefix = newPrefix();
			_namespaces.declarePrefix(prefix, namespaceURI);
		}
		else prefix = _namespaces.getPrefix(namespaceURI);
		writeName(prefix, localName);
	}
	else if (namespaceURI.empty() && localName.empty() && !qname.empty())
	{
		writeXML(qname);
	}
	else if (!localName.empty() && !qname.empty())
	{
		XMLString local;
		XMLString prefix;
		Name::split(qname, prefix, local);
		if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI);
		const XMLString& uri = _namespaces.getURI(prefix);
		if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty())
		{
			_namespaces.declarePrefix(prefix, namespaceURI);
		}
		writeName(prefix, localName);
	}
	else throw XMLException("Tag mismatch", nameToString(localName, qname));

	declareAttributeNamespaces(attributes);
	AttributeMap attributeMap;
	addNamespaceAttributes(attributeMap);
	addAttributes(attributeMap, attributes, namespaceURI);
	writeAttributes(attributeMap);
	_unclosedStartTag = true;
}
コード例 #22
0
ShortestDistance::ShortestDistance(char const* OutputFileName, char const* airportsFileName, char const* routesFileName, char const* airlinesFilename):filename(OutputFileName)
{
        ifstream in(OutputFileName);
        getline(in,line);
        if(line.compare("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"))
        {
            in.close();
            clock_t start= clock();
            out.open(OutputFileName);
            airports.open(airportsFileName);
            routes.open(routesFileName);
            airlines.open(airlinesFilename);
            parseAirports(dataMap);
            parseRoutes(dataMap);
            parseAirline(carrierNames);
            writeXML(dataMap, carrierNames);
            cout << "Parsing: " << (clock() - start)/(double)CLOCKS_PER_SEC << " seconds." << endl;
        }
        in.close();
        createTable();
}
コード例 #23
0
// This function creates the first network and save it in the QFile fi
void TestXmlParsing::createNetwork1(NeuralNetwork *network1, QFile *fi)
{
    network1->setMathFunction(stringToMathFunction("10*x/(1+(x*x)"));
    // Creation of the list of the layers sizes
    QList<int> *numbers = new QList <int> ;
    numbers->push_back(2);
    numbers->push_back(5);
    numbers->push_back(3);
    // Creation of the layers
    network1->createLayerList(numbers);
    delete numbers ;
    network1->linkLayers(true);

    // Writing file
    fi->open(QIODevice::ReadWrite) ;
    QXmlStreamWriter *stream = new QXmlStreamWriter(fi);
    stream->setAutoFormatting(true);
    stream->writeStartDocument();
    writeXML(network1, stream) ;
    stream->writeEndDocument();
    delete stream ;
    fi->close();
}
コード例 #24
0
ファイル: NAnim.cpp プロジェクト: Aliandrana/SuperPlay
bool NAnim::save(const std::string& _strPNGFilename, const std::string& _strXMLFilename)
{
	if (false == File::createDirectory(Functions::getDirectoryFromPath(_strPNGFilename)))
	{
		return	false;
	}

	if (false == writePNG(_strPNGFilename))
	{
		return	false;
	}

	if (false == File::createDirectory(Functions::getDirectoryFromPath(_strXMLFilename)))
	{
		return	false;
	}

	if (false == writeXML(_strPNGFilename, _strXMLFilename))
	{
		return	false;
	}

	return	true;
}
コード例 #25
0
//--------------------------------------------------------------
void handleChapters::readDir(){
    
    printf("reading directory sir\n");
    
    // load content
    dir.listDir("content/");
	dir.sort(); // in linux the file system doesn't return file lists ordered in alphabetical order
    
	//allocate the vector to have as many strings as files
	if( dir.size() ){
		chapters.assign(dir.size(), Chapters());
	}
    
	// you can now iterate through the files and load them into the Chapters vector
	for(int i = 0; i < (int)dir.size(); i++){
        
        file.open(dir.getPath(i));
        if(file.isDirectory()){
            dir.sort(); // do this again to alfabetize
            
            chapters[i].complete = false; // don't worry kids, we're just not certain yet
            chapters[i].inOrder  = false; // let me get back to that
            
            chapters[i].name = dir.getName(i);
            printf("%s\n",chapters[i].name.c_str());
            // getting filename should be a folder
            
            
            // write a new chapter to the XMl object
            if( XML.pushTag("movies", lastTagNumber) ){
                
                dir.listDir(dir.getPath(i)+"/");
                dir.sort();
                
                int lastChapNumber = XML.addTag("chapter");
                // writing chapter folder name to XML object
                XML.setValue("chapter:name", chapters[i].name, lastChapNumber);
                
                //printf("tagNum: %i\n",lastChapNumber);
                //printf("lastTagNumber: %i\n",lastTagNumber);
                
                // iterate through directory
                for(int f = 0; f < (int)dir.size(); f++){
                    file.open(dir.getPath(f));
                    
                    printf("iterating through directory %i\n",f);
                    
                    if(file.isFile()){
                        file.open(dir.getPath(f));
                        
                        // check if movie is named L, M or R then add to filmInfo object thats inside Chapters
                        // furthermore we check for several aspects of the film files, some info is only gained
                        // when actually loading the video, so thats where the tempMov kicks in. This is a bit
                        // processor heavy though, so do't do it all the time!
                        string baseName = file.getBaseName();
                        string firstChar = "";
                        firstChar += baseName[0];
                        
                        printf("filename: %s\n", dir.getName(f).c_str());
                        
                        if(firstChar == "L"){ // left screen duh
                            chapters[i].left.file = dir.getPath(f);
                            chapters[i].left.name = dir.getName(f);
                            chapters[i].left.filesize = file.getSize();
                            
                            ofVideoPlayer vid;
                            videos.push_back(vid);
                            
                            if (videos.back().loadMovie(chapters[i].left.file)) {
                                chapters[i].left.width     = videos.back().getWidth();
                                chapters[i].left.height    = videos.back().getHeight();
                                chapters[i].left.duration  = videos.back().getDuration();
                                chapters[i].left.numFrames = videos.back().getTotalNumFrames();
                            }
                            
                            chapters[i].left.sameSettings = false; // figure this out later
                            
                            if( XML.pushTag("chapter", lastChapNumber) ){
                                int tagNum = XML.addTag("left");
                                // writing film info of this thing to XML
                                XML.setValue("left:file", chapters[i].left.file, tagNum);
                                XML.setValue("left:name", chapters[i].left.name, tagNum);
                                XML.setValue("left:duration", chapters[i].left.duration, tagNum);
                                XML.setValue("left:frames", chapters[i].left.numFrames, tagNum);
                                XML.setValue("left:filesize", chapters[i].left.filesize, tagNum);
                                XML.setValue("left:width", chapters[i].left.width, tagNum);
                                XML.setValue("left:height", chapters[i].left.height, tagNum);
                                XML.popTag();
                            }
                        } else if(firstChar == "M"){ // middle screen duh
                            chapters[i].middle.file = dir.getPath(f);
                            chapters[i].middle.name = dir.getName(f);
                            chapters[i].middle.filesize = file.getSize();
                            
                            ofVideoPlayer vid;
                            videos.push_back(vid);
                            
                            if (videos.back().loadMovie(chapters[i].middle.file)) {
                                chapters[i].middle.width     = videos.back().getWidth();
                                chapters[i].middle.height    = videos.back().getHeight();
                                chapters[i].middle.duration  = videos.back().getDuration();
                                chapters[i].middle.numFrames = videos.back().getTotalNumFrames();
                            }
                            
                            chapters[i].middle.sameSettings = false; // figure this out later
                            
                            if( XML.pushTag("chapter", lastChapNumber) ){
                                int tagNum = XML.addTag("middle");
                                // writing film info of this thing to XML
                                XML.setValue("middle:file", chapters[i].middle.file, tagNum);
                                XML.setValue("middle:name", chapters[i].middle.name, tagNum);
                                XML.setValue("middle:duration", chapters[i].middle.duration, tagNum);
                                XML.setValue("middle:frames", chapters[i].left.numFrames, tagNum);
                                XML.setValue("middle:filesize", chapters[i].middle.filesize, tagNum);
                                XML.setValue("middle:width", chapters[i].middle.width, tagNum);
                                XML.setValue("middle:height", chapters[i].middle.height, tagNum);
                                XML.popTag();
                            }
                        } else if(firstChar == "R"){ // right screen duh
                            chapters[i].right.file = dir.getPath(f);
                            chapters[i].right.name = dir.getName(f);
                            chapters[i].right.filesize = file.getSize();
                            
                            ofVideoPlayer vid;
                            videos.push_back(vid);
                            
                            if (videos.back().loadMovie(chapters[i].right.file)) {
                                chapters[i].right.width     = videos.back().getWidth();
                                chapters[i].right.height    = videos.back().getHeight();
                                chapters[i].right.duration  = videos.back().getDuration();
                                chapters[i].right.numFrames = videos.back().getTotalNumFrames();
                            }
                            
                            chapters[i].right.sameSettings = false; // figure this out later
                            
                            if( XML.pushTag("chapter", lastChapNumber) ){
                                int tagNum = XML.addTag("right");
                                // writing film info of this thing to XML
                                XML.setValue("right:file", chapters[i].right.file, tagNum);
                                XML.setValue("right:name", chapters[i].right.name, tagNum);
                                XML.setValue("right:duration", chapters[i].right.duration, tagNum);
                                XML.setValue("right:frames", chapters[i].left.numFrames, tagNum);
                                XML.setValue("right:filesize", chapters[i].right.filesize, tagNum);
                                XML.setValue("right:width", chapters[i].right.width, tagNum);
                                XML.setValue("right:height", chapters[i].right.height, tagNum);
                                XML.popTag();
                            }
                        }
                    }
                }
                dir.listDir("content/");
                dir.sort();
                // pop out of chapter
                XML.popTag();
            }
            
        } else {
            printf("no directory senior! - %s\n", dir.getPath(i).c_str());
        }
    }
    checkFiles(); // checking to see if all files are in order
    writeXML(); // write it to an XML file, makes it easy to check whats wrong
    
    // chopping up the xml file into 300 char pieces so I can send it over the MPE network for checking
    XML.copyXmlToString(totalXmlString);
    totalXmlString.erase(std::remove(totalXmlString.begin(), totalXmlString.end(), '\n'), totalXmlString.end());
    totalXmlString.erase(std::remove(totalXmlString.begin(), totalXmlString.end(), ' '), totalXmlString.end());
    totalXmlString.erase(std::remove(totalXmlString.begin(), totalXmlString.end(), ','), totalXmlString.end());
    int chopLength = 300;
    float fChops = float(totalXmlString.size())/float(chopLength);
    float fChopsRoundUP = ceil(fChops);
    int numChops = int(fChopsRoundUP);
    partXML.resize(numChops);
    for (int i = 0; i < numChops; i++) {
        partXML[i].part = totalXmlString.substr(i*chopLength,chopLength);
        partXML[i].checked = false;
    }
    
    // deleting the videoplayer instances we just used

    
    for (int i = 0; i < videos.size(); i++) {
        videos[i].close();
    }
    videos.erase(videos.begin(), videos.end());
    
}
コード例 #26
0
ファイル: configxml.cpp プロジェクト: patronik/magentoTools
bool ConfigXML::createConfigFile()
{
    bool hasGlobal = false, hasFrontend = false, hasAdmin = false;

    QDomDocument document;
    configXMLDoc = &document;

    QDomProcessingInstruction xmldecl = document.createProcessingInstruction("xml", "version=\"1.0\"");
    document.appendChild(xmldecl); 

    // config element
    QDomElement config = document.createElement("config");
    document.appendChild(config);



    // MODULES & VERSION /////////////////////////////////////////
    // modules section
    QDomElement modules = document.createElement("modules");
    config.appendChild(modules);

    // module name
    QDomElement module = document.createElement(CnMn);
    modules.appendChild(module);

    // version
    QDomElement version = document.createElement("version");    
    version.appendChild(document.createTextNode(moduleConf->getModuleVersion()));
    module.appendChild(version);    
    // MODULES & VERSION END /////////////////////////////////////////

    // init global, frontend, admin sections
    QDomElement global = document.createElement("global");
    QDomElement frontend = document.createElement("frontend");
    QDomElement admin = document.createElement("admin");


    // blocks | models | helpers   
    if (moduleConf->getHasBlock()        
        || moduleConf->getHasHelper()
        || moduleConf->getHasModel()
        || moduleConf->getHasScript()
       )
    {
        hasGlobal = true;

        // init blocks, helpers, models sections
        QDomElement blocks = document.createElement("blocks");
        QDomElement helpers = document.createElement("helpers");
        QDomElement models = document.createElement("models");

        if (moduleConf->getHasBlock()) {            
            // block module
            QDomElement blockModule = document.createElement(
                        moduleConf->getModuleName().toLower()
                    );
            blocks.appendChild(blockModule);

            // class
            QDomElement blockClass = document.createElement("class");            
            blockClass.appendChild(document.createTextNode(CnMn + "_Block"));
            blockModule.appendChild(blockClass);

            // blocks section
            global.appendChild(blocks);
        }

        if (moduleConf->getHasHelper()) {            
            // helpers module
            QDomElement helperModule = document.createElement
                    (moduleConf->getModuleName().toLower()
                    );
            helpers.appendChild(helperModule);

            // class
            QDomElement helperClass = document.createElement("class");            
            helperClass.appendChild(document.createTextNode(CnMn + "_Helper"));
            helperModule.appendChild(helperClass);

            // helpers section
            global.appendChild(helpers);
        }

        if (moduleConf->getHasModel()) {            
            // block module
            QDomElement modelModule = document.createElement(moduleConf->getModuleName().toLower());
            models.appendChild(modelModule);

            // class
            QDomElement modelClass = document.createElement("class");            
            modelClass.appendChild(document.createTextNode(CnMn + "_Model"));
            modelModule.appendChild(modelClass);

            // models section
            global.appendChild(models);
        }

        // apply selected rewrites
        for (int i = 0; i < rewrites.size(); i++) {

            hasGlobal = true;

            Rewrite r = rewrites.at(i);

            if (r.getType() == "Block") {
                applyRewrite(r, blocks);
            }

            if (r.getType() == "Helper") {
                applyRewrite(r, helpers);
            }

            if (r.getType() == "Model") {
                applyRewrite(r, models);
            }

            r.createFile();
        }



        //////////////////// EVENTS ///////////////////
        // apply selected events
        QDomElement globalEvents = document.createElement("events");
        QDomElement frontendEvents = document.createElement("events");
        QDomElement adminEvents = document.createElement("events");
        for (int i = 0; i < events.size(); i++) {

            Event e = events.at(i);

            if (e.getArea() == "global") {
                hasGlobal = true;
                applyEvent(e, globalEvents);
            }

            if (e.getArea() == "frontend") {
                hasFrontend = true;
                applyEvent(e, frontendEvents);
            }

            if (e.getArea() == "admin") {
                hasAdmin = true;
                applyEvent(e, adminEvents);
            }

            e.createFile();
        }

        if (globalEvents.childNodes().size() > 0) {
            global.appendChild(globalEvents);
        }

        if (frontendEvents.childNodes().size() > 0) {
            frontend.appendChild(frontendEvents);
        }

        if (adminEvents.childNodes().size() > 0) {
            admin.appendChild(adminEvents);
        }
        //////////////////// EVENTS END ///////////////////



        if (moduleConf->getHasScript()) {

            hasGlobal = true;

            // resources section
            QDomElement resourcesElem = document.createElement("resources");            

            // resources setup module
            QDomElement moduleToSetup = document.createElement(moduleConf->getSetupDirName());
            resourcesElem.appendChild(moduleToSetup);

            // setup section
            QDomElement setupElem = document.createElement("setup");
            moduleToSetup.appendChild(setupElem);

            QDomElement moduleElem = document.createElement("module");
            moduleElem.appendChild(document.createTextNode(CnMn));

            setupElem.appendChild(moduleElem);

            global.appendChild(resourcesElem);
        }        


    }

    if (moduleConf->getHasController() ||
            moduleConf->getHasAdminController()
        )
    {                       
        // frontend router
        if (moduleConf->getHasController()) {

            hasFrontend = true;

            // routers
            QDomElement routers = document.createElement("routers");

            // router module
            QDomElement routerModule1 = document.createElement(
                        moduleConf->getModuleName().toLower()
                    );            

            QDomElement use = document.createElement("use");
            use.appendChild(document.createTextNode("standard"));

            routerModule1.appendChild(use);

            routerModule1.appendChild(createRouterArgs(document));
            routers.appendChild(routerModule1);
            frontend.appendChild(routers);            
        }

        // admin router
        if (moduleConf->getHasAdminController()) {                   

            hasAdmin = true;

            // routers
            QDomElement routers = document.createElement("routers");                        

            // router module
            QDomElement routerModule2 = document.createElement(
                        moduleConf->getModuleName().toLower()
                    );            

            QDomElement use = document.createElement("use");                       
            use.appendChild(document.createTextNode("admin"));

            routerModule2.appendChild(use);          

            routerModule2.appendChild(createRouterArgs(document));
            routers.appendChild(routerModule2);
            admin.appendChild(routers);

        }
    }


    // add sections and write to file
    if (hasGlobal) {
        config.appendChild(global);
    }

    if (hasFrontend) {
        config.appendChild(frontend);
    }

    if (hasAdmin) {
        config.appendChild(admin);
    }

    return writeXML(getConfigFilePath(), document);
}
コード例 #27
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::rawCharacters(const XMLString& str)
{
	if (_unclosedStartTag) closeStartTag();
	_contentWritten = _contentWritten || !str.empty();
	writeXML(str);
}