v8  3.28.71 (node 0.12.18)
V8 is Google's open source JavaScript engine
PersistentValueMap< K, V, Traits > Class Template Reference

#include <v8-util.h>

Data Structures

class  PersistentValueReference
 

Public Member Functions

 PersistentValueMap (Isolate *isolate)
 
 ~PersistentValueMap ()
 
IsolateGetIsolate ()
 
size_t Size ()
 
bool IsWeak ()
 
Local< V > Get (const K &key)
 
bool Contains (const K &key)
 
bool SetReturnValue (const K &key, ReturnValue< Value > returnValue)
 
void SetReference (const K &key, const Persistent< Object > &parent)
 
UniquePersistent< V > Set (const K &key, Local< V > value)
 
UniquePersistent< V > Set (const K &key, UniquePersistent< V > value)
 
UniquePersistent< V > Remove (const K &key)
 
void Clear ()
 
PersistentValueReference GetReference (const K &key)
 
UniquePersistent< V > Set (const K &key, UniquePersistent< V > value, PersistentValueReference *reference)
 

Detailed Description

template<typename K, typename V, typename Traits>
class v8::PersistentValueMap< K, V, Traits >

A map wrapper that allows using UniquePersistent as a mapped value. C++11 embedders don't need this class, as they can use UniquePersistent directly in std containers.

The map relies on a backing map, whose type and accessors are described by the Traits class. The backing map will handle values of type PersistentContainerValue, with all conversion into and out of V8 handles being transparently handled by this class.

Definition at line 119 of file v8-util.h.

Constructor & Destructor Documentation

◆ PersistentValueMap()

PersistentValueMap ( Isolate isolate)
inlineexplicit

Definition at line 121 of file v8-util.h.

◆ ~PersistentValueMap()

~PersistentValueMap ( )
inline

Definition at line 123 of file v8-util.h.

References PersistentValueMap< K, V, Traits >::Clear().

Member Function Documentation

◆ Clear()

void Clear ( )
inline

Traverses the map repeatedly, in case side effects of disposal cause insertions.

Definition at line 198 of file v8-util.h.

References HandleScope::HandleScope().

Referenced by PersistentValueMap< K, V, Traits >::~PersistentValueMap().

◆ Contains()

bool Contains ( const K &  key)
inline

Check whether a value is contained in the map.

Definition at line 147 of file v8-util.h.

◆ Get()

Local<V> Get ( const K &  key)
inline

Get value stored in map.

Definition at line 140 of file v8-util.h.

References Handle< T >::Local.

◆ GetIsolate()

Isolate* GetIsolate ( )
inline

Definition at line 125 of file v8-util.h.

Referenced by PersistentValueMap< K, V, Traits >::SetReference().

◆ GetReference()

PersistentValueReference GetReference ( const K &  key)
inline

Get a reference to a map value. This enables fast, repeated access to a value stored in the map while the map remains unchanged.

Careful: This is potentially unsafe, so please use with care. The value will become invalid if the value for this key changes in the underlying map, as a result of Set or Remove for the same key; as a result of the weak callback for the same key; or as a result of calling Clear() or destruction of the map.

Definition at line 262 of file v8-util.h.

◆ IsWeak()

bool IsWeak ( )
inline

Return whether the map holds weak persistents.

Definition at line 135 of file v8-util.h.

References v8::kNotWeak.

◆ Remove()

UniquePersistent<V> Remove ( const K &  key)
inline

Return value for key and remove it from the map.

Definition at line 190 of file v8-util.h.

◆ Set() [1/3]

UniquePersistent<V> Set ( const K &  key,
Local< V >  value 
)
inline

Put value into map. Depending on Traits::kIsWeak, the value will be held by the map strongly or weakly. Returns old value as UniquePersistent.

Definition at line 175 of file v8-util.h.

References PersistentBase< T >::UniquePersistent.

◆ Set() [2/3]

UniquePersistent<V> Set ( const K &  key,
UniquePersistent< V >  value 
)
inline

Put value into map, like Set(const K&, Local<V>).

Definition at line 183 of file v8-util.h.

◆ Set() [3/3]

UniquePersistent<V> Set ( const K &  key,
UniquePersistent< V >  value,
PersistentValueReference reference 
)
inline

Put a value into the map and update the reference. Restrictions of GetReference apply here as well.

Definition at line 270 of file v8-util.h.

◆ SetReference()

void SetReference ( const K &  key,
const Persistent< Object > &  parent 
)
inline

Call Isolate::SetReference with the given parent and the map value.

Definition at line 163 of file v8-util.h.

References PersistentValueMap< K, V, Traits >::GetIsolate().

◆ SetReturnValue()

bool SetReturnValue ( const K &  key,
ReturnValue< Value returnValue 
)
inline

Get value stored in map and set it in returnValue. Return true if a value was found.

Definition at line 155 of file v8-util.h.

◆ Size()

size_t Size ( )
inline

Return size of the map.

Definition at line 130 of file v8-util.h.


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