2026-06-28 16:15:30 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Recolect.mqh |
|
| | | //| Copyright 2026, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/ |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2026, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/"
|
| | | #property strict
|
| | |
|
| | | #ifndef MQLARTICLES_ENUMSTR_GENERATE_RECOLECT_MQH
|
| | | #define MQLARTICLES_ENUMSTR_GENERATE_RECOLECT_MQH
|
| | |
|
| | | #ifndef RECOLECT_MAX_SIZE
|
| | | #define RECOLECT_MAX_SIZE (1024)
|
| | | #endif // RECOLECT_MAX_SIZE
|
| | |
|
2026-07-03 16:05:29 -05:00 | | | #ifndef MQLARTICLES_RECOLECT_V
|
| | | #define MQLARTICLES_RECOLECT_V int
|
| | | #endif // MQLARTICLES_RECOLECT_V
|
| | |
|
| | |
|
2026-06-28 16:15:30 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class CRecolect
|
| | | {
|
| | | public:
|
| | | CRecolect(void) {}
|
| | | ~CRecolect(void) {}
|
| | | //---
|
2026-07-03 16:05:29 -05:00 | | | static MQLARTICLES_RECOLECT_V s_arr_v[RECOLECT_MAX_SIZE];
|
2026-06-28 16:15:30 -05:00 | | | static string s_arr_s[RECOLECT_MAX_SIZE];
|
| | | static int s_arr_size;
|
| | |
|
| | | //---
|
2026-07-03 16:05:29 -05:00 | | | static bool Add(const string& vs, const MQLARTICLES_RECOLECT_V vi)
|
2026-06-28 16:15:30 -05:00 | | | {
|
| | | s_arr_v[s_arr_size] = vi;
|
| | | s_arr_s[s_arr_size++] = vs;
|
| | | return true;
|
| | | }
|
| | |
|
| | | static bool Save(const string& file_name, bool comon)
|
| | | {
|
| | | ::ResetLastError();
|
| | | const int fh = FileOpen(file_name, FILE_ANSI | FILE_TXT | FILE_WRITE | (comon ? FILE_COMMON : 0));
|
| | | if(fh == INVALID_HANDLE)
|
| | | {
|
| | | PrintFormat("Fallo al cargar el archivo = %s, ultimo err = %d", file_name, ::GetLastError());
|
| | | return false;
|
| | | }
|
| | |
|
| | | //---
|
2026-06-28 17:04:49 -05:00 | | | FileWrite(fh, "map: {");
|
2026-06-28 16:15:30 -05:00 | | | const int last = s_arr_size - 1;
|
| | | for(int i = 0; i < last; i++)
|
| | | {
|
2026-07-03 16:05:29 -05:00 | | | const string str = " " + s_arr_s[i] + ": " + string(s_arr_v[i]) + ",";
|
| | | FileWrite(fh, str);
|
2026-06-28 16:15:30 -05:00 | | | }
|
2026-07-04 11:58:48 -05:00 | | | const string str = " " + s_arr_s[last] + ": " + string(s_arr_v[last]);
|
2026-07-03 16:05:29 -05:00 | | | FileWrite(fh, str);
|
2026-06-28 17:04:49 -05:00 | | | FileWrite(fh, "}");
|
2026-07-03 16:05:29 -05:00 | | |
|
2026-06-28 16:15:30 -05:00 | | | //---
|
| | | FileClose(fh);
|
| | | return true;
|
| | | }
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-03 16:05:29 -05:00 | | | MQLARTICLES_RECOLECT_V CRecolect::s_arr_v[RECOLECT_MAX_SIZE];
|
2026-06-28 16:15:30 -05:00 | | | string CRecolect::s_arr_s[RECOLECT_MAX_SIZE];
|
| | | int CRecolect::s_arr_size = 0;
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-06-28 17:04:49 -05:00 | | | #define MQLARTICLES_ENUMREC_REG(A) const bool g_asDA12_##A = CRecolect::Add(#A,int(A));
|
2026-06-28 16:15:30 -05:00 | | | // a = "user" | v = valor del enuym
|
| | |
|
| | | //---
|
| | | // A=string
|
| | | // V=valor
|
2026-06-28 17:04:49 -05:00 | | | #define MQLARTICLES_ENUMREC_REG_CTS(A, V) const bool g_asDA12_##V = CRecolect::Add(A,int(V));
|
2026-06-28 16:15:30 -05:00 | | |
|
| | | //---
|
| | | // prefixo custom
|
| | | // A=enum_v
|
| | | // P=prefijo
|
| | | // V=valor real
|
2026-06-28 17:04:49 -05:00 | | | #define MQLARTICLES_ENUMREC_REG_CTS_FULL(A, V, P) const bool g_asDA12_##P = CRecolect::Add(#A,int(V));
|
2026-06-28 16:15:30 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | #endif // MQLARTICLES_ENUMSTR_GENERATE_RECOLECT_MQH
|