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:

Inheritance graph
[legend]
Collaboration diagram for KJS::Value:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Value (ValueImp *v)
 Value (const Value &v)
Valueoperator= (const Value &v)
bool isValid () const
 Returns whether or not this is a valid value.

bool isNull () const
 This class or method is obsolete, it is provided for compatibility only. Use !isValid() instead.

ValueImpimp () const
Type type () const
 Returns the type of value.

bool isA (Type t) const
 Checks whether or not the value is of a particular tpye.

Value toPrimitive (ExecState *exec, Type preferredType=UnspecifiedType) const
 Performs the ToPrimitive type conversion operation on this value (ECMA 9.1).

bool toBoolean (ExecState *exec) const
 Performs the ToBoolean type conversion operation on this value (ECMA 9.2).

double toNumber (ExecState *exec) const
 Performs the ToNumber type conversion operation on this value (ECMA 9.3).

int toInteger (ExecState *exec) const
 Performs the ToInteger type conversion operation on this value (ECMA 9.4).

int toInt32 (ExecState *exec) const
 Performs the ToInt32 type conversion operation on this value (ECMA 9.5).

unsigned int toUInt32 (ExecState *exec) const
 Performs the ToUint32 type conversion operation on this value (ECMA 9.6).

unsigned short toUInt16 (ExecState *exec) const
 Performs the ToUint16 type conversion operation on this value (ECMA 9.7).

UString toString (ExecState *exec) const
 Performs the ToString type conversion operation on this value (ECMA 9.8).

Object toObject (ExecState *exec) const
 Performs the ToObject type conversion operation on this value (ECMA 9.9).

Value getBase (ExecState *exec) const
 Performs the GetBase type conversion operation on this value (ECMA 8.7).

UString getPropertyName (ExecState *exec) const
 Performs the GetPropertyName type conversion operation on this value (ECMA 8.7).

Value getValue (ExecState *exec) const
 Performs the GetValue type conversion operation on this value (ECMA 8.7.1).

void putValue (ExecState *exec, const Value w)
 Performs the PutValue type conversion operation on this value (ECMA 8.7.1).


Protected Attributes

ValueImprep

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 156 of file value.h.


Member Function Documentation

bool Value::isValid  )  const
 

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 219 of file value.cpp.

bool Value::isNull  )  const
 

This class or method is obsolete, it is provided for compatibility only. Use !isValid() instead.

Definition at line 224 of file value.cpp.

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

Type Value::type  )  const
 

Returns the type of value.

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

Returns:
The type of value

Definition at line 234 of file value.cpp.

References KJS::ValueImp::type().

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

bool Value::isA Type  t  )  const
 

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

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

Definition at line 239 of file value.cpp.

References type().

Value Value::toPrimitive ExecState exec,
Type  preferredType = UnspecifiedType
const
 

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

Definition at line 244 of file value.cpp.

References KJS::ValueImp::toPrimitive().

bool Value::toBoolean ExecState exec  )  const
 

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

Definition at line 249 of file value.cpp.

References KJS::ValueImp::toBoolean().

double Value::toNumber ExecState exec  )  const
 

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

Definition at line 254 of file value.cpp.

References KJS::ValueImp::toNumber().

int Value::toInteger ExecState exec  )  const
 

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

Definition at line 259 of file value.cpp.

References KJS::ValueImp::toInteger().

int Value::toInt32 ExecState exec  )  const
 

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

Definition at line 264 of file value.cpp.

References KJS::ValueImp::toInt32().

unsigned int Value::toUInt32 ExecState exec  )  const
 

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

Definition at line 269 of file value.cpp.

References KJS::ValueImp::toUInt32().

unsigned short Value::toUInt16 ExecState exec  )  const
 

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

Definition at line 274 of file value.cpp.

References KJS::ValueImp::toUInt16().

UString Value::toString ExecState exec  )  const
 

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

Definition at line 279 of file value.cpp.

References KJS::ValueImp::toString().

Object Value::toObject ExecState exec  )  const
 

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

Definition at line 284 of file value.cpp.

References KJS::ValueImp::toObject().

Value Value::getBase ExecState exec  )  const
 

Performs the GetBase type conversion operation on this value (ECMA 8.7).

Since references are supposed to have an Object or null as their base, this method is guaranteed to return either Null() or an Object value.

Definition at line 290 of file value.cpp.

References KJS::ValueImp::getBase().

UString Value::getPropertyName ExecState exec  )  const
 

Performs the GetPropertyName type conversion operation on this value (ECMA 8.7).

Definition at line 296 of file value.cpp.

References KJS::ValueImp::getPropertyName().

Value Value::getValue ExecState exec  )  const
 

Performs the GetValue type conversion operation on this value (ECMA 8.7.1).

Definition at line 302 of file value.cpp.

References KJS::ValueImp::getValue().

void Value::putValue ExecState exec,
const Value  w
 

Performs the PutValue type conversion operation on this value (ECMA 8.7.1).

Definition at line 308 of file value.cpp.

References KJS::ValueImp::putValue().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:09:38 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001