kjs Library API Documentation

KJS::Value Class Reference

Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents. More...

#include <value.h>

Inheritance diagram for KJS::Value:

KJS::Boolean KJS::Completion KJS::Null KJS::Number KJS::Object KJS::String KJS::Undefined List of all members.

Public Methods

bool isValid () const
bool isNull () const
Type type () const
bool isA (Type t) const
Value toPrimitive (ExecState *exec, Type preferredType=UnspecifiedType) const
bool toBoolean (ExecState *exec) const
double toNumber (ExecState *exec) const
int toInteger (ExecState *exec) const
int toInt32 (ExecState *exec) const
unsigned int toUInt32 (ExecState *exec) const
unsigned short toUInt16 (ExecState *exec) const
UString toString (ExecState *exec) const
Object toObject (ExecState *exec) const
bool toUInt32 (unsigned &i) const

Detailed Description

Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents.

Instead of using ValueImps (and derivatives) during normal program execution, you should use a Value-derived class.

Value maintains a pointer to a ValueImp object and uses a reference counting scheme to ensure that the ValueImp object is not deleted or garbage collected.

Note: The conversion operations all return values of various types - if an error occurs during conversion, an error object will instead be returned (where possible), and the execution state's exception will be set appropriately.

Definition at line 169 of file value.h.


Member Function Documentation

bool KJS::Value::isValid   const [inline]
 

Returns whether or not this is a valid value.

An invalid value has a 0 implementation pointer and should not be used for any other operation than this check. Current use: as a distinct return value signalling failing dynamicCast() calls.

Definition at line 183 of file value.h.

Referenced by KJS::String::dynamicCast(), KJS::Boolean::dynamicCast(), KJS::Null::dynamicCast(), KJS::Undefined::dynamicCast(), and KJS::Object::dynamicCast().

bool KJS::Value::isNull   const [inline]
 

Deprecated:
Use !isValid() instead.

Definition at line 188 of file value.h.

Referenced by KJS::Number::dynamicCast().

Type KJS::Value::type   const [inline]
 

Returns the type of value.

This is one of UndefinedType, NullType, BooleanType, StringType, NumberType, or ObjectType.

Returns:
The type of value

Definition at line 197 of file value.h.

References KJS::ValueImp::dispatchType().

Referenced by KJS::Number::dynamicCast(), KJS::String::dynamicCast(), KJS::Boolean::dynamicCast(), KJS::Null::dynamicCast(), KJS::Undefined::dynamicCast(), and KJS::Object::dynamicCast().

bool KJS::Value::isA Type    t const [inline]
 

Checks whether or not the value is of a particular tpye.

Parameters:
t  The type to compare with
Returns:
true if the value is of the specified type, otherwise false

Definition at line 205 of file value.h.

References KJS::ValueImp::dispatchType().

Value KJS::Value::toPrimitive ExecState   exec,
Type    preferredType = UnspecifiedType
const [inline]
 

Performs the ToPrimitive type conversion operation on this value (ECMA 9.1).

Definition at line 211 of file value.h.

References KJS::ValueImp::dispatchToPrimitive().

bool KJS::Value::toBoolean ExecState   exec const [inline]
 

Performs the ToBoolean type conversion operation on this value (ECMA 9.2).

Definition at line 218 of file value.h.

References KJS::ValueImp::dispatchToBoolean().

double KJS::Value::toNumber ExecState   exec const [inline]
 

Performs the ToNumber type conversion operation on this value (ECMA 9.3).

Definition at line 223 of file value.h.

References KJS::ValueImp::dispatchToNumber().

int KJS::Value::toInteger ExecState   exec const [inline]
 

Performs the ToInteger type conversion operation on this value (ECMA 9.4).

Definition at line 228 of file value.h.

References KJS::ValueImp::toInteger().

int KJS::Value::toInt32 ExecState   exec const [inline]
 

Performs the ToInt32 type conversion operation on this value (ECMA 9.5).

Definition at line 233 of file value.h.

References KJS::ValueImp::toInt32().

unsigned int KJS::Value::toUInt32 ExecState   exec const [inline]
 

Performs the ToUInt32 type conversion operation on this value (ECMA 9.6).

Definition at line 238 of file value.h.

References KJS::ValueImp::toUInt32().

unsigned short KJS::Value::toUInt16 ExecState   exec const [inline]
 

Performs the ToUInt16 type conversion operation on this value (ECMA 9.7).

Definition at line 243 of file value.h.

References KJS::ValueImp::toUInt16().

UString KJS::Value::toString ExecState   exec const [inline]
 

Performs the ToString type conversion operation on this value (ECMA 9.8).

Definition at line 248 of file value.h.

References KJS::ValueImp::dispatchToString().

Object KJS::Value::toObject ExecState   exec const [inline]
 

Performs the ToObject type conversion operation on this value (ECMA 9.9).

Definition at line 357 of file object.h.

References KJS::ValueImp::dispatchToObject().

bool KJS::Value::toUInt32 unsigned &    i const [inline]
 

Checks if we can do a lossless conversion to UInt32.

Definition at line 258 of file value.h.

References KJS::ValueImp::dispatchToUInt32().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kjs Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 22 14:23:48 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003