89 lines
2.9 KiB
MQL5
89 lines
2.9 KiB
MQL5
//+------------------------------------------------------------------+
| |
//| 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
| |
{
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#define BSFLNODEDOM_POINTERSET(ERR, IDX) \
| |
query.m_last_err = ERR; \
| |
query.m_i = IDX;
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
CDomNodeBase* CDomNodeBase::operator[](BSFLPointerQuery& query)
| |
{
| |
//---
| |
if(((1 << m_type) & (TSN_SBL_BASE_F_ARR | TSN_SBL_BASE_F_OBJ)) == 0)
| |
{
| |
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_INVALID_NODE_TYPE, 0)
| |
return NULL;
| |
}
| |
| |
//---
| |
if(query.m_size == 0)
| |
return &this;
| |
| |
//---
| |
CDomNodeBase* curr = &this;
| |
| |
//---
| |
for(int i = 0; i < query.m_size; i += 2)
| |
{
| |
if(curr.m_type == TSN_SBL_BASE_TYPE_OBJ)
| |
{
| |
const ulong khash = query.m_ins[i + BSFLPTR_I_KEY];
| |
CHashMapFast(string, CDomNodeBase*)* hs = curr.HashMap();
| |
if(!hs.ContainsKeyByHash(khash))
| |
{
| |
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_KEY_NOT_EXIST, i)
| |
return NULL;
| |
}
| |
curr = hs.m_table[hs.m_last_pos_tbl].value;
| |
}
| |
else
| |
if(curr.m_type == TSN_SBL_BASE_TYPE_ARR)
| |
{
| |
const int index = (int)query.m_ins[i + BSFLPTR_I_NUMBER];
| |
if(!curr.InRange(index))
| |
{
| |
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_ARRAY_OUT_RANGE, i)
| |
return NULL;
| |
}
| |
curr = curr.At(index);
| |
}
| |
else
| |
{
| |
BSFLNODEDOM_POINTERSET(BSFL_POINTER_ERR_INVALID_NODE_TYPE, i)
| |
return NULL;
| |
}
| |
}
| |
| |
//---
| |
return curr;
| |
}
| |
| |
//---
| |
}
| |
#endif // BASESPARSERSLAN_SRC_DOM_DOM_POINTER_MQH
| |
//+------------------------------------------------------------------+
|