updated: to the new ezc api
added: following ezc functions: ezc_and_not, ezc_any_not, ezc_or_not, ezc_one_not, is, is_not, is_empty, is_not_empty git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1005 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014, Tomasz Sowa
|
||||
* Copyright (c) 2014-2015, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -102,6 +102,53 @@ void ezc_one(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void ezc_and_not(Info & i)
|
||||
{
|
||||
if( !i.params.empty() )
|
||||
{
|
||||
i.res = true;
|
||||
|
||||
for(size_t a=0 ; a < i.params.size() ; ++a)
|
||||
{
|
||||
if( i.params[a].res )
|
||||
{
|
||||
i.res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ezc_any_not(Info & i)
|
||||
{
|
||||
ezc_and_not(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ezc_or_not(Info & i)
|
||||
{
|
||||
i.res = false;
|
||||
|
||||
for(size_t a=0 ; a < i.params.size() ; ++a)
|
||||
{
|
||||
if( !i.params[a].res )
|
||||
{
|
||||
i.res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ezc_one_not(Info & i)
|
||||
{
|
||||
ezc_or_not(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ezc_not(Info & i)
|
||||
{
|
||||
if( !i.params.empty() )
|
||||
@@ -110,6 +157,7 @@ void ezc_not(Info & i)
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* compare strings
|
||||
*/
|
||||
@@ -132,6 +180,44 @@ void cmp(Info & i)
|
||||
|
||||
|
||||
|
||||
void is(Info & i)
|
||||
{
|
||||
cmp(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void is_not(Info & i)
|
||||
{
|
||||
cmp(i);
|
||||
i.res = !i.res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void is_empty(Info & i)
|
||||
{
|
||||
i.res = true;
|
||||
|
||||
for(size_t a=0 ; a < i.params.size() ; ++a)
|
||||
{
|
||||
if( !i.params[a].str.empty() )
|
||||
{
|
||||
i.res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void is_not_empty(Info & i)
|
||||
{
|
||||
is_empty(i);
|
||||
i.res = !i.res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// IMPROVE ME !! may we need such a filter too?
|
||||
|
@@ -329,19 +329,27 @@ void Templates::CreateFunctions()
|
||||
/*
|
||||
generic functions
|
||||
*/
|
||||
ezc_functions.Insert("false", ezc_false);
|
||||
ezc_functions.Insert("true", ezc_true);
|
||||
ezc_functions.Insert("and", ezc_and);
|
||||
ezc_functions.Insert("any", ezc_any);
|
||||
ezc_functions.Insert("or", ezc_or);
|
||||
ezc_functions.Insert("one", ezc_one);
|
||||
ezc_functions.Insert("not", ezc_not);
|
||||
ezc_functions.Insert("cmp", cmp);
|
||||
ezc_functions.Insert("trim", trim);
|
||||
ezc_functions.Insert("to_lower", to_lower);
|
||||
ezc_functions.Insert("to_upper", to_upper);
|
||||
ezc_functions.Insert("index", index);
|
||||
ezc_functions.Insert("str", str);
|
||||
ezc_functions.Insert("false", ezc_false);
|
||||
ezc_functions.Insert("true", ezc_true);
|
||||
ezc_functions.Insert("and", ezc_and);
|
||||
ezc_functions.Insert("any", ezc_any);
|
||||
ezc_functions.Insert("or", ezc_or);
|
||||
ezc_functions.Insert("one", ezc_one);
|
||||
ezc_functions.Insert("and_not", ezc_and_not);
|
||||
ezc_functions.Insert("any_not", ezc_any_not);
|
||||
ezc_functions.Insert("or_not", ezc_or_not);
|
||||
ezc_functions.Insert("one_not", ezc_one_not);
|
||||
ezc_functions.Insert("not", ezc_not);
|
||||
ezc_functions.Insert("cmp", cmp);
|
||||
ezc_functions.Insert("is", is);
|
||||
ezc_functions.Insert("is_not", is_not);
|
||||
ezc_functions.Insert("is_empty", is_empty);
|
||||
ezc_functions.Insert("is_not_empty", is_not_empty);
|
||||
ezc_functions.Insert("trim", trim);
|
||||
ezc_functions.Insert("to_lower", to_lower);
|
||||
ezc_functions.Insert("to_upper", to_upper);
|
||||
ezc_functions.Insert("index", index);
|
||||
ezc_functions.Insert("str", str);
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -248,8 +248,16 @@ namespace TemplatesFunctions
|
||||
void ezc_any(Info & i);
|
||||
void ezc_or(Info & i);
|
||||
void ezc_one(Info & i);
|
||||
void ezc_and_not(Info & i);
|
||||
void ezc_any_not(Info & i);
|
||||
void ezc_or_not(Info & i);
|
||||
void ezc_one_not(Info & i);
|
||||
void ezc_not(Info & i);
|
||||
void cmp(Info & i);
|
||||
void is(Info & i);
|
||||
void is_not(Info & i);
|
||||
void is_empty(Info & i);
|
||||
void is_not_empty(Info & i);
|
||||
void trim(Info & i);
|
||||
void to_lower(Info & i);
|
||||
void to_upper(Info & i);
|
||||
|
Reference in New Issue
Block a user