Beispiel #1
0
/*----------------------------------------------------------------------------*/
std::string StrToken::intToString( int entero )
{

    std::stringstream cadena(""); 
    cadena << entero;
    return cadena.str();
}
Beispiel #2
0
QString SafetVariable::createXMLFileFromQuery(const QSqlQuery& query, const QString& outputFileName ) const {
	
	QString result; 

	Q_ASSERT_X(!outputFileName.isEmpty(), 
			"SafetDocument::createXMLFileFromSQL()", 
			qPrintable(QObject::tr("outputFileName vacio")));
	
	if (outputFileName.isEmpty()){
		qDebug("cadena outputFileName vacia");
		return result;
    	}
	

	QFile file;
	bool open;
	QTextStream out;
	bool istext = outputFileName.compare("::text", Qt::CaseInsensitive) == 0;
	if ( !istext ) {	
		file.setFileName(outputFileName);
		open = file.open(QIODevice::WriteOnly | QIODevice::Text); 
	Q_ASSERT_X(open, 
			"SafetDocument::createXMLFileFromSQL()",
			qPrintable(QObject::tr("No se pudo crear el archivo XML correspondiente a la sentencia SQL.")));
		out.setDevice(&file);
	}
	else {
		out.setString(&result);		
	}
	
	
	
	QSqlRecord rec;
	rec = query.record();
	
	out << "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" << "\n";
	out << "<libsafetdb>" << "\n";
	
	QString cadena("");
	    	//qDebug("<: %s", qPrintable(x.setNum(j+1)), ">");
//		    qDebug("\t<Document>");
	   		
		out << "<Document>" << "\n" ;
	   	for (int i= 0; i< rec.count(); i++){
	   		//qDebug(qPrintable(rec.fieldName(i)));
	   		//qDebug(qPrintable(query.value(i).toString()));	
	   		cadena.append("<");
	   		cadena.append(rec.fieldName(i));
	   		cadena.append(">");
	   		cadena.append(query.value(i).toString());
	   		cadena.append("</");
	   		cadena.append(rec.fieldName(i));
	   		cadena.append(">");
	   		  	
//	   		qDebug(qPrintable(cadena));
	   		  	
	   		out << cadena << "\n" ;  	
	   		cadena.clear();
	   	}
//	    qDebug("</Document>");
	    
	out << "</Document>" << "\n" << "</libsafetdb>" << "\n";
	return result;
}