Back to Adaptive Vision Library website

You are here: Start » Function Reference » Conditional Processing » ChooseByCase

ChooseByCase


This is Filter Equivalent. This function may be present in generated code, but should not be used in hand-written code.

Header:STD.h
Namespace:avl

Returns one of the input objects depending on the specified case index.

Syntax

void avl::ChooseByCase
(
	const Type& inObjectIfCase0,
	const Type& inObjectIfCase1,
	const Type& inObjectIfCase2,
	const Type& inObjectIfCase3,
	const Type& inObjectIfCase4,
	const Type& inObjectIfCase5,
	const Type& inObjectIfCase6,
	const Type& inObjectIfCase7,
	int inCaseIndex,
	Type& outObject
)

Parameters

Name Type Range Default Description
inObjectIfCase0 const Type& Object to be chosen for the case 0
inObjectIfCase1 const Type& Object to be chosen for the case 1
inObjectIfCase2 const Type& Object to be chosen for the case 2
inObjectIfCase3 const Type& Object to be chosen for the case 3
inObjectIfCase4 const Type& Object to be chosen for the case 4
inObjectIfCase5 const Type& Object to be chosen for the case 5
inObjectIfCase6 const Type& Object to be chosen for the case 6
inObjectIfCase7 const Type& Object to be chosen for the case 7
inCaseIndex int 0 - 7 Determines which object will be chosen
outObject Type& Chosen object

Hints

  • Also consider the ternary operator ?: in Formula Blocks.
  • This filter creates a full copy of one of the input objects. Thus, if you need the highest possible speed, use this filter only with primitive types. An alternative is to use Variant Step macrofilters which are fast and elegant.

Examples

inObjectIfCase0 = "Alice"
inObjectIfCase1 = "Bob"
inObjectIfCase2 = "Mike"
inObjectIfCase3 = "Katherine"
inObjectIfCase4 = "John"
inObjectIfCase5 = "Thomas"
inObjectIfCase6 = "Patricia"
inObjectIfCase7 = "Frank"
inCaseIndex = 2
outObject = "Mike"

Errors

List of possible exceptions:

Error type Description
DomainError Case index out of range in ChooseByCase.

See Also

  • ChooseByRange – Returns one of the three input objects depending on whether the associated input value falls below, in or above the specified range.
  • ChooseByPredicate – Returns one of the two input objects depending on the specified condition.