2026-02-18 17:36:44 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Saver.mqh |
|
|
|
|
|
//| Copyright 2025, Niquel Mendoza. |
|
|
|
|
|
//| https://www.mql5.com/es/users/nique_372 |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#property copyright "Copyright 2025, Niquel Mendoza."
|
|
|
|
|
#property link "https://www.mql5.com/es/users/nique_372"
|
|
|
|
|
#property strict
|
|
|
|
|
|
|
|
|
|
#ifndef AIDATAGENBYLEO_GENERIC_DATA_BASE_SAVER_MQH
|
|
|
|
|
#define AIDATAGENBYLEO_GENERIC_DATA_BASE_SAVER_MQH
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Include |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#include "..\\Parser\\Parser.mqh"
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
class CAiLeoMulyiFeatureGenSaver : public CLoggerBase
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
string m_name;
|
|
|
|
|
string m_src;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CAiLeoMulyiFeatureGenSaver(void) {}
|
|
|
|
|
~CAiLeoMulyiFeatureGenSaver(void) {}
|
|
|
|
|
|
|
|
|
|
//--- Getters y Setters
|
|
|
|
|
// Src
|
|
|
|
|
void Src(const string& src) { m_src = src; }
|
|
|
|
|
__forceinline string Src() const { return m_src; }
|
|
|
|
|
|
|
|
|
|
// Name
|
|
|
|
|
void Name(const string& name) { m_name = name; }
|
|
|
|
|
__forceinline string Name() const { return m_src; }
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
void Clean();
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
bool Load(const string& file_name, bool comon);
|
|
|
|
|
bool Save(const string& file_name, bool comon);
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
void Summary() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
bool CAiLeoMulyiFeatureGenSaver::Save(const string &file_name, bool comon)
|
|
|
|
|
{
|
|
|
|
|
//---
|
|
|
|
|
ResetLastError();
|
|
|
|
|
const int fh = FileOpen(file_name, FILE_WRITE | FILE_TXT | (comon ? FILE_COMMON : 0));
|
|
|
|
|
if(fh == INVALID_HANDLE)
|
|
|
|
|
{
|
|
|
|
|
LogError(StringFormat("Fallo al abrir el archivo = %s, ultimo error =%d", file_name, GetLastError()), FUNCION_ACTUAL);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
FileWrite(fh, m_name);
|
|
|
|
|
FileWriteString(fh, m_src);
|
|
|
|
|
FileClose(fh);
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
bool CAiLeoMulyiFeatureGenSaver::Load(const string &file_name, bool comon)
|
|
|
|
|
{
|
|
|
|
|
//---
|
|
|
|
|
ResetLastError();
|
|
|
|
|
const int fh = FileOpen(file_name, FILE_READ | FILE_TXT | (comon ? FILE_COMMON : 0));
|
|
|
|
|
if(fh == INVALID_HANDLE)
|
|
|
|
|
{
|
|
|
|
|
LogError(StringFormat("Fallo al abrir el archivo = %s, ultimo error =%d", file_name, GetLastError()), FUNCION_ACTUAL);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--- Extraemos el nombre
|
|
|
|
|
m_name = FileReadString(fh); // Nombre
|
|
|
|
|
int start = m_name.Find("[", 0);
|
|
|
|
|
if(start == -1)
|
|
|
|
|
{
|
|
|
|
|
LogError("En el archivo la primera linea debe de contener el nombre del geneador entre []", FUNCION_ACTUAL);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int end = m_name.Find("]", (++start));
|
|
|
|
|
if(end == -1)
|
|
|
|
|
{
|
|
|
|
|
LogError("En el archivo la primera linea debe de contener el nombre del geneador entre []", FUNCION_ACTUAL);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
end--; // Excluimos el ]
|
|
|
|
|
m_name = StringSubstrRange(m_name, start, end);
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
m_src = "";
|
|
|
|
|
while(!FileIsEnding(fh))
|
|
|
|
|
{
|
|
|
|
|
m_src += FileReadString(fh) + "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
FileClose(fh);
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void CAiLeoMulyiFeatureGenSaver::Clean(void)
|
|
|
|
|
{
|
|
|
|
|
m_src = NULL;
|
|
|
|
|
m_name = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void CAiLeoMulyiFeatureGenSaver::Summary(void) const
|
|
|
|
|
{
|
|
|
|
|
PrintFormat("---| AiData: %s", m_name);
|
|
|
|
|
Print(m_src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#endif // AIDATAGENBYLEO_GENERIC_DATA_BASE_SAVER_MQH
|
|
|
|
|
//+------------------------------------------------------------------+
|