69 lines
2.3 KiB
MQL5
69 lines
2.3 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| BasicTest.mq5 |
|
|
//| 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 version "1.00"
|
|
#property strict
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "..\\Src\\YmlNode.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Expert initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
//---
|
|
CYmlParser parser;
|
|
|
|
string yml = "nombre: [.nan, 21, 30]\n"
|
|
"edad: 30\n"
|
|
"activo: true\n"
|
|
"saldo: {valor: 10, clave: 10}\n";
|
|
|
|
if(!parser.Parse(yml))
|
|
{
|
|
Print("Error parse: ", EnumToString(parser.LastErr()));
|
|
return INIT_FAILED;
|
|
}
|
|
|
|
CYmlNode root = parser.GetRoot();
|
|
// ArrayPrint(parser.m_cinta, 2, " | ", 0, parser.m_cinta_pos);
|
|
|
|
Print("nombre = ", root["nombre"].AtHomegeneo(2).ToDouble(0.00));
|
|
Print("edad = ", root["edad"].ToInt(0));
|
|
Print("activo = ", root["activo"].ToBool(false));
|
|
|
|
CYmlNode node = root["saldo"];
|
|
CYmlIteratorObj it = node.BeginObj();
|
|
while(it.IsValid())
|
|
{
|
|
Print(it.Key(), " = ", it.Val().ToInt(0));
|
|
it.Next();
|
|
}
|
|
// parser.PrintCintaTypes();
|
|
//---
|
|
return(INIT_FAILED);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert deinitialization function |
|
|
//+------------------------------------------------------------------+
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//---
|
|
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert tick function |
|
|
//+------------------------------------------------------------------+
|
|
void OnTick()
|
|
{
|
|
//---
|
|
|
|
}
|
|
//+------------------------------------------------------------------+
|