libqalculate-4.9.0
|
A mathematical function argument definition with free value and base class for all argument definitions. More...
#include <Function.h>
Public Member Functions | |
Argument (std::string name_="", bool does_test=true, bool does_error=true) | |
Argument (const Argument *arg) | |
virtual | ~Argument () |
virtual void | set (const Argument *arg) |
virtual Argument * | copy () const |
virtual std::string | print () const |
std::string | printlong () const |
bool | test (MathStructure &value, int index, MathFunction *f, const EvaluationOptions &eo=default_evaluation_options) const |
virtual MathStructure | parse (const std::string &str, const ParseOptions &po=default_parse_options) const |
virtual void | parse (MathStructure *mstruct, const std::string &str, const ParseOptions &po=default_parse_options) const |
std::string | name () const |
void | setName (std::string name_) |
void | setCustomCondition (std::string condition) |
std::string | getCustomCondition () const |
bool | tests () const |
void | setTests (bool does_error) |
bool | alerts () const |
void | setAlerts (bool does_error) |
bool | zeroForbidden () const |
void | setZeroForbidden (bool forbid_zero) |
bool | matrixAllowed () const |
void | setMatrixAllowed (bool allow_matrix) |
bool | handlesVector () const |
void | setHandleVector (bool handle_vector) |
bool | isLastArgument () const |
void | setIsLastArgument (bool is_last) |
bool | rationalPolynomial () const |
void | setRationalPolynomial (bool rational_polynomial) |
virtual bool | suggestsQuotes () const |
virtual int | type () const |
Protected Member Functions | |
virtual bool | subtest (MathStructure &value, const EvaluationOptions &eo) const |
virtual std::string | subprintlong () const |
Protected Attributes | |
std::string | sname |
std::string | scondition |
bool | b_zero |
bool | b_test |
bool | b_matrix |
bool | b_text |
bool | b_error |
bool | b_rational |
bool | b_last |
bool | b_handle_vector |
A mathematical function argument definition with free value and base class for all argument definitions.
Free arguments accepts any value.
Argument::Argument | ( | std::string | name_ = "" , |
bool | does_test = true , |
||
bool | does_error = true |
||
) |
Creates a new argument definition.
name | Name/title of the argument definition. |
does_test | If argument values will be tested. |
does_error | If an error will issued if the value tests false. |
Argument::Argument | ( | const Argument * | arg | ) |
Creates a copy of an argument definition.
arg | Argument to copy. |
|
virtual |
Destructor
bool Argument::alerts | ( | ) | const |
If an error message will be presented to the user if the value for the argument is not allowed.
|
virtual |
Returns a copy of the argument definition.
Reimplemented in DataPropertyArgument, DataObjectArgument, NumberArgument, IntegerArgument, SymbolicArgument, TextArgument, DateArgument, VectorArgument, MatrixArgument, ExpressionItemArgument, FunctionArgument, BooleanArgument, UnitArgument, AngleArgument, VariableArgument, FileArgument, and ArgumentSet.
std::string Argument::getCustomCondition | ( | ) | const |
Returns the custom condition expression set for argument values.
std::string Argument::name | ( | ) | const |
Returns the name/title of the argument definition.
|
virtual |
Parses an expression for an argument value. The default behavior is to use Calculator::parse() directly.
str | Expression. |
po | Parse options. |
|
virtual |
Parses an expression for an argument value. The default behavior is to use Calculator::parse() directly.
mstruct | Mathematical structure to set with the parsed expression. |
str | Expression. |
po | Parse options. |
Reimplemented in DateArgument, and AngleArgument.
|
virtual |
Returns a short description of the argument definition. Ex. "number" for NumberArgument.
Reimplemented in DataPropertyArgument, DataObjectArgument, NumberArgument, IntegerArgument, SymbolicArgument, TextArgument, DateArgument, VectorArgument, MatrixArgument, ExpressionItemArgument, FunctionArgument, BooleanArgument, UnitArgument, AngleArgument, VariableArgument, FileArgument, and ArgumentSet.
std::string Argument::printlong | ( | ) | const |
Returns a long description of the argument definition. Ex. "A real number > 2".
bool Argument::rationalPolynomial | ( | ) | const |
If only rational polynomials are allowed as argument value.
|
virtual |
Sets the argument to a copy of an argument definition.
arg | Argument to copy. |
Reimplemented in NumberArgument, and IntegerArgument.
void Argument::setCustomCondition | ( | std::string | condition | ) |
Sets a custom condition for argument values. '\x' is replaced by the argument value in the expression.
condition | Condition expression. |
void Argument::setName | ( | std::string | name_ | ) |
Sets the name/title of the argument definition.
name_ | New name/title. |
void Argument::setZeroForbidden | ( | bool | forbid_zero | ) |
Sets if a value of zero is forbidden for the argument value.
forbid_zero | If zero shall be forbidden. |
|
protectedvirtual |
This function is called from Argument::printlong() and returns description specific the argument definition type. Should be reimplemented by all subclasses. For example IntegerArgument::subprintlong() might return "an integer" and Argument::printlong() might append " that fulfills the condition: even(\x)".
Reimplemented in DataPropertyArgument, DataObjectArgument, NumberArgument, IntegerArgument, SymbolicArgument, TextArgument, DateArgument, VectorArgument, MatrixArgument, ExpressionItemArgument, FunctionArgument, BooleanArgument, UnitArgument, AngleArgument, VariableArgument, FileArgument, and ArgumentSet.
|
protectedvirtual |
This function is called from Argument::test() and performs validation specific to the argument definition type. Should be reimplemented by all subclasses.
value | Value to test. |
eo | Evaluation options to use if the value needs to be evaluated. |
Reimplemented in DataPropertyArgument, DataObjectArgument, NumberArgument, IntegerArgument, SymbolicArgument, TextArgument, DateArgument, VectorArgument, MatrixArgument, ExpressionItemArgument, FunctionArgument, BooleanArgument, UnitArgument, AngleArgument, VariableArgument, FileArgument, and ArgumentSet.
bool Argument::test | ( | MathStructure & | value, |
int | index, | ||
MathFunction * | f, | ||
const EvaluationOptions & | eo = default_evaluation_options |
||
) | const |
Tests if a value fulfils the requirements of the argument definition. The value might change if it has not been fully evaluated.
value | Value to test. |
f | Mathematical function that the value is an argument for. |
eo | Evaluation options to use if the value needs to be evaluated. |
bool Argument::tests | ( | ) | const |
If the value for the argument will be tested. If not, the argument only works as an suggestion and any value is allowed.
|
virtual |
Returns the type of the argument, corresponding to which subclass the object belongs to.
Reimplemented in DataPropertyArgument, DataObjectArgument, NumberArgument, IntegerArgument, SymbolicArgument, TextArgument, DateArgument, VectorArgument, MatrixArgument, ExpressionItemArgument, FunctionArgument, BooleanArgument, UnitArgument, AngleArgument, VariableArgument, FileArgument, and ArgumentSet.
bool Argument::zeroForbidden | ( | ) | const |
If an argument value of zero is forbidden.