generated from UF-IRI/qt_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/UF-IRI/entrega-final-tp-202…
- Loading branch information
Showing
5 changed files
with
116 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,159 +1,139 @@ | ||
#include "archivos.h" | ||
#include "libreria.h" | ||
|
||
int leerArchivoGen(ifstream &archivo, claseG* claseGen){ | ||
int i=0,fila=0; | ||
char delimiter = ','; | ||
int leerArchivoUsuario(ifstream &archivo, usuario *&usuarios, unsigned int &tamU) | ||
{ | ||
if(!archivo.is_open()) | ||
return -1; | ||
|
||
char delimiter= ','; | ||
int i=0; | ||
string line; | ||
string header; | ||
string elemento; | ||
stringstream iss; | ||
|
||
while (archivo.good()) { | ||
getline(archivo, line); | ||
istringstream iss(line); | ||
bool primeraColumna = true; | ||
if (fila == 0){ | ||
while (getline(iss, claseGen[i].nombreClaS, delimiter)) { | ||
if (primeraColumna) | ||
primeraColumna = false; // Si es la primera columna, no la guardamos | ||
else | ||
i++; | ||
} | ||
} | ||
if (fila == 2){ | ||
while (getline(iss, elemento, delimiter)) { | ||
if (primeraColumna) { | ||
primeraColumna = false; // Si es la primera columna, no la guardamos | ||
} else { | ||
for(int aux=0; aux<9; aux++){ | ||
claseGen[i].Turnos[aux].cupoMax = stoi(elemento); | ||
} | ||
i++; | ||
} | ||
} | ||
} | ||
if (fila >= 4){ | ||
while (getline(iss, elemento, delimiter)) { | ||
if (primeraColumna) { | ||
primeraColumna = false; // Si es la primera columna, no la guardamos | ||
} else { | ||
if(elemento == "X") | ||
claseGen[i].Turnos[fila-4].horario = 1; | ||
else{ | ||
claseGen[i].Turnos[fila-4].horario = 0; | ||
} | ||
i++; | ||
} | ||
getline(archivo, header); | ||
|
||
} | ||
} | ||
fila++; | ||
i = 0; // Reinicializar el contador i | ||
while(getline(archivo, line)){ // Agarra la cantinad de clientes | ||
tamU++; | ||
} | ||
archivo.clear(); | ||
archivo.seekg(0, std::ios::beg); // pone el puntero al principio | ||
|
||
usuarios = new usuario[tamU]; | ||
|
||
return 0; | ||
} | ||
|
||
|
||
int leerArchivoClases(ifstream &archivo, clase* &clases, unsigned int &tamC) | ||
{ | ||
char delimiter = ','; | ||
string line; | ||
|
||
stringstream iss; | ||
|
||
if(archivo.is_open()){ | ||
|
||
getline(archivo, line); | ||
getline(archivo, header); | ||
|
||
while(!archivo.eof() && getline(archivo, line)){ | ||
iss.clear(); | ||
iss<<line; | ||
while(!archivo.eof() && getline(archivo, line)) { | ||
iss.clear(); | ||
iss<<line; | ||
elemento.clear(); | ||
getline(iss,elemento,delimiter); | ||
usuarios[i].idCliente = stoi(elemento); | ||
getline(iss,usuarios[i].nombre,delimiter); | ||
getline(iss,usuarios[i].apellido,delimiter); | ||
getline(iss,usuarios[i].email,delimiter); | ||
getline(iss,usuarios[i].telefono,delimiter); | ||
getline(iss,usuarios[i].fechaNac,delimiter); | ||
elemento.clear(); | ||
getline(iss,elemento,delimiter); | ||
usuarios[i].estado = stoi(elemento); | ||
|
||
incrementarClases(clases, tamC); | ||
|
||
getline(iss, line, delimiter); | ||
clases[tamC-1].Turnos->idclas= stoi(line); | ||
getline(iss, line, delimiter); | ||
clases[tamC-1].nombreclas=line; | ||
getline(iss, line); | ||
clases[tamC-1].Turnos->horario=stof(line); | ||
} | ||
|
||
i++; | ||
} | ||
return 1; | ||
} | ||
|
||
void incrementarClases(clase* &clases, unsigned int &tam) | ||
int leerArchivoClases(ifstream &archivo, clase *&clases, unsigned int &tamC) | ||
{ | ||
if(clases==nullptr){ | ||
if(tam<=0){ | ||
clases = new clase[++tam]; | ||
} | ||
return; | ||
} | ||
|
||
clase* temporal = new clase[++tam]; | ||
if(!archivo.is_open()) | ||
return -1; | ||
|
||
for(unsigned int i = 0; i < tam-1; i++){ | ||
temporal[i] = clases[i]; | ||
} | ||
delete[] clases; | ||
clases = temporal; | ||
} | ||
|
||
int leerArchivoUsuario(ifstream &archivo, usuario* & usuarios, unsigned int &tamU) | ||
{ | ||
char delimiter= ','; | ||
int i=0; | ||
string line; | ||
string header; | ||
string elemento; | ||
stringstream iss; | ||
|
||
if(archivo.is_open()) | ||
{ | ||
getline(archivo, line); | ||
while(!archivo.eof() && getline(archivo, line)) | ||
{ | ||
iss.clear(); | ||
iss<<line; | ||
|
||
incrementarUsuarios(usuarios, tamU); | ||
|
||
getline(iss, line, delimiter); | ||
usuarios[tamU-1].idCliente= stoi(line); | ||
getline(iss, line, delimiter); | ||
usuarios[tamU-1].nombre =line; | ||
getline(iss, line,delimiter); | ||
usuarios[tamU-1].apellido=line; | ||
getline(iss,line,delimiter); | ||
usuarios[tamU-1].email=line; | ||
getline(iss,line,delimiter); | ||
usuarios[tamU-1].fechaNac=line; | ||
getline(iss,line); | ||
usuarios[tamU-1].estado=stoi(line); | ||
getline(archivo, header); | ||
|
||
} | ||
while(getline(archivo, line)){ // Agarra la cantinad de clientes | ||
tamC++; | ||
} | ||
|
||
archivo.clear(); | ||
archivo.seekg(0, std::ios::beg); // pone el puntero al principio | ||
|
||
clases = new clase[tamC]; | ||
getline(archivo, header); | ||
|
||
while(!archivo.eof() && getline(archivo, line)) { | ||
iss.clear(); | ||
iss<<line; | ||
getline(iss,elemento,delimiter); | ||
clases[i].idClas = stoi(elemento); | ||
getline(iss,clases[i].nombreClas,delimiter); | ||
getline(iss,elemento,delimiter); | ||
clases[i].horario = stof(elemento); | ||
i++; | ||
|
||
if(clases[i].idClas>0 && clases[i].idClas<6){ | ||
clases[i].cupoMax=45; | ||
clases[i].cupo=0; | ||
} | ||
else if(clases[i].idClas>5 && clases[i].idClas<12){ | ||
clases[i].cupoMax=25; | ||
clases[i].cupo=0; | ||
} | ||
else if(clases[i].idClas >11 && clases[i].idClas<18){ | ||
clases[i].cupoMax=15; | ||
clases[i].cupo=0; | ||
} | ||
else if(clases[i].idClas>17 && clases[i].idClas<24){ | ||
clases[i].cupoMax=40; | ||
clases[i].cupo=0; | ||
} | ||
else if(clases[i].idClas>23 && clases[i].idClas<30){ | ||
clases[i].cupoMax=50; | ||
clases[i].cupo=0; | ||
} | ||
else if(clases[i].idClas>29 && clases[i].idClas<34){ | ||
clases[i].cupoMax=30; | ||
clases[i].cupo=0; | ||
} | ||
else if(clases[i].idClas>33 && clases[i].idClas<61){ | ||
clases[i].cupoMax=30; | ||
clases[i].cupo=0; | ||
} | ||
} | ||
return 1; | ||
} | ||
void incrementarUsuarios(usuario *& usuarios, unsigned int &tam) | ||
{ | ||
if(usuarios==nullptr){ | ||
if(tam<=0){ | ||
usuarios = new usuario[++tam]; | ||
|
||
|
||
int EscribirArchivoBinario(ofstream &archivo, Asistencia *&asistClientes, unsigned int &cantAsistencias){ | ||
|
||
if (archivo.is_open()) { | ||
for (unsigned int i=0; i < cantAsistencias; i++) { | ||
archivo.write((char*)&asistClientes[i].idCliente, sizeof(unsigned int)); | ||
archivo.write((char*)&asistClientes[i].cantInscriptos, sizeof(unsigned int)); | ||
for(int j = 0; j < asistClientes[i].cantInscriptos; j++) { | ||
archivo.write((char*)&asistClientes[i].CursosInscriptos[j], sizeof(Inscripcion)); | ||
} | ||
return; | ||
} | ||
} | ||
|
||
usuario* pasajero = new usuario[++tam]; | ||
return 1; | ||
|
||
for(unsigned int i = 0; i < tam-1; i++){ | ||
pasajero[i] = usuarios[i]; | ||
} | ||
delete[] usuarios; | ||
usuarios = pasajero; | ||
|
||
return -1; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.