|
Sagui library v3.5.2
Cross-platform library which helps to develop web servers or frameworks.
|
Data Structures | |
| struct | sg_expr_extension |
| struct | sg_expr |
| struct | sg_expr_argument |
Typedefs | |
| typedef double(* | sg_expr_func) (void *cls, struct sg_expr_argument *args, const char *identifier) |
Functions | |
| struct sg_expr * | sg_expr_new (void) __attribute__((malloc)) |
| void | sg_expr_free (struct sg_expr *expr) |
| int | sg_expr_compile (struct sg_expr *expr, const char *str, size_t len, struct sg_expr_extension *extensions) |
| int | sg_expr_clear (struct sg_expr *expr) |
| double | sg_expr_eval (struct sg_expr *expr) |
| double | sg_expr_var (struct sg_expr *expr, const char *name, size_t len) |
| int | sg_expr_set_var (struct sg_expr *expr, const char *name, size_t len, double val) |
| double | sg_expr_arg (struct sg_expr_argument *args, int index) |
| int | sg_expr_near (struct sg_expr *expr) |
| enum sg_expr_err_type | sg_expr_err (struct sg_expr *expr) |
| const char * | sg_expr_strerror (struct sg_expr *expr) |
| double | sg_expr_calc (const char *str, size_t len) |
Mathematical expression evaluator.
| typedef double(* sg_expr_func) (void *cls, struct sg_expr_argument *args, const char *identifier) |
Callback signature to specify a function at build time to be executed at run time in a mathematical expression.
| [out] | cls | User-defined closure. |
| [out] | args | Floating-point arguments passed to the function. |
| [out] | identifier | Null-terminated string to identify the function. |
| enum sg_expr_err_type |
Possible error types returned by the mathematical expression evaluator.
| struct sg_expr * sg_expr_new | ( | void | ) |
Creates a new mathematical expression evaluator handle.
| NULL | If no memory space is available and set the errno to ENOMEM. |
| void sg_expr_free | ( | struct sg_expr * | expr | ) |
Frees the mathematical expression evaluator handle previously allocated by sg_expr_new().
| [in] | expr | Expression evaluator handle. |
| int sg_expr_compile | ( | struct sg_expr * | expr, |
| const char * | str, | ||
| size_t | len, | ||
| struct sg_expr_extension * | extensions | ||
| ) |
Compiles a mathematical expression allowing to declare variables, macros and extensions.
| [in] | expr | Mathematical expression instance. |
| [in] | str | Null-terminated string with the mathematical expression to be compiled. |
| [in] | len | Length of the mathematical expression to be compiled. |
| [in] | extensions | Array of extensions to extend the evaluator. |
| 0 | Success. |
| EINVAL | Invalid argument. |
| ENOENT | Missing a needed extenssion. |
| EALREADY | Mathematical expression already compiled. |
| ENOMEM | Out of memory. |
| int sg_expr_clear | ( | struct sg_expr * | expr | ) |
Clears a mathematical expression instance.
| [in] | expr | Mathematical expression instance. |
| 0 | Success. |
| EINVAL | Invalid argument. |
| double sg_expr_eval | ( | struct sg_expr * | expr | ) |
Evaluates a compiled mathematical expression.
| [in] | expr | Compiled mathematical expression. |
| NAN | If the expr is null and set the errno to EINVAL. |
| double sg_expr_var | ( | struct sg_expr * | expr, |
| const char * | name, | ||
| size_t | len | ||
| ) |
Gets the value of a declared variable.
| [in] | expr | Mathematical expression instance. |
| [in] | name | Name of the declared variable. |
| [in] | len | Length of the variable name. |
| NAN |
|
| int sg_expr_set_var | ( | struct sg_expr * | expr, |
| const char * | name, | ||
| size_t | len, | ||
| double | val | ||
| ) |
Sets a variable to the mathematical expression.
| [in] | expr | Mathematical expression instance. |
| [in] | name | Name for the variable. |
| [in] | len | Length of the variable name. |
| [in] | val | Value for the variable. |
| 0 | Success. |
| EINVAL | Invalid argument. |
| ENOMEM | Out of memory. |
| double sg_expr_arg | ( | struct sg_expr_argument * | args, |
| int | index | ||
| ) |
Gets a function argument by its index.
| [in] | args | Arguments list. |
| [in] | index | Argument index. |
| NAN | If the args is null or index is less than zero and set the errno to EINVAL. |
| int sg_expr_near | ( | struct sg_expr * | expr | ) |
Returns the nearby position of an error in the mathematical expression.
| [in] | expr | Compiled mathematical expression. |
| 0 | Success. |
| EINVAL | Invalid argument. |
| enum sg_expr_err_type sg_expr_err | ( | struct sg_expr * | expr | ) |
Returns the type of an error in the mathematical expression.
| [in] | expr | Compiled mathematical expression. |
| SG_EXPR_ERR_UNKNOWN | If the expr is null or an unknown error occurred and set the errno to EINVAL. |
| const char * sg_expr_strerror | ( | struct sg_expr * | expr | ) |
Returns the description of an error in the mathematical expression.
| [in] | expr | Compiled mathematical expression. |
| NULL | If the expr is null and set the errno to EINVAL. |
| double sg_expr_calc | ( | const char * | str, |
| size_t | len | ||
| ) |
Returns the evaluated value of a mathematical expression.
| [in] | str | Null-terminated string with the mathematical expression to be evaluated. |
| [in] | len | Length of the mathematical expression to be evaluated. |
| NAN | If str is null, or len is less than one, and set the errno to EINVAL. |