kspread

KSpread::Value Class Reference

#include <kspread_value.h>

List of all members.


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)
Valueoperator= (const Value &_value)
Valueassign (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 isZero () const

Static Public Member Functions

static const Valueempty ()
static const ValueerrorDIV0 ()
static const ValueerrorNA ()
static const ValueerrorNAME ()
static const ValueerrorNUM ()
static const ValueerrorNULL ()
static const ValueerrorREF ()
static const ValueerrorVALUE ()
static int compare (double v1, double v2)
static bool isZero (double v)

Protected Attributes

ValueData * d

Constructor & Destructor Documentation

Value::Value  ) 
 

Creates an empty value, i.e holds nothing.

Definition at line 292 of file kspread_value.cc.

Value::Value Type  _type  ) 
 

Creates a value of certain type.

Definition at line 304 of file kspread_value.cc.

Value::~Value  )  [virtual]
 

Destroys the value.

Definition at line 298 of file kspread_value.cc.

Value::Value const Value _value  ) 
 

Creates a copy from another value.

Definition at line 312 of file kspread_value.cc.

Value::Value bool  b  ) 
 

Creates a boolean value.

Definition at line 346 of file kspread_value.cc.

Value::Value long  i  ) 
 

Creates an integer value.

Definition at line 353 of file kspread_value.cc.

Value::Value int  i  ) 
 

Creates an integer value.

Definition at line 360 of file kspread_value.cc.

Value::Value double  f  ) 
 

Create a floating-point value.

Definition at line 367 of file kspread_value.cc.

Value::Value const QString &  s  ) 
 

Create a string value.

Definition at line 374 of file kspread_value.cc.

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
 

Create an array of values.

Definition at line 409 of file kspread_value.cc.


Member Function Documentation

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 766 of file kspread_value.cc.

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.

QDate Value::asDate  )  const
 

Returns the date representation of this value.

Definition at line 598 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.

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.

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.

Value & Value::assign const Value _value  ) 
 

Assigns from another value.

Same as above.

Definition at line 420 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.

QTime Value::asTime  )  const
 

Returns the time representation of this value.

Definition at line 609 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 645 of file kspread_value.cc.

int Value::compare const Value v  )  const
 

Returns -1, 0, 1, depends whether this value is less than, equal to, or greater than v.

Definition at line 802 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 722 of file kspread_value.cc.

Value Value::element unsigned  column,
unsigned  row
const
 

Return an element in the array value.

Definition at line 629 of file kspread_value.cc.

const Value & Value::empty  )  [static]
 

Returns constant reference to empty value.

Definition at line 660 of file kspread_value.cc.

bool Value::equal const Value v  )  const
 

Returns true if this value is equal to v.

Definition at line 908 of file kspread_value.cc.

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 666 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.

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 674 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 682 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 698 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 690 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 706 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 714 of file kspread_value.cc.

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 Value::greater const Value v  )  const
 

Returns true if this value is greater than v.

Definition at line 920 of file kspread_value.cc.

bool KSpread::Value::isArray  )  const [inline]
 

Returns true if the type of this value is array.

Definition at line 194 of file kspread_value.h.

bool KSpread::Value::isBoolean  )  const [inline]
 

Returns true if the type of this value is Boolean.

Definition at line 168 of file kspread_value.h.

bool KSpread::Value::isEmpty  )  const [inline]
 

Returns true if empty.

Definition at line 163 of file kspread_value.h.

bool KSpread::Value::isError  )  const [inline]
 

Returns true if this value holds error information.

Definition at line 199 of file kspread_value.h.

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::isInteger  )  const [inline]
 

Returns true if the type of this value is integer.

Definition at line 173 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]
 

Returns true if the type of this value is string.

Definition at line 189 of file kspread_value.h.

bool Value::less const Value v  )  const
 

Returns true if this value is less than v.

Definition at line 914 of file kspread_value.cc.

Value & Value::operator= const Value _value  ) 
 

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.

unsigned Value::rows  )  const
 

If this value is an array, return the number of rows.

Returns 1 if isArray() returns false.

Definition at line 652 of file kspread_value.cc.

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 637 of file kspread_value.cc.

void Value::setError const QString &  msg  ) 
 

Sets this value to hold error message.

Definition at line 536 of file kspread_value.cc.

void Value::setFormat Format  fmt  ) 
 

Sets format information for this value.

Definition at line 624 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::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 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 QString &  s  ) 
 

Sets this value to string value.

Definition at line 515 of file kspread_value.cc.

void Value::setValue double  f  ) 
 

Sets this value to floating-point value.

Definition at line 492 of file kspread_value.cc.

void Value::setValue int  i  ) 
 

Sets this value to integer value.

Definition at line 464 of file kspread_value.cc.

void Value::setValue long  i  ) 
 

Sets this value to integer value.

Definition at line 455 of file kspread_value.cc.

void Value::setValue bool  b  ) 
 

Sets this value to boolean value.

Definition at line 435 of file kspread_value.cc.

void Value::setValue const Value v  ) 
 

Sets this value to another value.

Definition at line 486 of file kspread_value.cc.

Value::Type Value::type  )  const
 

Returns the type of the value.

Definition at line 429 of file kspread_value.cc.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys