apply method
- @override
- QueryBuilder builder,
- bool isRoot
override
Implementation
@override
int apply(QueryBuilder builder, bool isRoot) {
final size = _conditions.length;
if (size == 0) {
return -1; // -1 instead of 0 which indicates an error
} else if (size == 1) {
return _conditions[0].apply(builder, isRoot);
}
final intArrayPtr = allocate<Int32>(count: size);
try {
for (var i = 0; i < size; ++i) {
final cid = _conditions[i].apply(builder, false);
if (cid == 0) {
builder._throwExceptionIfNecessary();
throw Exception(
'Failed to create condition ' + _conditions[i].toString());
}
intArrayPtr[i] = cid;
}
// root All (AND) is implicit so no need to actually combine the conditions
if (isRoot && this is ConditionGroupAll) {
return -1; // no error but no condition ID either
}
return _func(builder._cBuilder, intArrayPtr, size);
} finally {
free(intArrayPtr);
}
}