forked from nique_372/BasesParserSLan
84 lines
3.2 KiB
MQL5
84 lines
3.2 KiB
MQL5
//+------------------------------------------------------------------+
| |
//| Number.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_UTILS_NUMBER_MQH
| |
#define BASESPARSERSLAN_SRC_UTILS_NUMBER_MQH
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
//--- conv str a -> val
| |
#include <TSN\\Std\\Str\\Conv.mqh>
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
namespace TSN
| |
{
| |
//+------------------------------------------------------------------+
| |
//| Numeros |
| |
//+------------------------------------------------------------------+
| |
#define DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
STRCONV_TOV_ALG(V, ch) \
| |
if((ch = m_raw[++m_pos] ^ '0') > 9) \
| |
break;
| |
| |
//--- skio lz
| |
#define DOMBASEUTIL_PARSE_SKIP_LZ \
| |
while((ch = m_raw[++m_pos]) == '0') {} \
| |
if((ch^='0') > 9) \
| |
break;
| |
| |
//--- unrolled 9
| |
#define DOMBASEUTIL_PARSE_NUM_UNROLLED_8(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V)
| |
| |
//--- unrolled 17 (8+8+1)
| |
#define DOMBASEUTIL_PARSE_NUM_UNROLLED_17(V) \
| |
DOMBASEUTIL_PARSE_NUM_UNROLLED_8(V) \
| |
DOMBASEUTIL_PARSE_NUM_UNROLLED_8(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V)
| |
| |
//--- unrolled 18 (8+8+2)
| |
#define DOMBASEUTIL_PARSE_NUM_UNROLLED_18(V) \
| |
DOMBASEUTIL_PARSE_NUM_UNROLLED_17(V) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V)
| |
| |
//--- saltar un numero
| |
#define DOMBASEUTIL_NUM_SKIP_NUMBER while((ch = m_raw[++m_pos] ^ '0') < 10) {}
| |
| |
//--- la parte decimal
| |
// la idea es que los digitos tipo 0.000564135641 o esos no coman tantos digitos
| |
#define DOMBASEUTIL_NUM_PROCCES_FIRST_DEC(V, CH, POS, DS, DIG) \
| |
DOMBASEUTIL_PARSE_NUM_U1(V) \
| |
if(!V) \
| |
{ \
| |
if(CH == 0) \
| |
{ \
| |
while((CH = m_raw[++POS]) == '0') {} \
| |
DIG = (DS - POS); \
| |
if((CH^='0') > 9) \
| |
break; \
| |
} \
| |
else \
| |
DIG = (DS - POS); \
| |
DOMBASEUTIL_PARSE_NUM_U1(V, CH) \
| |
}
| |
| |
//---
| |
}
| |
| |
#endif // BASESPARSERSLAN_SRC_UTILS_NUMBER_MQH
|