mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Helper classes to used CType functions as predicate in algorithms.
This commit is contained in:
parent
7dffcd0f6e
commit
eed7b70374
@ -33,7 +33,7 @@ namespace SqMod {
|
|||||||
static const SQChar EMPTY_STR_CHAR = 0;
|
static const SQChar EMPTY_STR_CHAR = 0;
|
||||||
const SQChar * g_EmptyStr = &EMPTY_STR_CHAR;
|
const SQChar * g_EmptyStr = &EMPTY_STR_CHAR;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
PluginFuncs* _Func = NULL;
|
PluginFuncs* _Func = NULL;
|
||||||
PluginCallbacks* _Clbk = NULL;
|
PluginCallbacks* _Clbk = NULL;
|
||||||
PluginInfo* _Info = NULL;
|
PluginInfo* _Info = NULL;
|
||||||
|
@ -403,6 +403,72 @@ bool cLogSWrn(bool cond, CCStr fmt, ...);
|
|||||||
bool cLogSErr(bool cond, CCStr fmt, ...);
|
bool cLogSErr(bool cond, CCStr fmt, ...);
|
||||||
bool cLogSFtl(bool cond, CCStr fmt, ...);
|
bool cLogSFtl(bool cond, CCStr fmt, ...);
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Helper class allows the use of functions with ctype style as predicate for algorithms.
|
||||||
|
*/
|
||||||
|
struct IsCType
|
||||||
|
{
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
typedef int (*CTypeFn)(int); // The signature of a ctype function.
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
CTypeFn m_Fn; // Pointer to the actual function that does the comparison.
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Base constructor.
|
||||||
|
*/
|
||||||
|
IsCType(CTypeFn fn)
|
||||||
|
: m_Fn(fn)
|
||||||
|
{
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Function call operator.
|
||||||
|
*/
|
||||||
|
template < typename T > bool operator () (T c)
|
||||||
|
{
|
||||||
|
return (m_Fn(static_cast< int >(c)) != 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Helper class allows the use of functions with ctype style as predicate for algorithms.
|
||||||
|
*/
|
||||||
|
struct IsNotCType
|
||||||
|
{
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
typedef int (*CTypeFn)(int); // The signature of a ctype function.
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
CTypeFn m_Fn; // Pointer to the actual function that does the comparison.
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Base constructor.
|
||||||
|
*/
|
||||||
|
IsNotCType(CTypeFn fn)
|
||||||
|
: m_Fn(fn)
|
||||||
|
{
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Function call operator.
|
||||||
|
*/
|
||||||
|
template < typename T > bool operator () (T c)
|
||||||
|
{
|
||||||
|
return (m_Fn(static_cast< int >(c)) == 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|
||||||
#endif // _BASE_SHARED_HPP_
|
#endif // _BASE_SHARED_HPP_
|
||||||
|
Loading…
Reference in New Issue
Block a user