kspread

#include <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 TQString &s)
 
 Value (const char *s)
 
 Value (const TQDateTime &dt)
 
 Value (const TQTime &time)
 
 Value (const TQDate &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 TQString &s)
 
void setError (const TQString &msg)
 
void setValue (const TQDateTime &dt)
 
void setValue (const TQTime &dt)
 
void setValue (const TQDate &dt)
 
void setFormat (Format fmt)
 
bool asBoolean () const
 
long asInteger () const
 
double asFloat () const
 
TQString asString () const
 
TQDateTime asDateTime () const
 
TQDate asDate () const
 
TQTime asTime () const
 
Value element (unsigned column, unsigned row) const
 
void setElement (unsigned column, unsigned row, const Value &value)
 
unsigned columns () const
 
unsigned rows () const
 
TQString 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
 

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.

Member Enumeration Documentation

◆ Format

enum KSpread::Value::Format

Definition at line 57 of file kspread_value.h.

◆ Type

enum KSpread::Value::Type

Definition at line 46 of file kspread_value.h.

Constructor & Destructor Documentation

◆ Value() [1/13]

Value::Value ( )

Creates an empty value, i.e holds nothing.

Definition at line 292 of file kspread_value.cpp.

◆ Value() [2/13]

Value::Value ( Value::Type  _type)

Creates a value of certain type.

Definition at line 304 of file kspread_value.cpp.

◆ ~Value()

Value::~Value ( )
virtual

Destroys the value.

Definition at line 298 of file kspread_value.cpp.

◆ Value() [3/13]

Value::Value ( const Value &  _value)

Creates a copy from another value.

Definition at line 312 of file kspread_value.cpp.

◆ Value() [4/13]

Value::Value ( bool  b)

Creates a boolean value.

Definition at line 346 of file kspread_value.cpp.

◆ Value() [5/13]

Value::Value ( long  i)

Creates an integer value.

Definition at line 353 of file kspread_value.cpp.

◆ Value() [6/13]

Value::Value ( int  i)

Creates an integer value.

Definition at line 360 of file kspread_value.cpp.

◆ Value() [7/13]

Value::Value ( double  f)

Create a floating-point value.

Definition at line 367 of file kspread_value.cpp.

◆ Value() [8/13]

Value::Value ( const TQString &  s)

Create a string value.

Definition at line 374 of file kspread_value.cpp.

◆ Value() [9/13]

Value::Value ( const char *  s)

Definition at line 381 of file kspread_value.cpp.

◆ Value() [10/13]

Value::Value ( const TQDateTime &  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.cpp.

◆ Value() [11/13]

Value::Value ( const TQTime &  time)

Create a floating-point value from time.

See also note above.

Definition at line 395 of file kspread_value.cpp.

◆ Value() [12/13]

Value::Value ( const TQDate &  date)

Create a floating-point value from date.

See also note above.

Definition at line 402 of file kspread_value.cpp.

◆ Value() [13/13]

Value::Value ( unsigned  columns,
unsigned  rows 
)

Create an array of values.

Definition at line 409 of file kspread_value.cpp.

Member Function Documentation

◆ allowComparison()

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

◆ asBoolean()

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

◆ asDate()

TQDate Value::asDate ( ) const

Returns the date representation of this value.

Definition at line 598 of file kspread_value.cpp.

◆ asDateTime()

TQDateTime Value::asDateTime ( ) const

Returns the date/time representation of this value.

Definition at line 592 of file kspread_value.cpp.

◆ asFloat()

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

◆ asInteger()

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

◆ assign()

Value & Value::assign ( const Value &  _value)

Assigns from another value.

Same as above.

Definition at line 420 of file kspread_value.cpp.

◆ asString()

TQString 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.cpp.

◆ asTime()

TQTime Value::asTime ( ) const

Returns the time representation of this value.

Definition at line 609 of file kspread_value.cpp.

◆ columns()

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

◆ compare() [1/2]

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 803 of file kspread_value.cpp.

◆ compare() [2/2]

int Value::compare ( double  v1,
double  v2 
)
static

Definition at line 748 of file kspread_value.cpp.

◆ detach()

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

◆ element()

Value Value::element ( unsigned  column,
unsigned  row 
) const

Return an element in the array value.

Definition at line 630 of file kspread_value.cpp.

◆ empty()

const Value & Value::empty ( )
static

Returns constant reference to empty value.

Definition at line 661 of file kspread_value.cpp.

◆ equal()

bool Value::equal ( const Value &  v) const

Returns true if this value is equal to v.

Definition at line 909 of file kspread_value.cpp.

◆ errorDIV0()

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

◆ errorMessage()

TQString 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.cpp.

◆ errorNA()

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

◆ errorNAME()

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

◆ errorNULL()

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

◆ errorNUM()

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

◆ errorREF()

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

◆ errorVALUE()

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

◆ format()

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

◆ greater()

bool Value::greater ( const Value &  v) const

Returns true if this value is greater than v.

Definition at line 921 of file kspread_value.cpp.

◆ isArray()

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.

◆ isBoolean()

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.

◆ isEmpty()

bool KSpread::Value::isEmpty ( ) const
inline

Returns true if empty.

Definition at line 163 of file kspread_value.h.

◆ isError()

bool KSpread::Value::isError ( ) const
inline

Returns true if this value holds error information.

Definition at line 199 of file kspread_value.h.

◆ isFloat()

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.

◆ isInteger()

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.

◆ isNumber()

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.

◆ isString()

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.

◆ isZero() [1/2]

bool Value::isZero ( ) const

Definition at line 761 of file kspread_value.cpp.

◆ isZero() [2/2]

bool Value::isZero ( double  v)
static

Definition at line 756 of file kspread_value.cpp.

◆ less()

bool Value::less ( const Value &  v) const

Returns true if this value is less than v.

Definition at line 915 of file kspread_value.cpp.

◆ operator!=()

bool KSpread::Value::operator!= ( const Value &  other) const
inline

Definition at line 419 of file kspread_value.h.

◆ operator=()

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

◆ operator==()

bool Value::operator== ( const Value &  v) const

Definition at line 325 of file kspread_value.cpp.

◆ rows()

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

◆ setElement()

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

◆ setError()

void Value::setError ( const TQString &  msg)

Sets this value to hold error message.

Definition at line 536 of file kspread_value.cpp.

◆ setFormat()

void Value::setFormat ( Value::Format  fmt)

Sets format information for this value.

Definition at line 624 of file kspread_value.cpp.

◆ setValue() [1/9]

void Value::setValue ( bool  b)

Sets this value to boolean value.

Definition at line 435 of file kspread_value.cpp.

◆ setValue() [2/9]

void Value::setValue ( const TQDate &  dt)

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

Definition at line 581 of file kspread_value.cpp.

◆ setValue() [3/9]

void Value::setValue ( const TQDateTime &  dt)

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

Definition at line 558 of file kspread_value.cpp.

◆ setValue() [4/9]

void Value::setValue ( const TQString &  s)

Sets this value to string value.

Definition at line 515 of file kspread_value.cpp.

◆ setValue() [5/9]

void Value::setValue ( const TQTime &  dt)

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

Definition at line 571 of file kspread_value.cpp.

◆ setValue() [6/9]

void Value::setValue ( const Value &  v)

Sets this value to another value.

Definition at line 486 of file kspread_value.cpp.

◆ setValue() [7/9]

void Value::setValue ( double  f)

Sets this value to floating-point value.

Definition at line 492 of file kspread_value.cpp.

◆ setValue() [8/9]

void Value::setValue ( int  i)

Sets this value to integer value.

Definition at line 464 of file kspread_value.cpp.

◆ setValue() [9/9]

void Value::setValue ( long  i)

Sets this value to integer value.

Definition at line 455 of file kspread_value.cpp.

◆ type()

Value::Type Value::type ( ) const

Returns the type of the value.

Definition at line 429 of file kspread_value.cpp.

Member Data Documentation

◆ d

ValueData* KSpread::Value::d
protected

Definition at line 429 of file kspread_value.h.


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