libqalculate-5.4.0

Public Member Functions | Protected Attributes | List of all members
KnownVariable Class Reference

A variable with a known value. More...

`#include <Variable.h>`

Inheritance diagram for KnownVariable:

## Public Member Functions
| KnownVariable (std::string cat_, std::string name_, const MathStructure &o, std::string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true)
| KnownVariable (std::string cat_, std::string name_, std::string expression_, std::string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true)
| KnownVariable ()
| KnownVariable (const KnownVariable *variable)
virtual ExpressionItem * | copy () const
virtual void | set (const ExpressionItem *item)
bool | isKnown () const
virtual bool | isExpression () const
virtual std::string | expression () const
virtual std::string | uncertainty (bool *is_relative=NULL) const
virtual std::string | unit () const
int | subtype () const
virtual void | set (const MathStructure &o)
virtual void | set (std::string expression_)
virtual void | setUncertainty (std::string standard_uncertainty, bool is_relative=false)
virtual void | setUnit (std::string unit_expression)
virtual const MathStructure & | get ()
virtual bool | representsPositive (bool=false)
virtual bool | representsNegative (bool=false)
virtual bool | representsNonNegative (bool=false)
virtual bool | representsNonPositive (bool=false)
virtual bool | representsInteger (bool=false)
virtual bool | representsNonInteger (bool=false)
virtual bool | representsFraction (bool=false)
virtual bool | representsNumber (bool=false)
virtual bool | representsRational (bool=false)
virtual bool | representsReal (bool=false)
virtual bool | representsNonComplex (bool=false)
virtual bool | representsComplex (bool=false)
virtual bool | representsNonZero (bool=false)
virtual bool | representsEven (bool=false)
virtual bool | representsOdd (bool=false)
virtual bool | representsUndefined (bool=false, bool=false, bool=false)
virtual bool | representsBoolean ()
virtual bool | representsNonMatrix ()
virtual bool | representsScalar ()
virtual int | id () const
Public Member Functions inherited from Variable
| Variable (std::string cat_, std::string name_, std::string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true)
| Variable (const Variable *variable)
virtual int | type () const
Public Member Functions inherited from ExpressionItem
| 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 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)

## Protected Attributes
MathStructure * | mstruct
MathStructure * | mstruct_alt
bool | b_expression
int | calculated_precision
std::string | sexpression
std::string | suncertainty
std::string | sunit
bool | b_relative_uncertainty
Protected Attributes inherited from ExpressionItem
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

## Detailed Description

A variable with a known value.

Known variables have an associated value. The value can be a simple number or a full mathematical expression. The known variable class is used both for variable values and constants.

The value can be provided as an expression in the form of a text string or as a mathematical value in the form of an object of the MathStructure class. The text string is parsed when needed, which saves time when loading many variable definitions which might not be used, at least not immediately.

## Constructor & Destructor Documentation

## ◆ KnownVariable() [1/4]

KnownVariable::KnownVariable | ( | std::string | cat_,
|  | std::string | name_,
|  | const MathStructure & | o,
|  | std::string | title_ = "",
|  | bool | is_local = true,
|  | bool | is_builtin = false,
|  | bool | is_active = true )

Create a known variable with a value.

Parameters

  cat_ | Category that the variable belongs to.
  name_ | Initial name of the variable.
  o | Value.
  title_ | Descriptive name.
  is_local | If the variable is local/user-defined or global.
  is_builtin | If the variable is builtin and not modifiable.
  is_active | If the variable is active and can be used in expressions.

## ◆ KnownVariable() [2/4]

KnownVariable::KnownVariable | ( | std::string | cat_,
|  | std::string | name_,
|  | std::string | expression_,
|  | std::string | title_ = "",
|  | bool | is_local = true,
|  | bool | is_builtin = false,
|  | bool | is_active = true )

Create a known variable with an text string expression.

Parameters

  cat_ | Category that the variable belongs to.
  name_ | Initial name of the variable.
  expression_ | Expression.
  title_ | Descriptive name.
  is_local | If the variable is local/user-defined or global.
  is_builtin | If the variable is builtin and not modifiable.
  is_active | If the variable is active and can be used in expressions.

## ◆ KnownVariable() [3/4]

KnownVariable::KnownVariable | ( |  | ) |

Create an empty known variable. Primarily for internal use.

## ◆ KnownVariable() [4/4]

KnownVariable::KnownVariable | ( | const KnownVariable * | variable | ) |

Create a copy of a known variable.

Parameters

  variable | Known variable to copy.

## Member Function Documentation

## ◆ copy()

virtual ExpressionItem * KnownVariable::copy | ( |  | ) | const
| virtual

Implements Variable.

## ◆ expression()

virtual std::string KnownVariable::expression | ( |  | ) | const
| virtual

Returns the variable's string expression or an empty string if it has not got an expression.

Returns
  The variable's expression.

## ◆ get()

virtual const MathStructure & KnownVariable::get | ( |  | ) |
| virtual

Returns the value of the variable. If no value is set or parsed and an expression is set, the expression is parsed and resulting value returned.

Returns
  The value of the variable..

Reimplemented in DynamicVariable.

## ◆ id()

virtual int KnownVariable::id | ( |  | ) | const
| inline virtual

Reimplemented from Variable.

## ◆ isExpression()

virtual bool KnownVariable::isExpression | ( |  | ) | const
| virtual

Returns if the variable has an text string expression instead of a value.

Returns
  True if the variable has an expression instead of a value.

## ◆ isKnown()

bool KnownVariable::isKnown | ( |  | ) | const
| inline virtual

Returns if the variable has a known value (as opposed to assumptions).

Returns
  true if the variable is of class KnownVariable, false if UnknownVariable.

Implements Variable.

## ◆ representsBoolean()

virtual bool KnownVariable::representsBoolean | ( |  | ) |
| virtual

Reimplemented from Variable.

## ◆ representsComplex()

virtual bool KnownVariable::representsComplex | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsEven()

virtual bool KnownVariable::representsEven | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsFraction()

virtual bool KnownVariable::representsFraction | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsInteger()

virtual bool KnownVariable::representsInteger | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNegative()

virtual bool KnownVariable::representsNegative | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNonComplex()

virtual bool KnownVariable::representsNonComplex | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNonInteger()

virtual bool KnownVariable::representsNonInteger | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNonMatrix()

virtual bool KnownVariable::representsNonMatrix | ( |  | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNonNegative()

virtual bool KnownVariable::representsNonNegative | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNonPositive()

virtual bool KnownVariable::representsNonPositive | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNonZero()

virtual bool KnownVariable::representsNonZero | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsNumber()

virtual bool KnownVariable::representsNumber | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsOdd()

virtual bool KnownVariable::representsOdd | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsPositive()

virtual bool KnownVariable::representsPositive | ( | bool | = false | ) |
| virtual

Returns if the variable represents a positive value.

Reimplemented from Variable.

Reimplemented in DynamicVariable, NowVariable, TodayVariable, TomorrowVariable, and YesterdayVariable.

## ◆ representsRational()

virtual bool KnownVariable::representsRational | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsReal()

virtual bool KnownVariable::representsReal | ( | bool | = false | ) |
| virtual

Reimplemented from Variable.

## ◆ representsScalar()

virtual bool KnownVariable::representsScalar | ( |  | ) |
| virtual

Reimplemented from Variable.

## ◆ representsUndefined()

virtual bool KnownVariable::representsUndefined | ( | bool | = false,
|  | bool | = false,
|  | bool | = false )
| virtual

Reimplemented from Variable.

## ◆ set() [1/3]

virtual void KnownVariable::set | ( | const ExpressionItem * | item | ) |
| virtual

Reimplemented from Variable.

## ◆ set() [2/3]

virtual void KnownVariable::set | ( | const MathStructure & | o | ) |
| virtual

Sets the value of the variable. If expression is set, it is cleared.

Parameters

  o | Value.

Reimplemented in DynamicVariable.

## ◆ set() [3/3]

virtual void KnownVariable::set | ( | std::string | expression_ | ) |
| virtual

Sets the text string expression of the variable. The value is cleared.

Parameters

  expression_ | Expression.

Reimplemented in DynamicVariable.

## ◆ subtype()

int KnownVariable::subtype | ( |  | ) | const
| inline virtual

Returns the subtype of the variable, corresponding to which subsubclass the object belongs to.

Returns
  VariableSubtype.

Reimplemented from Variable.

References SUBTYPE_KNOWN_VARIABLE.

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

- /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_math_libqalculate/libqalculate/work/libqalculate-5.4.0/libqalculate/Variable.h