Virtual_by_fxsaber/Include/fxsaber/Virtual/String.mqh

90 lines
3.6 KiB
MQL5
Raw Permalink Normal View History

<EFBFBD><EFBFBD>#ifdef VIRTUAL_COUNTER
struct COUNTER_UNIT
{
int Count;
string Name;
COUNTER_UNIT() : Count(0), Name(NULL)
{
}
bool Set( const string &Str )
{
bool Res = (this.Name == Str);
if (!Res && (Res = (this.Name == NULL)))
this.Name = Str;
return(Res && (bool)++this.Count);
}
};
class COUNTER
{
COUNTER_UNIT Units[];
int Amount;
public:
COUNTER( void ) : Amount(::ArrayResize(Units, 1000) * 0)
{
}
void Set( const string Str )
{
for (int i = 0; (i <= this.Amount); i++)
if (this.Units[i].Set(Str))
{
if (i == this.Amount)
this.Amount++;
break;
}
}
~COUNTER()
{
::ArrayResize(this.Units, this.Amount);
::ArrayPrint(this.Units);
}
};
COUNTER Counter; // Counter.Set(__FUNCTION__); ?@>?8A0BL 2 DC=:F8OE.
#define _VC Counter.Set(__FUNCTION__);
#else // #ifdef VIRTUAL_COUNTER
#define _VC
#endif // #ifdef VIRTUAL_COUNTER #else
#define STRING_LEN (sizeof(uint) * 16) // K@02=820=85 ?> uint
struct STRING
{
//private: // https://www.mql5.com/ru/forum/1111/page2274#comment_8563787
uchar Array[STRING_LEN];
public:
void operator =( const int ) const
{
_VC
return;
}
void operator =( const string &Str )
{
_VC
if (Str == NULL) // https://www.mql5.com/ru/forum/1111/page2323#comment_9414672
this.Array[0] = 0; // NULL-AB@>:0 1C45B ?@52@0I0BLAO 2 ""-AB@>:C, B.5. NULL-AB@>:C =5 A>E@0=8BL.
else
::StringToCharArray(Str, this.Array);
return;
}
string Get( void ) const
{
_VC
return(::CharArrayToString(this.Array)); // https://www.mql5.com/ru/forum/380278/page13#comment_25676915
}
};
#undef STRING_LEN