BasesParserSLan/Src/DOM/DomPointer.mqh

89 lines
2.9 KiB
MQL5

2026-10-05 17:54:12 -05:00
//+------------------------------------------------------------------+
//| DomPointer.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com"
#property strict
#ifndef BASESPARSERSLAN_SRC_DOM_DOM_POINTER_MQH
#define BASESPARSERSLAN_SRC_DOM_DOM_POINTER_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\ExtraDef\\Pointer\\Cpiler.mqh"
#include "DomImp.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2026-10-05 21:57:35 -05:00
#define BSFLNODEDOM_POINTERSET(ERR, IDX) \
query.m_last_err = ERR; \
query.m_i = IDX;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CDomNodeBase* CDomNodeBase::operator[](BSFLPointerQuery& query)
2026-10-05 17:54:12 -05:00
{
//---
if(((1 << m_type) & (TSN_SBL_BASE_F_ARR | TSN_SBL_BASE_F_OBJ)) == 0)
{
2026-10-05 21:57:35 -05:00
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_INVALID_NODE_TYPE, 0)
2026-10-05 17:54:12 -05:00
return NULL;
}
//---
2026-10-05 21:57:35 -05:00
if(query.m_size == 0)
2026-10-05 17:54:12 -05:00
return &this;
//---
CDomNodeBase* curr = &this;
//---
2026-10-05 21:57:35 -05:00
for(int i = 0; i < query.m_size; i += 2)
2026-10-05 17:54:12 -05:00
{
if(curr.m_type == TSN_SBL_BASE_TYPE_OBJ)
{
2026-10-05 21:57:35 -05:00
const ulong khash = query.m_ins[i + BSFLPTR_I_KEY];
2026-10-05 17:54:12 -05:00
CHashMapFast(string, CDomNodeBase*)* hs = curr.HashMap();
if(!hs.ContainsKeyByHash(khash))
{
2026-10-05 21:57:35 -05:00
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_KEY_NOT_EXIST, i)
2026-10-05 17:54:12 -05:00
return NULL;
}
curr = hs.m_table[hs.m_last_pos_tbl].value;
}
else
if(curr.m_type == TSN_SBL_BASE_TYPE_ARR)
{
2026-10-05 21:57:35 -05:00
const int index = (int)query.m_ins[i + BSFLPTR_I_NUMBER];
2026-10-05 17:54:12 -05:00
if(!curr.InRange(index))
{
2026-10-05 21:57:35 -05:00
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_ARRAY_OUT_RANGE, i)
2026-10-05 17:54:12 -05:00
return NULL;
}
curr = curr.At(index);
}
else
{
2026-10-05 21:57:35 -05:00
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_INVALID_NODE_TYPE, i)
2026-10-05 17:54:12 -05:00
return NULL;
}
}
//---
return curr;
}
//---
}
#endif // BASESPARSERSLAN_SRC_DOM_DOM_POINTER_MQH
//+------------------------------------------------------------------+