Vuo  1.1.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
VuoMathExpressionParser.cc File Reference

Description

VuoMathExpressionParser implementation.

Classes

class  VuoMathExpressionErrorInternal
 C++ implementation of opaque C type VuoMathExpressionError. More...
 
class  VuoMathExpressionParserInternal
 C++ implementation of opaque C type VuoMathExpressionParser. More...
 

Functions

const char * VuoMathExpressionError_getMessage (VuoMathExpressionError error)
 Returns a description of the error.
 
VuoList_VuoInteger VuoMathExpressionError_getExpressionIndices (VuoMathExpressionError error)
 Returns a sorted list of the indices of the math expressions causing the error.
 
void VuoMathExpressionError_free (VuoMathExpressionError error)
 Destructor.
 
static double deg2rad (double degrees)
 Converts degrees to radians.
 
static double rad2deg (double radians)
 Converts radians to degrees.
 
static vector< string > splitSingleExpressionOnAssignmentOperators (string expression)
 Returns the parts of expression separated by (and not including) the assignment operator ("=").
 
static void checkSyntaxOfSingleExpression (string expression, VuoMathExpressionError *error)
 Checks that expression contains a syntactically valid, single math expression with at most one assignment operator.
 
static void checkSyntaxOfMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error)
 Checks that each single math expression in expressions satisfies checkSyntaxOfSingleExpression().
 
static void parseVariablesFromSingleExpression (string expression, vector< string > &inputVariableNames, string &outputVariableName, VuoMathExpressionError *error)
 Parses the unique variable names from expression and puts them in inputVariableNames and outputVariableName.
 
static void parseVariablesFromMultipleExpressions (VuoList_VuoText expressions, vector< string > &inputVariableNames, vector< string > &outputVariableNames, VuoMathExpressionError *error)
 Parses the unique variable names from expressions and puts them in inputVariableNames and outputVariableNames.
 
void VuoMathExpressionParser_free (void *me)
 Destroys me, a VuoMathExpressionParser.
 
VuoMathExpressionParser VuoMathExpressionParser_makeFromSingleExpression (VuoText expression, VuoMathExpressionError *error)
 Parses expression (e.g.
 
VuoMathExpressionParser VuoMathExpressionParser_makeFromMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error)
 Parses expressions (e.g.
 
VuoList_VuoText VuoMathExpressionParser_getInputVariables (VuoMathExpressionParser m)
 Returns the unique input variable names from the parsed expression(s), in alphabetical order.
 
VuoList_VuoText VuoMathExpressionParser_getOutputVariables (VuoMathExpressionParser m)
 Returns the output variable names from the parsed expression(s), in the order they appeared.
 
VuoDictionary_VuoText_VuoReal VuoMathExpressionParser_calculate (VuoMathExpressionParser m, VuoDictionary_VuoText_VuoReal inputValues)
 Evaluates the parsed expression(s).
 
static double sinInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double cosInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double tanInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double asinInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double acosInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double atanInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double sinhInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double coshInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double tanhInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double asinhInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double acoshInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double atanhInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 

Variables

static const size_t MAX_VARIABLE_COUNT = 64
 Maximum number of variables that can be parsed by a VuoMathExpressionParser.
 

Function Documentation

static double acoshInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double acosInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double asinhInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double asinInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double atanhInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double atanInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static void checkSyntaxOfMultipleExpressions ( VuoList_VuoText  expressions,
VuoMathExpressionError error 
)
static

Checks that each single math expression in expressions satisfies checkSyntaxOfSingleExpression().

static void checkSyntaxOfSingleExpression ( string  expression,
VuoMathExpressionError error 
)
static

Checks that expression contains a syntactically valid, single math expression with at most one assignment operator.

static double coshInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double cosInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double deg2rad ( double  degrees)
static

Converts degrees to radians.

static void parseVariablesFromMultipleExpressions ( VuoList_VuoText  expressions,
vector< string > &  inputVariableNames,
vector< string > &  outputVariableNames,
VuoMathExpressionError error 
)
static

Parses the unique variable names from expressions and puts them in inputVariableNames and outputVariableNames.

Assumes that expressions satisfies checkSyntaxOfMultipleExpressions().

static void parseVariablesFromSingleExpression ( string  expression,
vector< string > &  inputVariableNames,
string &  outputVariableName,
VuoMathExpressionError error 
)
static

Parses the unique variable names from expression and puts them in inputVariableNames and outputVariableName.

Assumes that expression satisfies checkSyntaxOfSingleExpression().

static double rad2deg ( double  radians)
static

Converts radians to degrees.

static double sinhInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double sinInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static vector<string> splitSingleExpressionOnAssignmentOperators ( string  expression)
static

Returns the parts of expression separated by (and not including) the assignment operator ("=").

Assumes that expression satisfies checkSyntaxOfSingleExpression().

static double tanhInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double tanInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

void VuoMathExpressionError_free ( VuoMathExpressionError  error)

Destructor.

VuoList_VuoInteger VuoMathExpressionError_getExpressionIndices ( VuoMathExpressionError  error)

Returns a sorted list of the indices of the math expressions causing the error.

The indices refer to the VuoList_VuoText passed to VuoMathExpressionParser_makeFromMultipleExpressions().

const char* VuoMathExpressionError_getMessage ( VuoMathExpressionError  error)

Returns a description of the error.

The returned pointer is owned by error and should not be freed by the caller.

VuoDictionary_VuoText_VuoReal VuoMathExpressionParser_calculate ( VuoMathExpressionParser  m,
VuoDictionary_VuoText_VuoReal  inputValues 
)

Evaluates the parsed expression(s).

The value of each input variable is set from inputValues (a mapping of variable names to values). Any variables not in inputValues are set to 0.

Returns a mapping of output variable names to values.

void VuoMathExpressionParser_free ( void *  me)

Destroys me, a VuoMathExpressionParser.

VuoList_VuoText VuoMathExpressionParser_getInputVariables ( VuoMathExpressionParser  m)

Returns the unique input variable names from the parsed expression(s), in alphabetical order.

VuoList_VuoText VuoMathExpressionParser_getOutputVariables ( VuoMathExpressionParser  m)

Returns the output variable names from the parsed expression(s), in the order they appeared.

For a non-assignment expression (e.g. "x + 1", as opposed to "y = x + 1"), a unique name is automatically assigned.

VuoMathExpressionParser VuoMathExpressionParser_makeFromMultipleExpressions ( VuoList_VuoText  expressions,
VuoMathExpressionError error 
)

Parses expressions (e.g.

["sum=n1+n2", "product=n1*n2", "n1-n2+5"]).

If parsing fails, returns null and sets error.

VuoMathExpressionParser VuoMathExpressionParser_makeFromSingleExpression ( VuoText  expression,
VuoMathExpressionError error 
)

Parses expression (e.g.

"a + b" or "y = x + 1").

If parsing fails, returns null and sets error.

Variable Documentation

const size_t MAX_VARIABLE_COUNT = 64
static

Maximum number of variables that can be parsed by a VuoMathExpressionParser.