GDAL

Public Member Functions | Static Public Member Functions | List of all members
gdal::MathExpression Class Referenceabstract

Class to support evaluation of a mathematical expression. More...

`#include <vrtexpression.h>`

## Public Member Functions
virtual void | RegisterVariable (std::string_view osVariable, double *pdfLocation)=0
| Register a variable to be used in the expression.
virtual void | RegisterVector (std::string_view osVariable, std::vector< double > *padfLocation)=0
| Register a vector to be used in the expression.
virtual CPLErr | Compile ()=0
| Compile the expression.
virtual CPLErr | Evaluate ()=0
| Evaluate the expression.
virtual const std::vector< double > & | Results () const =0
| Access the results from the last time the expression was evaluated.

## Static Public Member Functions
static std::unique_ptr< MathExpression > | Create (const char *pszExpression, const char *pszDialect)
| Create a MathExpression using a specified dialect.

## Detailed Description

Class to support evaluation of a mathematical expression.

## Member Function Documentation

## ◆ Compile()

virtual CPLErr gdal::MathExpression::Compile | ( |  | ) |
| pure virtual

Compile the expression.

If not called explicitly, the expression will be compiled the first time the expression is evaluated.

Returns
  CE_None if the expression can be successfully parsed and all symbols have been registered, CE_Failure otherwise.

Since
  3.11

## ◆ Create()

static std::unique_ptr< MathExpression > gdal::MathExpression::Create | ( | const char * | pszExpression,
|  | const char * | pszDialect
| ) |  |
| static

Create a MathExpression using a specified dialect.

Parameters

  pszExpression | The body of the expression, e.g. "X + 3"
  pszDialect | The expression dialect, e.g. "muparser"

Returns
  a MathExpression using the specified dialect, or nullptr on error.

## ◆ Evaluate()

virtual CPLErr gdal::MathExpression::Evaluate | ( |  | ) |
| pure virtual

Evaluate the expression.

Returns
  CE_None if the expression was successfully evaluated, CE_Failure otherwise.

Since
  3.11

## ◆ RegisterVariable()

virtual void gdal::MathExpression::RegisterVariable | ( | std::string_view | osVariable,
|  | double * | pdfLocation
| ) |  |
| pure virtual

Register a variable to be used in the expression.

The value of the variable may be changed during repeated evaluations of the expression, but its location in memory may not.

Parameters

  osVariable | The name of the variable
  pdfLocation | The location of the variable's value

Since
  3.11

## ◆ RegisterVector()

virtual void gdal::MathExpression::RegisterVector | ( | std::string_view | osVariable,
|  | std::vector< double > * | padfLocation
| ) |  |
| pure virtual

Register a vector to be used in the expression.

The values and size of the vector may be changed during repeated evaluations of the expression, but its location in memory may not.

Parameters

  osVariable | The name of the vector
  padfLocation | The location of the vector

Since
  3.11

## ◆ Results()

virtual const std::vector< double > & gdal::MathExpression::Results | ( |  | ) | const
| pure virtual

Access the results from the last time the expression was evaluated.

The returned vector may be reused on subsequent evaluations of the expression.

Returns
  a reference to the vector in which results are stored.

Since
  3.11

The documentation for this class was generated from the following files:

- vrtexpression.h
- pixelfunctions.cpp