kspread Library API Documentation

KSpreadValue Class Reference

Provides a wrapper for cell value. More...

#include <kspread_value.h>

List of all members.

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

 KSpreadValue ()
 KSpreadValue (Type _type)
virtual ~KSpreadValue ()
 KSpreadValue (const KSpreadValue &_value)
KSpreadValueoperator= (const KSpreadValue &_value)
KSpreadValueassign (const KSpreadValue &_value)
 KSpreadValue (bool b)
 KSpreadValue (long i)
 KSpreadValue (int i)
 KSpreadValue (double f)
 KSpreadValue (const QString &s)
 KSpreadValue (const QDateTime &dt)
 KSpreadValue (const QTime &time)
 KSpreadValue (const QDate &date)
 KSpreadValue (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 KSpreadValue &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
KSpreadValue element (unsigned column, unsigned row) const
void setElement (unsigned column, unsigned row, const KSpreadValue &value)
unsigned columns () const
unsigned rows () const
QString errorMessage () const
void detach ()
bool allowComparison (const KSpreadValue &v) const
int compare (const KSpreadValue &v) const
bool equal (const KSpreadValue &v) const
bool less (const KSpreadValue &v) const
bool greater (const KSpreadValue &v) const
bool isZero () const

Static Public Member Functions

static const KSpreadValueempty ()
static const KSpreadValueerrorDIV0 ()
static const KSpreadValueerrorNA ()
static const KSpreadValueerrorNAME ()
static const KSpreadValueerrorNUM ()
static const KSpreadValueerrorNULL ()
static const KSpreadValueerrorREF ()
static const KSpreadValueerrorVALUE ()
static int compare (double v1, double v2)
static bool isZero (double v)

Protected Attributes

KSpreadValueData * d


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.

KSpreadValue uses implicit data sharing to reduce memory usage.

Definition at line 39 of file kspread_value.h.


Constructor & Destructor Documentation

KSpreadValue::KSpreadValue  ) 
 

Creates an empty value, i.e holds nothing.

Definition at line 198 of file kspread_value.cc.

Referenced by element(), and setElement().

KSpreadValue::KSpreadValue Type  _type  ) 
 

Creates a value of certain type.

Definition at line 210 of file kspread_value.cc.

KSpreadValue::~KSpreadValue  )  [virtual]
 

Destroys the value.

Definition at line 204 of file kspread_value.cc.

KSpreadValue::KSpreadValue const KSpreadValue _value  ) 
 

Creates a copy from another value.

Definition at line 218 of file kspread_value.cc.

References assign().

KSpreadValue::KSpreadValue bool  b  ) 
 

Creates a boolean value.

Definition at line 231 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue long  i  ) 
 

Creates an integer value.

Definition at line 238 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue int  i  ) 
 

Creates an integer value.

Definition at line 245 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue double  f  ) 
 

Create a floating-point value.

Definition at line 252 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue const QString s  ) 
 

Create a string value.

Definition at line 259 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue 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 266 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue const QTime time  ) 
 

Create a floating-point value from time.

See also note above.

Definition at line 273 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue const QDate date  ) 
 

Create a floating-point value from date.

See also note above.

Definition at line 280 of file kspread_value.cc.

References setValue().

KSpreadValue::KSpreadValue unsigned  columns,
unsigned  rows
 

Create an array of values.

Definition at line 287 of file kspread_value.cc.


Member Function Documentation

KSpreadValue & KSpreadValue::operator= const KSpreadValue _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 225 of file kspread_value.cc.

References assign().

KSpreadValue & KSpreadValue::assign const KSpreadValue _value  ) 
 

Assigns from another value.

Same as above.

Definition at line 298 of file kspread_value.cc.

Referenced by KSpreadValue(), operator=(), and setValue().

KSpreadValue::Type KSpreadValue::type  )  const
 

Returns the type of the value.

Definition at line 307 of file kspread_value.cc.

Referenced by allowComparison(), asBoolean(), asFloat(), asInteger(), asString(), compare(), errorMessage(), and KSpreadCell::setValue().

KSpreadValue::Format KSpreadValue::format  )  const
 

Returns the format of the value (i.e.

how should it be interpreted)

Definition at line 497 of file kspread_value.cc.

Referenced by KSpread::ValueCalc::add(), and KSpread::ValueFormatter::determineFormatting().

bool KSpreadValue::isEmpty  )  const [inline]
 

Returns true if empty.

Definition at line 160 of file kspread_value.h.

bool KSpreadValue::isBoolean  )  const [inline]
 

Returns true if the type of this value is Boolean.

Definition at line 165 of file kspread_value.h.

Referenced by KSpread::ValueFormatter::determineFormatting().

bool KSpreadValue::isInteger  )  const [inline]
 

Returns true if the type of this value is integer.

Definition at line 170 of file kspread_value.h.

bool KSpreadValue::isFloat  )  const [inline]
 

Returns true if the type of this value is floating-point.

Definition at line 175 of file kspread_value.h.

bool KSpreadValue::isNumber  )  const [inline]
 

Returns true if the type of this value is either integer or floating-point.

Definition at line 181 of file kspread_value.h.

Referenced by KSpread::ValueCalc::add().

bool KSpreadValue::isString  )  const [inline]
 

Returns true if the type of this value is string.

Definition at line 186 of file kspread_value.h.

Referenced by KSpread::ValueFormatter::determineFormatting().

bool KSpreadValue::isArray  )  const [inline]
 

Returns true if the type of this value is array.

Definition at line 191 of file kspread_value.h.

Referenced by KSpread::ValueFormatter::formatText(), and KSpread::ValueCalc::sum().

bool KSpreadValue::isError  )  const [inline]
 

Returns true if this value holds error information.

Definition at line 196 of file kspread_value.h.

Referenced by errorDIV0(), errorNA(), errorNAME(), errorNULL(), errorNUM(), errorREF(), and errorVALUE().

void KSpreadValue::setValue const KSpreadValue v  ) 
 

Sets this value to another value.

Definition at line 364 of file kspread_value.cc.

References assign().

Referenced by KSpreadValue(), KSpread::ValueParser::parse(), and setValue().

void KSpreadValue::setValue bool  b  ) 
 

Sets this value to boolean value.

Definition at line 313 of file kspread_value.cc.

References detach().

void KSpreadValue::setValue long  i  ) 
 

Sets this value to integer value.

Definition at line 333 of file kspread_value.cc.

References detach().

void KSpreadValue::setValue int  i  ) 
 

Sets this value to integer value.

Definition at line 342 of file kspread_value.cc.

References detach().

void KSpreadValue::setValue double  f  ) 
 

Sets this value to floating-point value.

Definition at line 370 of file kspread_value.cc.

References detach().

void KSpreadValue::setValue const QString s  ) 
 

Sets this value to string value.

Definition at line 393 of file kspread_value.cc.

References detach().

void KSpreadValue::setError const QString msg  ) 
 

Sets this value to hold error message.

Definition at line 414 of file kspread_value.cc.

References detach().

Referenced by KSpreadCell::calc(), errorDIV0(), errorNA(), errorNAME(), errorNULL(), errorNUM(), errorREF(), errorVALUE(), and KSpreadCell::makeFormula().

void KSpreadValue::setValue const QDateTime dt  ) 
 

Sets this value to floating-point number representing the date/time.

Definition at line 436 of file kspread_value.cc.

References setValue().

void KSpreadValue::setValue const QTime dt  ) 
 

Sets this value to floating-point number representing the date.

Definition at line 449 of file kspread_value.cc.

References setValue().

void KSpreadValue::setValue const QDate dt  ) 
 

Sets this value to floating-point number representing the time.

Definition at line 459 of file kspread_value.cc.

References setValue().

void KSpreadValue::setFormat Format  fmt  ) 
 

Sets format information for this value.

Definition at line 502 of file kspread_value.cc.

Referenced by KSpread::ValueCalc::add(), KSpread::ValueCalc::log(), KSpread::ValueParser::parse(), and KSpread::ValueCalc::sum().

bool KSpreadValue::asBoolean  )  const
 

Returns the boolean value of this value.

Call this function only if isBoolean() returns true.

Definition at line 322 of file kspread_value.cc.

References type().

Referenced by compare().

long KSpreadValue::asInteger  )  const
 

Returns the integer value of this value.

Call this function only if isNumber() returns true.

Definition at line 351 of file kspread_value.cc.

References type().

Referenced by compare().

double KSpreadValue::asFloat  )  const
 

Returns the floating-point value of this value.

Call this function only if isNumber() returns true.

Definition at line 379 of file kspread_value.cc.

References type().

Referenced by asDate(), asTime(), compare(), KSpread::ValueFormatter::determineFormatting(), and KSpread::ValueFormatter::formatText().

QString KSpreadValue::asString  )  const
 

Returns the string value of this value.

Call this function only if isString() returns true.

Definition at line 402 of file kspread_value.cc.

References type().

Referenced by compare().

QDateTime KSpreadValue::asDateTime  )  const
 

Returns the date/time representation of this value.

Definition at line 470 of file kspread_value.cc.

References asDate(), and asTime().

Referenced by KSpread::ValueFormatter::formatText().

QDate KSpreadValue::asDate  )  const
 

Returns the date representation of this value.

Definition at line 476 of file kspread_value.cc.

References asFloat().

Referenced by asDateTime(), and KSpread::ValueFormatter::formatText().

QTime KSpreadValue::asTime  )  const
 

Returns the time representation of this value.

Definition at line 487 of file kspread_value.cc.

References asFloat().

Referenced by asDateTime().

KSpreadValue KSpreadValue::element unsigned  column,
unsigned  row
const
 

Return an element in the array value.

Do not call if isArray() is false.

Definition at line 507 of file kspread_value.cc.

References empty(), and KSpreadValue().

Referenced by KSpread::ValueFormatter::formatText(), and KSpread::ValueCalc::sum().

void KSpreadValue::setElement unsigned  column,
unsigned  row,
const KSpreadValue value
 

Sets an element in the array value.

Do not use if isArray() is false.

Definition at line 515 of file kspread_value.cc.

References detach(), and KSpreadValue().

unsigned KSpreadValue::columns  )  const
 

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

Note that return value is undefined if isArray() returns false.

Definition at line 523 of file kspread_value.cc.

Referenced by KSpread::ValueCalc::sum().

unsigned KSpreadValue::rows  )  const
 

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

Note that return value is undefined if isArray() returns false.

Definition at line 530 of file kspread_value.cc.

Referenced by KSpread::ValueCalc::sum().

QString KSpreadValue::errorMessage  )  const
 

Returns error message associated with this value.

Call this function only if isError() returns true.

Definition at line 422 of file kspread_value.cc.

References type().

Referenced by compare().

void KSpreadValue::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 600 of file kspread_value.cc.

Referenced by setElement(), setError(), and setValue().

const KSpreadValue & KSpreadValue::empty  )  [static]
 

Returns constant reference to empty value.

Definition at line 538 of file kspread_value.cc.

Referenced by KSpreadCell::calc(), KSpreadCell::checkTextInput(), element(), and KSpreadCell::~KSpreadCell().

const KSpreadValue & KSpreadValue::errorDIV0  )  [static]
 

Returns constant reference to #DIV/0! error.

This is used to indicate that a formula divides by 0 (zero).

Definition at line 544 of file kspread_value.cc.

References isError(), and setError().

Referenced by KSpread::ValueCalc::log().

const KSpreadValue & KSpreadValue::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 552 of file kspread_value.cc.

References isError(), and setError().

Referenced by KSpread::ValueCalc::log().

const KSpreadValue & KSpreadValue::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 560 of file kspread_value.cc.

References isError(), and setError().

const KSpreadValue & KSpreadValue::errorNUM  )  [static]
 

Returns constant reference to #NUM! error.

This is to indicate a problem with a number in a formula.

Definition at line 568 of file kspread_value.cc.

References isError(), and setError().

const KSpreadValue & KSpreadValue::errorNULL  )  [static]
 

Returns constant reference to #NULL! error.

This is to indicate that two area do not intersect.

Definition at line 576 of file kspread_value.cc.

References isError(), and setError().

const KSpreadValue & KSpreadValue::errorREF  )  [static]
 

Returns constant reference to #REF! error.

This is used to indicate an invalid cell reference.

Definition at line 584 of file kspread_value.cc.

References isError(), and setError().

const KSpreadValue & KSpreadValue::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 592 of file kspread_value.cc.

References isError(), and setError().

bool KSpreadValue::allowComparison const KSpreadValue 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 644 of file kspread_value.cc.

References type().

int KSpreadValue::compare const KSpreadValue v  )  const
 

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

Definition at line 677 of file kspread_value.cc.

References asBoolean(), asFloat(), asInteger(), asString(), errorMessage(), and type().

Referenced by equal(), greater(), and less().

bool KSpreadValue::equal const KSpreadValue v  )  const
 

Returns true if this value is equal to v.

Definition at line 783 of file kspread_value.cc.

References compare().

bool KSpreadValue::less const KSpreadValue v  )  const
 

Returns true if this value is less than v.

Definition at line 788 of file kspread_value.cc.

References compare().

bool KSpreadValue::greater const KSpreadValue v  )  const
 

Returns true if this value is greater than v.

Definition at line 793 of file kspread_value.cc.

References compare().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:48 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003