MQLArticles/Utils/UView.mqh

78 lines
2.9 KiB
MQL5
Raw Permalink Normal View History

2026-08-28 17:55:58 -05:00
//+------------------------------------------------------------------+
//| UView.mqh |
//| Copyright 2026, Niquel Mendoza |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza"
#property link "https://www.mql5.com"
#property strict
#ifndef MQLARTICLES_UTILS_UVIEW_MQH
#define MQLARTICLES_UTILS_UVIEW_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
template <typename TOuner>
struct CStringView
{
TOuner* m_ctx;
int m_len;
int m_start;
//--- acceso
__forceinline uchar operator[](const int pos) const;
uchar At(const int pos) const;
__forceinline uchar Front() const;
__forceinline uchar Back() const;
//---
string Materialize(int dst_start = 0, int count = WHOLE_ARRAY) const;
int Materialize(uchar& out, int dst_start = 0, int count = WHOLE_ARRAY) const;
//--- modificadores de ventana
int RemovePrefix(int n);
int RemoveSuffix(int n);
//--- operaciones
//- subtr
string SubtrStr(const int pos, const int num) const;
CStringView SubtrView(const int pos, const int num) const;
//- compare
int Compare(const string& other) const;
int Compare(const CStringView& other) const;
//- stats with
__forceinline bool StartsWith(const uchar c) const;
__forceinline bool EndsWith(const uchar c) const;
//- apis basica pero conveirten..
string Lower() const;
string Upper() const;
string Trim() const;
string Replace(const string& find, const string& replacement) const;
//- find
int Find(const uchar c, int pos = 0) const;
int FindWithSwar(const ulong mask, int pos = 0) const;
int FindWithMComp(const uchar c, int pos = 0) const;
int FindStr(const string& find, int pos = 0) const;
//- reverse find
int RFind(const uchar c, int rend = -1) const;
int RFindWithMComp(const uchar c, int pos = -1) const;
int RFindWithSwar(const ulong mask, int pos = -1) const;
int RFindStr(const string& find, int pos = -1) const;
//- exact pattern
bool ExactPattern(const int pos, const string& v);
bool ExactPattern(const int pos, const CStringView& v);
//-- split
int Split(const uchar c, string& out[]);
};
//+------------------------------------------------------------------+
#endif // MQLARTICLES_UTILS_UVIEW_MQH