libqalculate-4.9.0
|
Abstract base class for functions, variables and units. More...
#include <ExpressionItem.h>
Public Member Functions | |
ExpressionItem (std::string cat_, std::string name_, std::string title_="", std::string descr_="", bool is_local=true, bool is_builtin=false, bool is_active=true) | |
virtual ExpressionItem * | copy () const =0 |
virtual void | set (const ExpressionItem *item) |
virtual bool | destroy () |
bool | isRegistered () const |
void | setRegistered (bool is_registered) |
For internal use. | |
virtual const std::string & | name (bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const std::string & | referenceName () const |
virtual const ExpressionName & | preferredName (bool abbreviation=false, bool use_unicode=false, bool plural=false, bool reference=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const ExpressionName & | preferredInputName (bool abbreviation=false, bool use_unicode=false, bool plural=false, bool reference=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const ExpressionName & | preferredDisplayName (bool abbreviation=false, bool use_unicode=false, bool plural=false, bool reference=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const ExpressionName & | getName (size_t index) const |
virtual void | setName (const ExpressionName &ename, size_t index=1, bool force=true) |
virtual void | setName (std::string sname, size_t index, bool force=true) |
virtual void | addName (const ExpressionName &ename, size_t index=0, bool force=true) |
virtual void | addName (std::string sname, size_t index=0, bool force=true) |
virtual size_t | countNames () const |
virtual void | clearNames () |
virtual void | clearNonReferenceNames () |
virtual void | removeName (size_t index) |
virtual size_t | hasName (const std::string &sname, bool case_sensitive=true) const |
virtual size_t | hasNameCaseSensitive (const std::string &sname) const |
virtual const ExpressionName & | findName (int abbreviation=-1, int use_unicode=-1, int plural=-1, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const std::string & | title (bool return_name_if_no_title=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual void | setTitle (std::string title_) |
virtual const std::string & | description () const |
virtual void | setDescription (std::string descr_) |
virtual const std::string & | category () const |
virtual void | setCategory (std::string cat_) |
virtual bool | hasChanged () const |
virtual void | setChanged (bool has_changed) |
virtual bool | isLocal () const |
virtual bool | setLocal (bool is_local=true, int will_be_active=-1) |
virtual bool | isBuiltin () const |
virtual bool | isApproximate () const |
virtual void | setApproximate (bool is_approx=true) |
virtual int | precision () const |
virtual void | setPrecision (int prec) |
virtual bool | isActive () const |
virtual void | setActive (bool is_active) |
virtual bool | isHidden () const |
virtual void | setHidden (bool is_hidden) |
virtual int | refcount () const |
virtual void | ref () |
virtual void | unref () |
virtual void | ref (ExpressionItem *o) |
virtual void | unref (ExpressionItem *o) |
virtual ExpressionItem * | getReferencer (size_t index=1) const |
virtual bool | changeReference (ExpressionItem *o_from, ExpressionItem *o_to) |
virtual int | type () const =0 |
virtual int | subtype () const =0 |
virtual int | id () const |
Protected Attributes | |
std::string | scat |
std::string | stitle |
std::string | sdescr |
bool | b_local |
bool | b_changed |
bool | b_builtin |
bool | b_approx |
bool | b_active |
bool | b_registered |
bool | b_hidden |
bool | b_destroyed |
int | i_ref |
int | i_precision |
std::vector< ExpressionItem * > | v_refs |
std::vector< ExpressionName > | names |
Abstract base class for functions, variables and units.
Expression items have one or more names used to reference it in mathematical expressions and display them in a result. Each name must be fully unique, with the exception that functions can have names used by other types of items (for example "min" is used as a name for the minute unit but also for a function returning smallest value in a vector).
Items have an optional title and description for information to the end user. The category property is used to organize items, so that the end user can easily find them. Subcategories are separated by a slash, '/' (ex. "Physical Constants/Electromagnetic Constants").
A local item is created/edited by the end user.
A builtin item has defining properties that can/should not be edited by the user and is usually an item not loaded from the definition files.
An inactive item can not be used in expressions and can share the name of an active item.
The hidden property defines if the item should be hidden from the end user.
Before an item can be used in expressions, it must be added to the Calculator object using CALCULATOR->addExpressionItem(). It is then said to be registered.
To delete an ExpressionItem object you should use destroy() to make sure that the item is removed from the Calculator and does not have any referrer.
|
virtual |
Returns the category that the expression item belongs to. Subcategories are separated by '/'.
|
virtual |
Removes all names.
|
virtual |
Removes all names that are not used for reference (ExpressionName.reference = true).
|
virtual |
Returns the expression items description.
|
virtual |
Searches for a name with specific properties.
abbreviation | If the name must be abbreviated. 1=true, 0=false, -1=ignore. |
use_unicode | If the name must have unicode characters. 1=true, 0=false, -1=ignore. |
plural | If the name must be in plural form. 1=true, 0=false, -1=ignore. |
can_display_unicode_string_function | Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected. |
can_display_unicode_string_arg | Argument to pass to the above test function. |
|
virtual |
Returns name for an index (starting at one). All functions can be traversed by starting at index one and increasing the index until empty_expression_name is returned.
index | Index of name. |
|
virtual |
If the object has been changed since it was created/loaded.
|
virtual |
Checks if the expression item has a name with a specific text string.
sname | A text string to look for (not case sensitive) |
case_sensitive | If the name is case sensitive. |
|
virtual |
Checks if the expression item has a name with a specific case sensitive text string.
sname | A text string to look for (case sensitive) |
|
virtual |
Returns if the expression item is active and can be used in expressions.
|
virtual |
If the item is approximate or exact. Note that an actual value associated with the item might have a have a lower precision. For, for example, a mathematical function this defines the precision of the formula, not the result.
|
virtual |
Returns precision of the item, if it is approximate. Note that an actual value associated with the item might have a have a lower precision. For, for example, a mathematical function this defines the precision of the formula, not the result.
|
virtual |
Returns the name that best fulfils provided criteria and is suitable for display. If two names are equally preferred, the one with lowest index is returned.
abbreviation | If an abbreviated name is preferred. |
use_unicode | If a name with unicode characters can be displayed/is preferred (prioritized if false). |
plural | If a name in plural form is preferred. |
reference | If a reference name is preferred (ignored if false). |
can_display_unicode_string_function | Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected. |
can_display_unicode_string_arg | Argument to pass to the above test function. |
|
virtual |
Returns the name that best fulfils provided criteria and is suitable for user input. If two names are equally preferred, the one with lowest index is returned.
abbreviation | If an abbreviated name is preferred. |
use_unicode | If a name with unicode characters can be displayed/is preferred (prioritized if false). |
plural | If a name in plural form is preferred. |
reference | If a reference name is preferred (ignored if false). |
can_display_unicode_string_function | Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected. |
can_display_unicode_string_arg | Argument to pass to the above test function. |
|
virtual |
Returns the name that best fulfils provided criteria. If two names are equally preferred, the one with lowest index is returned.
abbreviation | If an abbreviated name is preferred. |
use_unicode | If a name with unicode characters can be displayed/is preferred (prioritized if false). |
plural | If a name in plural form is preferred. |
reference | If a reference name is preferred (ignored if false). |
can_display_unicode_string_function | Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected. |
can_display_unicode_string_arg | Argument to pass to the above test function. |
|
virtual |
The reference count is not used to delete the expression item when it becomes zero, but to stop from being deleted while it is in use.
|
virtual |
Sets which category the expression belongs to. Subcategories are separated by '/'.
cat_ | Category. |
|
virtual |
Sets the expression items description.
descr_ | Description. |
|
virtual |
Changes a name. If a name for the provided index is not present, it is added (equivalent to addName(ename, index, force)).
ename | The new name. |
index | Index of name to change. |
force | If true, expression items with conflicting names are replaced, otherwise . Only applies if the item is registered. |
|
virtual |
Changes the text string of a name. If a name for the provided index is not present, it is added (equivalent to addName(sname, index, force)).
sname | The new name text string. |
index | Index of name to change. |
force | If true, expression items with conflicting names are replaced, otherwise . Only applies if the item is registered. |
|
virtual |
Sets the title, descriptive name, of the item. The title can not be used in expressions.
title_ | The new title. |
|
pure virtual |
Returns the subtype of the expression item, corresponding to which subsubclass the object belongs to.
Implemented in DataSet, MathFunction, UserFunction, Unit, AliasUnit, CompositeUnit, Variable, UnknownVariable, and KnownVariable.
|
virtual |
Returns the title, descriptive name, of the item.
return_name_if_no_title | If true, a name is returned if the title string is empty (using preferredName(false, use_unicode, false, false, can_display_unicode_string_function, can_display_unicode_string_arg)). |
use_unicode | If a name with unicode characters can be displayed/is preferred (passed to preferredName()). |
can_display_unicode_string_function | Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected (passed to preferredName()). |
can_display_unicode_string_arg | Argument to pass to the above test function (passed to preferredName()). |
|
pure virtual |
Returns the type of the expression item, corresponding to which subclass the object belongs to.
Implemented in MathFunction, Unit, and Variable.