diff --git a/include/configFile.hpp b/include/configFile.hpp index 7fe563c..d4ef44d 100644 --- a/include/configFile.hpp +++ b/include/configFile.hpp @@ -1,6 +1,7 @@ #include "config.hpp" #include #include +#include #ifndef __CONFIG_FILE_HPP_ #define __CONFIG_FILE_HPP_ namespace cf { @@ -9,5 +10,6 @@ namespace cf { void closeConfig(Config *config); std::string getLine(std::ifstream *file); void saveConfig(Config *config); + void escribirText(std::ofstream *file, std::string *text, int numSpcs); } // namespace cf #endif // __CONFIG_FILE_HPP_ diff --git a/include/idiomas/en.hpp b/include/idiomas/en.hpp index 0dd2042..0c03705 100644 --- a/include/idiomas/en.hpp +++ b/include/idiomas/en.hpp @@ -22,6 +22,8 @@ namespace en{ const extern std::string confTiempoInput = "- Execution time\t> "; const extern std::string confHilosError = "Must introduce a number"; const extern std::string confTiempoError = "The time format must be HH:mm:ss"; + const extern std::string confArchText_1 = "Autogenerated file by Stress_UI"; + const extern std::string confArchText_2 = "Do not edit manually without knowing what you do"; } #endif // __EN_HPP_ diff --git a/include/idiomas/es.hpp b/include/idiomas/es.hpp index 5e6c17f..c046099 100644 --- a/include/idiomas/es.hpp +++ b/include/idiomas/es.hpp @@ -22,6 +22,8 @@ namespace es{ const extern std::string confTiempoInput = "- Tiempo de ejecución\t> "; const extern std::string confHilosError = "Se debe introducir un número"; const extern std::string confTiempoError = "El formato del tiempo debe ser HH:mm:ss"; + const extern std::string confArchText_1 = "Archivo autogenerado por Stress_UI"; + const extern std::string confArchText_2 = "No editar manualmente sin saber lo que se hace"; } #endif // __ES_HPP_ diff --git a/include/idiomas/gl.hpp b/include/idiomas/gl.hpp index 726d6b6..62c627b 100644 --- a/include/idiomas/gl.hpp +++ b/include/idiomas/gl.hpp @@ -22,6 +22,8 @@ namespace gl{ const extern std::string confTiempoInput = "- Tempo de execución\t> "; const extern std::string confHilosError = "Debese introducir un número"; const extern std::string confTiempoError = "O formato do tempo debe ser HH:mm:ss"; + const extern std::string confArchText_1 = "Archivo autoxenerado por Stress_UI"; + const extern std::string confArchText_2 = "Non editar manualmente sin saber o que se fai"; } #endif // __GL_HPP_ diff --git a/include/textos.hpp b/include/textos.hpp index a20ce02..fad9aba 100644 --- a/include/textos.hpp +++ b/include/textos.hpp @@ -22,6 +22,8 @@ namespace txt{ extern std::string g_confTiempoInput; extern std::string g_confHilosError; extern std::string g_confTiempoError; + extern std::string g_confArchText_1; + extern std::string g_confArchText_2; void inicializarIdioma(std::string idioma); } diff --git a/src/configFile.cpp b/src/configFile.cpp index 53c6d92..613e040 100644 --- a/src/configFile.cpp +++ b/src/configFile.cpp @@ -1,5 +1,5 @@ #include "configFile.hpp" -#include +#include "textos.hpp" Config cf::openConfig() { std::ifstream file; @@ -48,7 +48,8 @@ std::string cf::getLine(std::ifstream *file) { void cf::saveConfig(Config *config) { std::ofstream file(g_configFile); - file << "#######################################################################" << std::endl; + std::string header = "#######################################################################"; + file << header << std::endl; file << "# + + + + #" << std::endl; file << "# + + + #" << std::endl; file << "# + + #" << std::endl; @@ -64,12 +65,40 @@ void cf::saveConfig(Config *config) { file << "# | | | | | : . | ; ; | #" << std::endl; file << "# : : . . . : #" << std::endl; file << "# #" << std::endl; - file << "# Archivo autogenerado por Stress_UI #" << std::endl; - file << "# No editar manualmente sin saber lo que se hace #" << std::endl; - file << "#######################################################################" << std::endl; + + cf::escribirText(&file, &txt::g_confArchText_1, header.length()); + + cf::escribirText(&file, &txt::g_confArchText_2, header.length()); + + file << header << std::endl; file << std::endl; - file << "Número de hilos\t\t= " << std::to_string(config->getNumHilos()); + file << txt::g_confHilosInput.substr(2,txt::g_confHilosInput.find("\t>") - 2) << "\t\t= " << std::to_string(config->getNumHilos()); file << std::endl; - file << "Tiempo de ejecución\t= " << config->getTiempo(); + file << txt::g_confTiempoInput.substr(2,txt::g_confTiempoInput.find("\t>") - 2) << "\t= " << config->getTiempo(); file.close(); } + +void cf::escribirText(std::ofstream *file, std::string *text, int numSpcs){ + *file << "# " << *text; + + for (int i = text->length() + 3; i < numSpcs; i++){ + *file << " "; + } + for (int i = 0; i < text->length(); i++) { + if (text->substr(i, 2).compare("á") == 0 | + text->substr(i, 2).compare("é") == 0 | + text->substr(i, 2).compare("í") == 0 | + text->substr(i, 2).compare("ó") == 0 | + text->substr(i, 2).compare("ú") == 0 | + text->substr(i, 2).compare("Á") == 0 | + text->substr(i, 2).compare("É") == 0 | + text->substr(i, 2).compare("Ó") == 0 | + text->substr(i, 2).compare("Ú") == 0 | + text->substr(i, 2).compare("ñ") == 0 | + text->substr(i, 2).compare("Ñ") == 0) { + + *file << " "; + } + } + *file << "#" << std::endl; +} diff --git a/src/textos.cpp b/src/textos.cpp index 0cac74b..e429522 100644 --- a/src/textos.cpp +++ b/src/textos.cpp @@ -22,6 +22,8 @@ std::string txt::g_confHilosInput = ""; std::string txt::g_confTiempoInput = ""; std::string txt::g_confHilosError = ""; std::string txt::g_confTiempoError = ""; +std::string txt::g_confArchText_1 = ""; +std::string txt::g_confArchText_2 = ""; void txt::inicializarIdioma(std::string idioma){ idioma = idioma.substr(0, idioma.find("_")); @@ -47,6 +49,8 @@ void txt::inicializarIdioma(std::string idioma){ txt::g_confTiempoInput = confTiempoInput; txt::g_confHilosError = confHilosError; txt::g_confTiempoError = confTiempoError; + txt::g_confArchText_1 = confArchText_1; + txt::g_confArchText_2 = confArchText_2; }else if(idioma == "es"){ using namespace es; txt::g_noColor = noColor; @@ -68,6 +72,8 @@ void txt::inicializarIdioma(std::string idioma){ txt::g_confTiempoInput = confTiempoInput; txt::g_confHilosError = confHilosError; txt::g_confTiempoError = confTiempoError; + txt::g_confArchText_1 = confArchText_1; + txt::g_confArchText_2 = confArchText_2; }else if(idioma == "en"){ using namespace en; txt::g_noColor = noColor; @@ -89,6 +95,8 @@ void txt::inicializarIdioma(std::string idioma){ txt::g_confTiempoInput = confTiempoInput; txt::g_confHilosError = confHilosError; txt::g_confTiempoError = confTiempoError; + txt::g_confArchText_1 = confArchText_1; + txt::g_confArchText_2 = confArchText_2; }else{ using namespace en; txt::g_noColor = noColor; @@ -110,6 +118,8 @@ void txt::inicializarIdioma(std::string idioma){ txt::g_confTiempoInput = confTiempoInput; txt::g_confHilosError = confHilosError; txt::g_confTiempoError = confTiempoError; + txt::g_confArchText_1 = confArchText_1; + txt::g_confArchText_2 = confArchText_2; } }