kspread
KSpread::Value Class Reference
#include <kspread_value.h>
Detailed Description
Provides a wrapper for cell value.Each cell in a worksheet must hold a value, either as enterred by user or as a result of formula evaluation. Default cell holds empty value.
Value uses implicit data sharing to reduce memory usage.
Definition at line 41 of file kspread_value.h.
Public Types | |
enum | Type { Empty, Boolean, Integer, Float, String, Array, CellRange, Error } |
enum | Format { fmt_None, fmt_Boolean, fmt_Number, fmt_Percent, fmt_Money, fmt_DateTime, fmt_Date, fmt_Time, fmt_String } |
Public Member Functions | |
Value () | |
Value (Type _type) | |
virtual | ~Value () |
Value (const Value &_value) | |
Value & | operator= (const Value &_value) |
Value & | assign (const Value &_value) |
Value (bool b) | |
Value (long i) | |
Value (int i) | |
Value (double f) | |
Value (const QString &s) | |
Value (const char *s) | |
Value (const QDateTime &dt) | |
Value (const QTime &time) | |
Value (const QDate &date) | |
Value (unsigned columns, unsigned rows) | |
Type | type () const |
Format | format () const |
bool | isEmpty () const |
bool | isBoolean () const |
bool | isInteger () const |
bool | isFloat () const |
bool | isNumber () const |
bool | isString () const |
bool | isArray () const |
bool | isError () const |
void | setValue (const Value &v) |
void | setValue (bool b) |
void | setValue (long i) |
void | setValue (int i) |
void | setValue (double f) |
void | setValue (const QString &s) |
void | setError (const QString &msg) |
void | setValue (const QDateTime &dt) |
void | setValue (const QTime &dt) |
void | setValue (const QDate &dt) |
void | setFormat (Format fmt) |
bool | asBoolean () const |
long | asInteger () const |
double | asFloat () const |
QString | asString () const |
QDateTime | asDateTime () const |
QDate | asDate () const |
QTime | asTime () const |
Value | element (unsigned column, unsigned row) const |
void | setElement (unsigned column, unsigned row, const Value &value) |
unsigned | columns () const |
unsigned | rows () const |
QString | errorMessage () const |
void | detach () |
bool | allowComparison (const Value &v) const |
int | compare (const Value &v) const |
bool | equal (const Value &v) const |
bool | less (const Value &v) const |
bool | greater (const Value &v) const |
bool | operator== (const Value &v) const |
bool | operator!= (const Value &other) const |
bool | isZero () const |
Static Public Member Functions | |
static const Value & | empty () |
static const Value & | errorDIV0 () |
static const Value & | errorNA () |
static const Value & | errorNAME () |
static const Value & | errorNUM () |
static const Value & | errorNULL () |
static const Value & | errorREF () |
static const Value & | errorVALUE () |
static int | compare (double v1, double v2) |
static bool | isZero (double v) |
Protected Attributes | |
ValueData * | d |
Constructor & Destructor Documentation
Value::Value | ( | ) |
Value::Value | ( | Type | _type | ) |
Value::~Value | ( | ) | [virtual] |
Value::Value | ( | const Value & | _value | ) |
Value::Value | ( | bool | b | ) |
Value::Value | ( | long | i | ) |
Value::Value | ( | int | i | ) |
Value::Value | ( | double | f | ) |
Value::Value | ( | const QString & | s | ) |
Value::Value | ( | const QDateTime & | dt | ) |
Create a floating-point value from date/time.
Internally date/time is represented as serial-number, i.e number of elapsed day since reference date. Day 61 is defined as March 1, 1900.
Definition at line 388 of file kspread_value.cc.
Value::Value | ( | const QTime & | time | ) |
Create a floating-point value from time.
See also note above.
Definition at line 395 of file kspread_value.cc.
Value::Value | ( | const QDate & | date | ) |
Create a floating-point value from date.
See also note above.
Definition at line 402 of file kspread_value.cc.
Value::Value | ( | unsigned | columns, | |
unsigned | rows | |||
) |
Member Function Documentation
Assigns from another value.
Because the data is implicitly shared, such assignment is very fast and doesn't consume additional memory.
Definition at line 319 of file kspread_value.cc.
Value::Type Value::type | ( | ) | const |
Value::Format Value::format | ( | ) | const |
Returns the format of the value (i.e.
how should it be interpreted)
Definition at line 619 of file kspread_value.cc.
bool KSpread::Value::isEmpty | ( | ) | const [inline] |
bool KSpread::Value::isBoolean | ( | ) | const [inline] |
bool KSpread::Value::isInteger | ( | ) | const [inline] |
bool KSpread::Value::isFloat | ( | ) | const [inline] |
Returns true if the type of this value is floating-point.
Definition at line 178 of file kspread_value.h.
bool KSpread::Value::isNumber | ( | ) | const [inline] |
Returns true if the type of this value is either integer or floating-point.
Definition at line 184 of file kspread_value.h.
bool KSpread::Value::isString | ( | ) | const [inline] |
bool KSpread::Value::isArray | ( | ) | const [inline] |
bool KSpread::Value::isError | ( | ) | const [inline] |
void Value::setValue | ( | const Value & | v | ) |
void Value::setValue | ( | bool | b | ) |
void Value::setValue | ( | long | i | ) |
void Value::setValue | ( | int | i | ) |
void Value::setValue | ( | double | f | ) |
void Value::setValue | ( | const QString & | s | ) |
void Value::setError | ( | const QString & | msg | ) |
void Value::setValue | ( | const QDateTime & | dt | ) |
Sets this value to floating-point number representing the date/time.
Definition at line 558 of file kspread_value.cc.
void Value::setValue | ( | const QTime & | dt | ) |
Sets this value to floating-point number representing the date.
Definition at line 571 of file kspread_value.cc.
void Value::setValue | ( | const QDate & | dt | ) |
Sets this value to floating-point number representing the time.
Definition at line 581 of file kspread_value.cc.
void Value::setFormat | ( | Format | fmt | ) |
bool Value::asBoolean | ( | ) | const |
Returns the boolean value of this value.
Call this function only if isBoolean() returns true.
Definition at line 444 of file kspread_value.cc.
long Value::asInteger | ( | ) | const |
Returns the integer value of this value.
Call this function only if isNumber() returns true.
Definition at line 473 of file kspread_value.cc.
double Value::asFloat | ( | ) | const |
Returns the floating-point value of this value.
Call this function only if isNumber() returns true.
Definition at line 501 of file kspread_value.cc.
QString Value::asString | ( | ) | const |
Returns the string value of this value.
Call this function only if isString() returns true.
Definition at line 524 of file kspread_value.cc.
QDateTime Value::asDateTime | ( | ) | const |
Returns the date/time representation of this value.
Definition at line 592 of file kspread_value.cc.
QDate Value::asDate | ( | ) | const |
QTime Value::asTime | ( | ) | const |
Value Value::element | ( | unsigned | column, | |
unsigned | row | |||
) | const |
void Value::setElement | ( | unsigned | column, | |
unsigned | row, | |||
const Value & | value | |||
) |
Sets an element in the array value.
Do not use if isArray() is false.
Definition at line 638 of file kspread_value.cc.
unsigned Value::columns | ( | ) | const |
If this value is an array, return the number of columns.
Returns 1 if isArray() returns false.
Definition at line 646 of file kspread_value.cc.
unsigned Value::rows | ( | ) | const |
If this value is an array, return the number of rows.
Returns 1 if isArray() returns false.
Definition at line 653 of file kspread_value.cc.
QString Value::errorMessage | ( | ) | const |
Returns error message associated with this value.
Call this function only if isError() returns true.
Definition at line 544 of file kspread_value.cc.
void Value::detach | ( | ) |
Detaches itself from shared value data, i.e make a private, deep copy of the data.
Usually this function is called automatically so you don't have to care about it.
Definition at line 723 of file kspread_value.cc.
const Value & Value::empty | ( | ) | [static] |
const Value & Value::errorDIV0 | ( | ) | [static] |
Returns constant reference to DIV/0! error.
This is used to indicate that a formula divides by 0 (zero).
Definition at line 667 of file kspread_value.cc.
const Value & Value::errorNA | ( | ) | [static] |
Returns constant reference to N/A error.
This is to indicate that a value is not available to a function.
Definition at line 675 of file kspread_value.cc.
const Value & Value::errorNAME | ( | ) | [static] |
Returns constant reference to NAME? error.
This is to indicate that certain text inside formula is not recognized, possibly a misspelled name or name that does not exist.
Definition at line 683 of file kspread_value.cc.
const Value & Value::errorNUM | ( | ) | [static] |
Returns constant reference to NUM! error.
This is to indicate a problem with a number in a formula.
Definition at line 691 of file kspread_value.cc.
const Value & Value::errorNULL | ( | ) | [static] |
Returns constant reference to NULL! error.
This is to indicate that two area do not intersect.
Definition at line 699 of file kspread_value.cc.
const Value & Value::errorREF | ( | ) | [static] |
Returns constant reference to REF! error.
This is used to indicate an invalid cell reference.
Definition at line 707 of file kspread_value.cc.
const Value & Value::errorVALUE | ( | ) | [static] |
Returns constant reference to VALUE! error.
This is to indicate that wrong type of argument or operand is used, usually within a function call, e.g SIN("some text").
Definition at line 715 of file kspread_value.cc.
bool Value::allowComparison | ( | const Value & | v | ) | const |
Returns true if it is OK to compare this value with v.
If this function returns false, then return value of compare is undefined.
Definition at line 767 of file kspread_value.cc.
Returns -1, 0, 1, depends whether this value is less than, equal to, or greater than v.
Definition at line 803 of file kspread_value.cc.
bool Value::equal | ( | const Value & | v | ) | const |
bool Value::less | ( | const Value & | v | ) | const |
bool Value::greater | ( | const Value & | v | ) | const |
The documentation for this class was generated from the following files: