commit de acabar la jornada laboral
This commit is contained in:
107
source/param.cpp
107
source/param.cpp
@@ -65,109 +65,6 @@ void initParam()
|
||||
param.notification.color.b = 48;
|
||||
}
|
||||
|
||||
// Establece valores para los parametros a partir de un fichero de texto
|
||||
/*void loadParamsFromFile(std::string file_path)
|
||||
{
|
||||
// Pone valores por defecto a las variables
|
||||
initParam();
|
||||
|
||||
// Variables para manejar el fichero
|
||||
std::ifstream file(file_path);
|
||||
std::string line;
|
||||
std::string param1;
|
||||
std::string param2;
|
||||
|
||||
// Si el fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::cout << "Reading file: " << file_name << std::endl;
|
||||
#endif
|
||||
// Procesa cada linea del fichero
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Reinicia variables
|
||||
param1.clear();
|
||||
param2.clear();
|
||||
|
||||
// Elimina los comentarios al final de una linea
|
||||
{
|
||||
// line = line.substr(0, line.find("#"));
|
||||
auto pos = line.find("#");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
line.resize(pos);
|
||||
}
|
||||
}
|
||||
|
||||
// Ignora los espacios en blanco
|
||||
int pos = 0;
|
||||
while (pos < (int)line.size() && (int)line[pos] <= 32)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
|
||||
// Si no ha llegado al final de la linea, es que hay algo escrito (no es una linea vacía)
|
||||
if (pos < (int)line.size())
|
||||
{
|
||||
// Elimina el espacio en blanco
|
||||
line = line.substr(pos, std::string::npos);
|
||||
|
||||
// Se queda con todo lo que no sean espacios en blanco
|
||||
pos = 1;
|
||||
while (pos <= (int)line.size() && (int)line[pos] > 32)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
|
||||
// Si llega al final de la linea, falta la segunda palabra
|
||||
if (pos < (int)line.size())
|
||||
{
|
||||
// Se queda con la primera palabra
|
||||
param1 = line.substr(0, pos);
|
||||
|
||||
// Y recorta la linea
|
||||
line = line.substr(pos, std::string::npos);
|
||||
|
||||
// Ignora los espacios en blanco
|
||||
pos = 0;
|
||||
while (pos <= (int)line.size() && (int)line[pos] <= 32)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
|
||||
// Si llega al final de la linea, falta la segunda palabra
|
||||
if (pos < (int)line.size())
|
||||
{
|
||||
// Elimina el espacio en blanco
|
||||
line = line.substr(pos, std::string::npos);
|
||||
|
||||
// Ignora los espacios en blanco
|
||||
pos = 1;
|
||||
while (pos <= (int)line.size() && (int)line[pos] > 32)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
// Se queda con la segunda palabra
|
||||
param2 = line.substr(0, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setParams(param1, param2);
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
file.close();
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
else
|
||||
std::cout << "Failed to load file: " << file_path << std::endl;
|
||||
#endif
|
||||
|
||||
precalculateZones();
|
||||
}*/
|
||||
void loadParamsFromFile(const std::string &file_path)
|
||||
{
|
||||
// Inicializa los parámetros con valores por defecto
|
||||
@@ -177,16 +74,12 @@ void loadParamsFromFile(const std::string &file_path)
|
||||
std::ifstream file(file_path);
|
||||
if (!file.is_open())
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
std::cerr << "Error: No se pudo abrir el archivo " << file_path << std::endl;
|
||||
#endif
|
||||
throw std::runtime_error("No se pudo abrir el archivo: " + file_path);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::cout << "Reading file: " << file_name << std::endl;
|
||||
#endif
|
||||
|
||||
std::string line, param1, param2;
|
||||
while (std::getline(file, line))
|
||||
|
||||
Reference in New Issue
Block a user