LSNativeContext Class

class localsolver::LSNativeContext

Context for native functions.

Native contexts are used to query the values of the arguments passed to native functions.

Since:6.0

Summary

Functions
count Returns the number of values in the current context.
isBool Returns true if the value at the given position is a boolean.
isInt Returns true if the value at the given position is an integer.
isDouble Returns true if the value at the given position is a double.
isCollection Returns true if the value at the given position is a collection (list or set).
isArray Returns true if the value at the given position is an array.
getIntValue Returns the integer value at the given position.
getDoubleValue Returns the double value at the given position.
getCollectionValue Returns the collection value at the given position.
getArrayValue Returns the array value at the given position.

Functions

int count() const

Returns the number of values in the current context.

Values in contexts are indexed from 0 to count() - 1.

bool isBool(int pos) const

Returns true if the value at the given position is a boolean.

You can retrieve the value with getIntValue.

Return:True if the value at the given position is a boolean.
Parameters:pos - Position of the value to query.

bool isInt(int pos) const

Returns true if the value at the given position is an integer.

You can retrieve the value with getIntValue.

Return:True if the value at the given position is an integer.
Parameters:pos - Position of the value to query.

bool isDouble(int pos) const

Returns true if the value at the given position is a double.

You can retrieve the value with getDoubleValue.

Return:True if the value at the given position is a double.
Parameters:pos - Position of the value to query.

bool isCollection(int pos) const

Returns true if the value at the given position is a collection (list or set).

You can retrieve the value with getCollectionValue.

Return:True if the value at the given position is a collection.
Since:8.5
Parameters:pos - Position of the value to query.

bool isArray(int pos) const

Returns true if the value at the given position is an array.

You can retrieve the value with getArrayValue.

Return:True if the value at the given position is an array.
Since:8.5
Parameters:pos - Position of the value to query.

lsint getIntValue(int pos) const

Returns the integer value at the given position.

If the value is neither an integer nor a boolean, an exception is thrown.

Return:Integer value.
Parameters:pos - Position of the value to query.

lsdouble getDoubleValue(int pos) const

Returns the double value at the given position.

If the value is not a double, an exception is thrown.

Return:Double value.
Parameters:pos - Position of the value to query.

LSCollection getCollectionValue(int pos) const

Returns the collection value at the given position.

If the value is not a collection (list or set), an exception is thrown. Note that the returned collection is read only.

Return:Collection value.
Since:8.5
Parameters:pos - Position of the value to query.

LSArray getArrayValue(int pos) const

Returns the array value at the given position.

If the value is not an array, an exception is thrown.

Return:Array value.
Since:8.5
Parameters:pos - Position of the value to query.