kspread
KSpread::Formula Class Reference
Class Formula encapsulates a formula for a cell. More...
#include <Formula.h>
Public Member Functions | |
| Formula (const Formula &) | |
| Formula () | |
| Formula (Sheet *sheet) | |
| Formula (Sheet *sheet, const Cell &cell) | |
| ~Formula () | |
| const Cell & | cell () const |
| void | clear () |
| QString | dump () const |
| Value | eval (CellIndirection cellIndirections=CellIndirection()) const |
| QString | expression () const |
| bool | isValid () const |
| bool | operator!= (const Formula &o) const |
| Formula & | operator= (const Formula &) |
| bool | operator== (const Formula &) const |
| Tokens | scan (const QString &expr, const KLocale *locale=0) const |
| void | setExpression (const QString &expr) |
| Sheet * | sheet () const |
| Tokens | tokens () const |
Protected Member Functions | |
| void | compile (const Tokens &tokens) const |
| Value | evalRecursive (CellIndirection cellIndirections, QHash< Cell, Value > &values) const |
| bool | isNamedArea (const QString &expr) const |
Detailed Description
Class Formula encapsulates a formula for a cell.
A Formula is a equations which perform calculations on values in the cells and sheets. Every formula must start with an equal sign (=).
Definition at line 262 of file Formula.h.
Constructor & Destructor Documentation
| Formula::Formula | ( | Sheet * | sheet | ) | [explicit] |
| Formula::Formula | ( | ) |
Creates a formula that is not owned by any sheet.
This might be useful in some cases.
Definition at line 446 of file Formula.cpp.
| Formula::Formula | ( | const Formula & | other | ) |
Copy constructor.
Definition at line 454 of file Formula.cpp.
| Formula::~Formula | ( | ) |
Destroys the formula.
Definition at line 461 of file Formula.cpp.
Member Function Documentation
| const Cell & Formula::cell | ( | ) | const |
Returns the cell which owns this formula.
Definition at line 465 of file Formula.cpp.
| void Formula::clear | ( | ) |
Clears everything, makes as like a newly constructed formula.
Definition at line 514 of file Formula.cpp.
| void Formula::compile | ( | const Tokens & | tokens | ) | const [protected] |
Definition at line 950 of file Formula.cpp.
| QString Formula::dump | ( | ) | const |
Definition at line 1728 of file Formula.cpp.
| Value Formula::eval | ( | CellIndirection | cellIndirections = CellIndirection() |
) | const |
Evaluates the formula and returns the result.
The optional cellIndirections parameter can be used to replace all occurences of a references to certain cells with references to different cells. If this mapping is non-empty this does mean that intermediate results can't be cached.
Definition at line 1391 of file Formula.cpp.
| Value Formula::evalRecursive | ( | CellIndirection | cellIndirections, | |
| QHash< Cell, Value > & | values | |||
| ) | const [protected] |
helper function for recursive evaluations; makes sure one cell is not evaluated more than once resulting in infinite loops
Definition at line 1397 of file Formula.cpp.
| QString Formula::expression | ( | ) | const |
Gets the expression of this formula.
Definition at line 488 of file Formula.cpp.
| bool Formula::isNamedArea | ( | const QString & | expr | ) | const [protected] |
helper function: return true for valid named area
Definition at line 1377 of file Formula.cpp.
| bool Formula::isValid | ( | ) | const |
Returns true if the specified expression is valid, i.e.
it contains no parsing error. Empty formula (i.e. without expression) is always invalid.
Definition at line 496 of file Formula.cpp.
| bool KSpread::Formula::operator!= | ( | const Formula & | o | ) | const [inline] |
Assignment operator.
Definition at line 1715 of file Formula.cpp.
| bool Formula::operator== | ( | const Formula & | other | ) | const |
Definition at line 1721 of file Formula.cpp.
Given an expression, this function separates it into tokens.
If the expression contains error (e.g. unknown operator, string no terminated) this function returns tokens which is not valid.
Definition at line 536 of file Formula.cpp.
| void Formula::setExpression | ( | const QString & | expr | ) |
Sets the expression for this formula.
Definition at line 479 of file Formula.cpp.
| Sheet * Formula::sheet | ( | ) | const |
Returns the cell which owns this formula.
Definition at line 470 of file Formula.cpp.
| Tokens Formula::tokens | ( | ) | const |
Returns list of tokens associated with this formula.
This has nothing to with the formula evaluation but might be useful, e.g. for syntax highlight or similar features. If the formula contains error, the returned tokens is invalid.
Definition at line 528 of file Formula.cpp.
The documentation for this class was generated from the following files:
