2026-10-05 17:54:12 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| StrImp.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_EXTRADEF_POINTER_STRIMP_MQH
|
| | | #define BASESPARSERSLAN_SRC_EXTRADEF_POINTER_STRIMP_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "Cpiler.mqh"
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
2026-10-05 21:57:35 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | BSFLPointerQuery::BSFLPointerQuery(const string& query, BSFLPointerCompiler& compiler)
|
| | | : m_i(0), m_last_err(BSFL_POINTER_ERR_NOT)
|
| | | {
|
| | | Set(query, compiler);
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | __forceinline void BSFLPointerQuery::Set(const string &query, BSFLPointerCompiler &compiler)
|
| | | {
|
| | | compiler.Assing(query, CP_UTF8);
|
| | | compiler.CorrectPadding();
|
| | | compiler.Compile(this);
|
| | | }
|
| | |
|
2026-10-05 17:54:12 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void BSFLPointerQuery::ErrorFormat(string &desc)
|
| | | {
|
| | | //---
|
| | | if(m_last_err == BSFL_POINTER_ERR_NOT)
|
| | | return;
|
| | |
|
| | | //---
|
| | | desc.Reserve(256);
|
| | | desc = StringFormat("BSFL Pointer error [índex=%d]: ", (m_i >> 1));
|
| | |
|
| | | //---
|
| | | switch(m_last_err)
|
| | | {
|
| | | case BSFL_POINTER_ERR_KEY_NOT_EXIST:
|
| | | {
|
| | | const ulong v = m_ins[m_i + BSFLPTR_I_NUMBER];
|
| | | desc += StringFormat("Key '%s' not exist in document",
|
| | | CharArrayToString(m_raw, BSFLPOINTER_BIT_GET_START(v), BSFLPOINTER_BIT_GET_LEN(v)));
|
| | | break;
|
| | | }
|
| | | case BSFL_POINTER_ERR_ARRAY_OUT_RANGE:
|
| | | {
|
| | | const int v = (int)m_ins[m_i + BSFLPTR_I_NUMBER];
|
| | | desc += StringFormat("Array index = '%d', out of range or invalid", v);
|
| | | break;
|
| | | }
|
| | | case BSFL_POINTER_ERR_INVALID_NODE_TYPE:
|
| | | {
|
| | | desc += "Invalid node type, must by objet or array";
|
| | | break;
|
| | | }
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void BSFLPointerQuery::ErrorInfo(void)
|
| | | {
|
| | | //---
|
| | | if(m_last_err == BSFL_POINTER_ERR_NOT)
|
| | | return;
|
| | |
|
| | | //---
|
| | | static string desc;
|
| | | ErrorFormat(desc);
|
| | |
|
| | | //---
|
| | | const ulong v = m_ins[m_i + BSFLPTR_I_NUMBER];
|
| | | int pos = BSFLPOINTER_BIT_GET_START(v) + 1;
|
| | |
|
| | | //---
|
| | | static string out;
|
| | | CParserErrFormat::Format(ArraySize(m_raw), m_raw, 1, pos, desc, out);
|
| | |
|
| | | //---
|
| | | Print(out);
|
| | | }
|
| | |
|
2026-10-05 21:57:35 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void BSFLPointerQuery::CintaTypesInfo(void)
|
| | | {
|
| | | //---
|
| | | PrintFormat("--- BSFLPointerQuery/Info ---");
|
| | | PrintFormat("Total instructions = %d\nCurr Index = %d\nCurr last err = %d",
|
| | | m_size, m_i, m_last_err);
|
| | |
|
| | | //---
|
| | | for(int i = 0; i < m_size; i += 2)
|
| | | {
|
| | | const ulong v = m_ins[i + BSFLPTR_I_NUMBER];
|
| | | const int integer = (int)v;
|
| | |
|
| | | //---
|
| | | PrintFormat("[%d] | Number = %d | Key = '%s' | Hash = '%I64u'",
|
| | | i,
|
| | | integer,
|
| | | CharArrayToString(m_raw, BSFLPOINTER_BIT_GET_START(v), BSFLPOINTER_BIT_GET_LEN(v)),
|
| | | m_ins[i + BSFLPTR_I_KEY]
|
| | | );
|
| | | }
|
| | | }
|
| | |
|
2026-10-05 17:54:12 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|
| | | #endif // BASESPARSERSLAN_SRC_EXTRADEF_POINTER_STRIMP_MQH
|