void GitCode::cargarFichero(string mfileFichero) { string rutaFichero(mfileFichero); string lineaActual; std::ifstream inputStream; inputStream.exceptions(std::ifstream::failbit | std::ifstream::badbit); inputStream.open(rutaFichero); //Extraemos la cabecera del fichero inputStream >> lineaActual; while (!inputStream.eof()) { inputStream >> lineaActual; //Parseamos la línea auto pos = lineaActual.find(';'); auto ruta = lineaActual.substr(0, pos); auto tama = lineaActual.substr(pos + 1, lineaActual.length()); //Separamos la ubicación del nombre del fichero pos = ruta.find_last_of('/'); auto ubicacion = ruta.substr(0, pos + 1); auto nombre = ruta.substr(pos + 1, ruta.length()); //Convertimos el string en un int int tamaB = std::stoi(tama); Fichero fichero(nombre, ubicacion, tamaB); ficheros.push_back(fichero); } inputStream.close(); }
int main(){ typedef lmx::Matrix<double> dMatrix; typedef lmx::Vector<double> dVector; lmx::setMatrixType(0); lmx::setLinSolverType(0); lmx::Matrix<double> A(4,4); // igual a dMatrix A(4,4); dMatrix B( A.rows(), A.cols() ); dVector v(4); A.fillRandom(10.); B.fillIdentity(); v.fillIdentity(); dMatrix C( A ); cout << A*B*C << endl ; cout << A+B-C << endl ; cout << A*v << endl ; dVector x(4); lmx::solveLinear(A,x,v); cout << "Solution: " << endl << x << endl; std::ofstream fichero("matrix.tex"); lmx::latexPrint(fichero, "mat", A, 3); return 1; }
void __fastcall TForm1::Guardar1Click(TObject *Sender) { if (archivo=="") {ShowMessage("No hay ruta para guardar");} else { ofstream fichero(archivo.c_str(),ios::out | ios::binary | ios::beg ); dibujo->salvardibujo(fichero); fichero.close();} }
void __fastcall TForm1::GuardarComo1Click(TObject *Sender) { if(SaveDialog1->Execute()){ archivo = SaveDialog1->FileName.c_str(); ofstream fichero(archivo.c_str(),ios::out | ios::binary | ios::beg ); dibujo->salvardibujo(fichero); fichero.close(); } }
void __fastcall TForm1::Abrir1Click(TObject *Sender) { if (OpenDialog1->Execute()){ archivo=OpenDialog1->FileName.c_str(); ifstream fichero(archivo.c_str(),ios::out | ios::binary | ios::beg ); dibujo->cargardibujo(fichero); fichero.close(); Repaint(); } }
void __fastcall TForm1::Cargar2Click(TObject *Sender) { if (OpenDialog1->Execute()){ gFiltro=OpenDialog1->FileName; ifstream fichero(gFiltro.c_str(),ios::out | ios::binary | ios::beg ); int i=0; fichero >> i; string pal; for(int j=0;j<i;j++) { fichero >> pal; AnsiString aux=pal.c_str(); aux=aux.LowerCase(); Filtro->insertar(aux); } fichero.close(); }
void InkjetInformer::LeerArchivoActual(){ NombreRutaArchivoActual=QString("%1\\%2_%3de%4.txt") .arg(ruta) .arg(nombreBase) .arg(archivoActual) .arg(numeroArchivos); QFile fichero(NombreRutaArchivoActual); if (!fichero.exists()){ //Si no existe, hay que crearlo fichero.open(QIODevice::ReadWrite | QIODevice::Text); } if (!fichero.open(QIODevice::ReadWrite | QIODevice::Text)){ //Si no se puede abrir, nos salimos return; } QTextStream stream(&fichero); QString lectura = stream.readLine(10); QDate fechaleida=QDate::fromString(lectura,"dd/MM/yyyy"); qDebug() << "Valores leidos" << lectura; QDate hoy=QDate::currentDate(); QString hoy_s=hoy.toString("dd/MM/yyyy"); QDate hoy_f=QDate::fromString(hoy_s,"dd/MM/yyyy"); if (hoy_f==fechaleida){ // Continuamos insertando informacion qDebug() << "Hoy es: " << hoy_f; fichero.close(); } else{ // Hay que borrar el fichero, es de un dia anterior fichero.close(); fichero.remove(); QFile ficheronuevo(NombreRutaArchivoActual); ficheronuevo.open(QIODevice::ReadWrite | QIODevice::Text); ficheronuevo.close(); } }
void __fastcall TForm1::N1Click(TObject *Sender) { if (gFiltro=="") {ShowMessage("No hay ruta para guardar");} else { ofstream fichero(gFiltro.c_str(),ios::out | ios::binary | ios::beg ); int i=0; Filtro->DameNumElem(i); AnsiString s=""; Filtro->ABOtoString(s); fichero << i << endl; int j=0; int l=s.Length(); int cont=0; bool flag=true; AnsiString pal=""; while(j<=l || flag==true) { LeerBlancos(s,j); LeerPalabra(s,j,pal); if(pal!=""){cont++; fichero << pal.c_str() << endl;} if (cont==i)flag=false; } fichero.close(); } }
void InkjetInformer::SaveLogToFile(){ if (contador_signal==0x00){ contador_tiempo=0; return; } QString temp; QFile fichero(NombreRutaArchivoActual); fichero.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Append); QTextStream stream(&fichero); for (int i=0;i<contador_signal;i++){ temp=m_stInformer.TablaInformer[i]; stream << temp << "\n"; } fichero.close(); contador_signal=0; contador_tiempo=0; }
void __fastcall TForm1::GuardarComo2Click(TObject *Sender) { if(SaveDialog1->Execute()){ gFiltro=SaveDialog1->FileName; ofstream fichero(gFiltro.c_str(),ios::out | ios::binary | ios::beg ); int i=0; Filtro->DameNumElem(i); AnsiString s=""; Filtro->ABOtoString(s); fichero << i << endl; int j=0; int l=s.Length(); int cont=0; bool flag=true; AnsiString pal=""; while(j<=l || flag==true) { LeerBlancos(s,j); LeerPalabra(s,j,pal); if(pal!=""){cont++; fichero << pal.c_str() << endl;} if (cont==i)flag=false; } fichero.close(); } }