Doomsday SDK  2.3
Core engine library and supporting libraries
Classes | Public Member Functions | List of all members
de::RefValue Class Reference

References a Variable. More...

#include <refvalue.h>

+ Inheritance diagram for de::RefValue:

Classes

class  NullError
 Attempt to dereference a NULL variable. More...
 

Public Member Functions

 RefValue (Variable *variable=0)
 Constructs a new reference to a variable. More...
 
virtual ~RefValue ()
 
Number asNumber () const
 Convert the value to a number. More...
 
void assign (Value *value)
 Assign value. More...
 
Text asText () const
 Convert the value to into a text string. More...
 
Valuebegin ()
 Begin iteration of contained values. More...
 
void call (Process &process, Value const &arguments, Value *self) const
 Applies the call operator on the value. More...
 
dint compare (Value const &value) const
 Compares this value to another. More...
 
bool contains (Value const &value) const
 Determines whether the value contains the equivalent of another value. More...
 
Valuedereference ()
 
Value const & dereference () const
 
void divide (Value const &divisor)
 Calculate the division of this value divided by divisor, storing the result in this value. More...
 
Valueduplicate () const
 Creates a duplicate copy of the value. More...
 
Value const & element (Value const &index) const
 Get a specific element of the value. More...
 
Valueelement (Value const &index)
 Get a specific element of the value. More...
 
bool isFalse () const
 Determine if the value can be thought of as a logical falsehood. More...
 
bool isTrue () const
 Determine if the value can be thought of as a logical truth. More...
 
RecordmemberScope () const
 Returns the scope for any members of this value. More...
 
void modulo (Value const &divisor)
 Calculate the modulo of this value divided by divisor, storing the result in this value. More...
 
void multiply (Value const &value)
 Calculate the multiplication of this value by value, storing the result in this value. More...
 
void negate ()
 Negate the value of this value. More...
 
Valuenext ()
 Iterate the next value. More...
 
void operator<< (Reader &from)
 Restore the object from the provided Reader. More...
 
void operator>> (Writer &to) const
 Serialize the object using the provided Writer. More...
 
void setElement (Value const &index, Value *elementValue)
 Set a specific element of the value. More...
 
dsize size () const
 Determine the size of the value. More...
 
void subtract (Value const &subtrahend)
 Calculate the subtraction of this value and an another value, storing the result in this value. More...
 
void sum (Value const &value)
 Calculate the sum of this value and an another value, storing the result in this value. More...
 
Text typeId () const
 Returns the type of the value as a text string identifier. More...
 
Variablevariable () const
 Returns the variable this reference points to. More...
 
void variableBeingDeleted (Variable &variable)
 
void verify () const
 
- Public Member Functions inherited from de::Value
virtual ~Value ()
 
template<typename ValueType >
ValueType & as ()
 
template<typename ValueType >
ValueType const & as () const
 
int asInt () const
 Convert the value to the nearest 32-bit signed integer. More...
 
virtual Number asSafeNumber (Number const &defaultValue=0.0) const
 Convert the value to a number. More...
 
StringList asStringList () const
 Convert the value to a list of strings using asText(). More...
 
int asUInt () const
 Convert the value to the nearest 32-bit unsigned integer. More...
 
virtual ValueduplicateAsReference () const
 Creates a duplicate copy of the value. More...
 
virtual ValueduplicateElement (Value const &index) const
 Duplicates an element of the value. More...
 
Value const & element (dint index) const
 
Valueelement (dint index)
 
- Public Member Functions inherited from de::Deletable
virtual ~Deletable ()
 
- Public Member Functions inherited from de::String::IPatternArg
virtual ~IPatternArg ()
 
- Public Member Functions inherited from de::ISerializable
virtual ~ISerializable ()
 
- Public Member Functions inherited from de::IWritable
virtual ~IWritable ()
 
- Public Member Functions inherited from de::IReadable
virtual ~IReadable ()
 

Additional Inherited Members

- Public Types inherited from de::Value
typedef ddouble Number
 Numbers are in double-precision. More...
 
typedef String Text
 Text strings. More...
 
- Public Types inherited from de::Deletable
typedef de::Observers< IDeletionObserverDeletionAudience
 
- Static Public Member Functions inherited from de::Value
static ValueconstructFrom (Reader &reader)
 Construct a value by reading data from the Reader. More...
 
static ValueconstructFrom (QVariant const &variant)
 Construct a value by converting from a QVariant. More...
 
- Public Attributes inherited from de::Deletable
DeletionAudience audienceForDeletion
 
- Protected Types inherited from de::Value
typedef dbyte SerialId
 
enum  SerialIds {
  NONE, NUMBER, TEXT, ARRAY,
  DICTIONARY, BLOCK, FUNCTION, RECORD,
  TIME, URI, ANIMATION
}
 

Detailed Description

References a Variable.

Operations done on a RefValue are actually performed on the variable's value.

Definition at line 34 of file refvalue.h.

Constructor & Destructor Documentation

◆ RefValue()

de::RefValue::RefValue ( Variable variable = 0)

Constructs a new reference to a variable.

Parameters
variableVariable.

Definition at line 26 of file refvalue.cpp.

◆ ~RefValue()

de::RefValue::~RefValue ( )
virtual

Definition at line 34 of file refvalue.cpp.

Member Function Documentation

◆ asNumber()

Value::Number de::RefValue::asNumber ( ) const
virtual

Convert the value to a number.

Implementing this is optional. The default implementation will raise an exception.

Exceptions
ConversionErrorValue cannot be converted to number.

Reimplemented from de::Value.

Definition at line 63 of file refvalue.cpp.

◆ assign()

void de::RefValue::assign ( Value value)
virtual

Assign value.

Only supported by reference values.

Parameters
valueValue to assign. Referenced object gets ownership.
Exceptions
IllegalErrorCannot assign to value.

Reimplemented from de::Value.

Definition at line 158 of file refvalue.cpp.

◆ asText()

Value::Text de::RefValue::asText ( ) const
virtual

Convert the value to into a text string.

All values have to implement this.

Implements de::Value.

Definition at line 68 of file refvalue.cpp.

◆ begin()

Value * de::RefValue::begin ( )
virtual

Begin iteration of contained values.

This is only meaningful with iterable values such as arrays.

Returns
The first value. Caller gets ownership. NULL, if there are no items.
Exceptions
IllegalErrorValue is not iterable.

Reimplemented from de::Value.

Definition at line 103 of file refvalue.cpp.

◆ call()

void de::RefValue::call ( Process process,
Value const &  arguments,
Value self 
) const
virtual

Applies the call operator on the value.

Parameters
processProcess where the call is made.
argumentsArguments of the call.
selfOptional scope that becomes the value of the "self" variable in the called function's local namespace. Ownership taken.
Exceptions
IllegalErrorValue cannot be called.

Reimplemented from de::Value.

Definition at line 164 of file refvalue.cpp.

◆ compare()

dint de::RefValue::compare ( Value const &  value) const
virtual

Compares this value to another.

Parameters
valueValue to compare with.
Returns
0, if the values are equal. 1, if value is greater than this value. -1, if value is less than this value.

Reimplemented from de::Value.

Definition at line 123 of file refvalue.cpp.

◆ contains()

bool de::RefValue::contains ( Value const &  value) const
virtual

Determines whether the value contains the equivalent of another value.

Defined for arrays.

Parameters
valueValue to look for.
Returns
true, if the value is there, otherwise false.
Exceptions
IllegalErrorValue cannot contain other values.

Reimplemented from de::Value.

Definition at line 98 of file refvalue.cpp.

◆ dereference() [1/2]

Value & de::RefValue::dereference ( )

Definition at line 46 of file refvalue.cpp.

◆ dereference() [2/2]

Value const & de::RefValue::dereference ( ) const

Definition at line 52 of file refvalue.cpp.

◆ divide()

void de::RefValue::divide ( Value const &  divisor)
virtual

Calculate the division of this value divided by divisor, storing the result in this value.

Exceptions
ArithmeticErrorValue cannot be divided.

Reimplemented from de::Value.

Definition at line 143 of file refvalue.cpp.

◆ duplicate()

Value * de::RefValue::duplicate ( ) const
virtual

Creates a duplicate copy of the value.

Returns
New Value object. Caller gets ownership of the object.

Implements de::Value.

Definition at line 58 of file refvalue.cpp.

◆ element() [1/2]

Value const & de::RefValue::element ( Value const &  index) const
virtual

Get a specific element of the value.

This is meaningful with arrays and dictionaries.

Parameters
indexIndex of the element.
Returns
Element value (non-modifiable).
Exceptions
IllegalErrorValue cannot be indexed.

Reimplemented from de::Value.

Definition at line 83 of file refvalue.cpp.

◆ element() [2/2]

Value & de::RefValue::element ( Value const &  index)
virtual

Get a specific element of the value.

This is meaningful with arrays and dictionaries.

Parameters
indexIndex of the element.
Returns
Element value (modifiable).
Exceptions
IllegalErrorValue cannot be indexed.

Reimplemented from de::Value.

Definition at line 88 of file refvalue.cpp.

◆ isFalse()

bool de::RefValue::isFalse ( ) const
virtual

Determine if the value can be thought of as a logical falsehood.

Reimplemented from de::Value.

Definition at line 118 of file refvalue.cpp.

◆ isTrue()

bool de::RefValue::isTrue ( ) const
virtual

Determine if the value can be thought of as a logical truth.

Implements de::Value.

Definition at line 113 of file refvalue.cpp.

◆ memberScope()

Record * de::RefValue::memberScope ( ) const
virtual

Returns the scope for any members of this value.

When evaluating a member in reference to this value, this will return the primary scope using which the members can be found.

For built-in types, this may return one of the Script.* records.

Reimplemented from de::Value.

Definition at line 73 of file refvalue.cpp.

◆ modulo()

void de::RefValue::modulo ( Value const &  divisor)
virtual

Calculate the modulo of this value divided by divisor, storing the result in this value.

Exceptions
ArithmeticErrorModule operation is not defined for the value.

Reimplemented from de::Value.

Definition at line 153 of file refvalue.cpp.

◆ multiply()

void de::RefValue::multiply ( Value const &  value)
virtual

Calculate the multiplication of this value by value, storing the result in this value.

Exceptions
ArithmeticErrorValue cannot be multiplied.

Reimplemented from de::Value.

Definition at line 148 of file refvalue.cpp.

◆ negate()

void de::RefValue::negate ( )
virtual

Negate the value of this value.

Exceptions
ArithmeticErrorValue cannot be negated.

Reimplemented from de::Value.

Definition at line 128 of file refvalue.cpp.

◆ next()

Value * de::RefValue::next ( )
virtual

Iterate the next value.

This is only meaningful with iterable values such as arrays.

Returns
NULL, if the iteration is over. Otherwise a new Value containing the next iterated value. Caller gets ownership.
Exceptions
IllegalErrorValue is not iterable.

Reimplemented from de::Value.

Definition at line 108 of file refvalue.cpp.

◆ operator<<()

void de::RefValue::operator<< ( Reader from)
virtual

Restore the object from the provided Reader.

Parameters
fromReader where the data is read from.

Implements de::IReadable.

Definition at line 174 of file refvalue.cpp.

◆ operator>>()

void de::RefValue::operator>> ( Writer to) const
virtual

Serialize the object using the provided Writer.

Parameters
toWriter using which the data is written.

Implements de::IWritable.

Definition at line 169 of file refvalue.cpp.

◆ setElement()

void de::RefValue::setElement ( Value const &  index,
Value elementValue 
)
virtual

Set a specific element of the value.

This is meaningful only with arrays and dictionaries, which are composed out of modifiable elements.

Parameters
indexIndex of the element.
elementValueNew value for the element. This value will take ownership of elementValue.
Exceptions
IllegalErrorValue cannot be indexed.

Reimplemented from de::Value.

Definition at line 93 of file refvalue.cpp.

◆ size()

dsize de::RefValue::size ( ) const
virtual

Determine the size of the value.

The meaning of this depends on the type of the value.

Exceptions
IllegalErrorSize is meaningless.

Reimplemented from de::Value.

Definition at line 78 of file refvalue.cpp.

◆ subtract()

void de::RefValue::subtract ( Value const &  subtrahend)
virtual

Calculate the subtraction of this value and an another value, storing the result in this value.

Exceptions
ArithmeticErrorValue cannot be subtracted from.

Reimplemented from de::Value.

Definition at line 138 of file refvalue.cpp.

◆ sum()

void de::RefValue::sum ( Value const &  value)
virtual

Calculate the sum of this value and an another value, storing the result in this value.

Exceptions
ArithmeticErrorValue cannot be summed.

Reimplemented from de::Value.

Definition at line 133 of file refvalue.cpp.

◆ typeId()

Value::Text de::RefValue::typeId ( ) const
virtual

Returns the type of the value as a text string identifier.

For instance, for a TextValue this would be 'Text'.

Returns
Type identifier.

Implements de::Value.

Definition at line 186 of file refvalue.cpp.

◆ variable()

Variable* de::RefValue::variable ( ) const
inline

Returns the variable this reference points to.

Definition at line 54 of file refvalue.h.

◆ variableBeingDeleted()

void de::RefValue::variableBeingDeleted ( Variable variable)

Definition at line 180 of file refvalue.cpp.

◆ verify()

void de::RefValue::verify ( ) const
Exceptions
NullErrorThe value no longer points to a variable.

Definition at line 37 of file refvalue.cpp.


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