本文整理汇总了C++中Filter::eval方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::eval方法的具体用法?C++ Filter::eval怎么用?C++ Filter::eval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::eval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
// Retrieve up to "N" items where N is list.size().
// Items must match filter and lie adjacent to Cursor.
// Returns false on IO error.
bool HistoryFlat::get(const Filter &filter, Cursor &cursor, std::vector<Item> &list)
{
// number of items found.
size_t i = 0;
// record index to start scan.
size_t index = cursor.indices[cursor.forward];
// update opposing scan index.
cursor.indices[!cursor.forward] = index;
// is our list full?
while ( i < list.size() )
{
// no: read a record.
if ( !read(index) )
// IO error.
return false;
// match filter criteria?
if ( filter.eval(_item) )
{
// yes: add it.
list[i++] = _item;
}
// advance cursor; stop if reach limit.
if ( !cursor.index(index) )
break;
}
// resize to number records found.
list.resize(i);
// update cursor index.
cursor.indices[cursor.forward] = index;
return true;
}
示例2: Value
bike.props.set("type", "bike");
bike.props.set("series", "CB");
bike.props.set("check", "available");
bike.props.set("serial", 4398046511105); // 2^42 + 1
ctx.setKeyword("$geometry", Value(1));
ctx.setKeyword("$zoom", Value("false"));
}
//1. basic predicate
TEST_CASE( "yaml-filter-tests: basic predicate test", "[filters][core][yaml]") {
init();
Filter filter = load("filter: { series: !!str 3}");
REQUIRE(!filter.eval(civic, ctx));
REQUIRE(filter.eval(bmw1, ctx));
REQUIRE(!filter.eval(bike, ctx));
}
//2. predicate with valueList
TEST_CASE( "yaml-filter-tests: predicate with valueList", "[filters][core][yaml]") {
init();
Filter filter = load("filter: { name : [civic, bmw320i] }");
REQUIRE(filter.eval(civic, ctx));
REQUIRE(filter.eval(bmw1, ctx));
REQUIRE(!filter.eval(bike, ctx));
}