last ...
This commit is contained in:
@@ -1358,4 +1358,290 @@ string ToString(ENUM_XPOI_EVENTS value)
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XOHCL Extensions ...
|
||||
|
||||
/**
|
||||
* Check two Bar is Same or not ...
|
||||
*
|
||||
* @param source: XOHCL instance ...
|
||||
* @param dest: XOHCL instance ...
|
||||
* @param force: Check also it's Dates ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSame(
|
||||
XOHCL &source,
|
||||
XOHCL &dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = source.IsValid() &&
|
||||
dest.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
source.open == dest.open &&
|
||||
source.close == dest.close &&
|
||||
source.high == dest.high &&
|
||||
source.low == dest.low;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Specific Items Index inside a Collection ...
|
||||
*
|
||||
* @param source: XOHCL instance ...
|
||||
* @param dest: XOHCL instance Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FindIndex(
|
||||
XOHCL &source,
|
||||
XOHCL &dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!source.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(dest);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar = dest[i];
|
||||
|
||||
//
|
||||
bool isSame = IsSame(
|
||||
source,
|
||||
iBar //
|
||||
);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Specific Bar to List only if Not Exists ...
|
||||
*
|
||||
* @param source: XOHCL instance ...
|
||||
* @param dest: XOHCL instance Collection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AddIfNotExists(
|
||||
XOHCL &source,
|
||||
XOHCL &dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = ArraySize(dest);
|
||||
result = source.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = FindIndex(source, dest);
|
||||
bool isExists = IsValidIndex(idx);
|
||||
if (isExists)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
source,
|
||||
dest //
|
||||
);
|
||||
|
||||
//
|
||||
result = isExists;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XZone Extensions ...
|
||||
|
||||
/**
|
||||
* Check two Zone is Same or not ...
|
||||
*
|
||||
* @param source: XZone instance ...
|
||||
* @param dest: XZone instance ...
|
||||
* @param force: Check also it's Dates ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSame(
|
||||
XZone &source,
|
||||
XZone &dest,
|
||||
bool force = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = source.IsValid() &&
|
||||
dest.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
source.upper == dest.upper &&
|
||||
source.lower == dest.lower;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (force)
|
||||
{
|
||||
//
|
||||
result =
|
||||
source.from == dest.from &&
|
||||
source.to == dest.to;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Specific Items Index inside a Collection ...
|
||||
*
|
||||
* @param source: XZone instance ...
|
||||
* @param dest: XZone instance Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FindIndex(
|
||||
XZone &source,
|
||||
XZone &dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!source.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(dest);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XZone iZone = dest[i];
|
||||
|
||||
//
|
||||
bool isSame = IsSame(
|
||||
source,
|
||||
iZone //
|
||||
);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Specific Zone to List only if Not Exists ...
|
||||
*
|
||||
* @param source: XZone instance ...
|
||||
* @param dest: XZone instance Collection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AddIfNotExists(
|
||||
XZone &source,
|
||||
XZone &dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = ArraySize(dest);
|
||||
result = source.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = FindIndex(source, dest);
|
||||
bool isExists = IsValidIndex(idx);
|
||||
if (isExists)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
source,
|
||||
dest //
|
||||
);
|
||||
|
||||
//
|
||||
result = isExists;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user