87 lines
2.8 KiB
MQL5
87 lines
2.8 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| Pointer.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_NODE_POINTER_MQH
| |||
#define BASESPARSERSLAN_SRC_NODE_POINTER_MQH
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
#include "NodeBase.mqh"
| |||
#include "..\\ExtraDef\\Pointer\\StrImp.mqh"
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
namespace TSN
| |||
{
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
#define NODEBASESFL_QUERY_SET(INDEX, ERR) \
| |||
query.m_last_err = ERR; \
| |||
query.m_i = INDEX;
| |||
| |||
//---
| |||
template <typename TCtx, typename TType, typename TOut>
| |||
TOut CNodeSFLBase::operator[](BSFLPointerQuery& query)
| |||
{
| |||
//---
| |||
if(NODEBASE_IS_NOT_VALID_F ||
| |||
((1 << int(m_ctx.m_cinta[m_idx] & TSN_SBL_BIT_MASK_TYPE)) & (TSN_SBL_BASE_F_OBJ | TSN_SBL_BASE_F_ARR)) == 0)
| |||
{
| |||
NODEBASESFL_QUERY_SET(0, BSFL_POINTER_ERR_INVALID_NODE_TYPE)
| |||
return TOut::EMPTY_NODE;
| |||
}
| |||
| |||
//---
| |||
TOut curr(m_ctx, m_idx, m_end, m_node_pos);
| |||
| |||
//---
| |||
if(query.m_size == 0)
| |||
return curr;
| |||
| |||
//---
| |||
for(int i = 0; i < query.m_size; i += 2)
| |||
{
| |||
const uchar t = (uchar)curr.GetType();
| |||
if(t == TSN_SBL_BASE_TYPE_OBJ)
| |||
{
| |||
const ulong khash = query.m_ins[i + BSFLPTR_I_KEY];
| |||
curr = curr.Get(khash);
| |||
if(curr.IsInvalid())
| |||
{
| |||
NODEBASESFL_QUERY_SET(i, BSFL_POINTER_ERR_KEY_NOT_EXIST)
| |||
return TOut::EMPTY_NODE;
| |||
}
| |||
}
| |||
else
| |||
if(t == TSN_SBL_BASE_TYPE_ARR)
| |||
{
| |||
const int index = (int)query.m_ins[i + BSFLPTR_I_NUMBER];
| |||
if(!curr.InRangeSafe(index))
| |||
{
| |||
NODEBASESFL_QUERY_SET(i, BSFL_POINTER_ERR_ARRAY_OUT_RANGE)
| |||
return TOut::EMPTY_NODE;
| |||
}
| |||
curr = curr.At(index);
| |||
}
| |||
else
| |||
{
| |||
NODEBASESFL_QUERY_SET(i, BSFL_POINTER_ERR_INVALID_NODE_TYPE)
| |||
return TOut::EMPTY_NODE;
| |||
}
| |||
}
| |||
| |||
//---
| |||
return curr;
| |||
}
| |||
}
| |||
#endif // BASESPARSERSLAN_SRC_NODE_POINTER_MQH
| |||
//+------------------------------------------------------------------+
|