V8 Project
v8::StdMapTraits< K, V > Class Template Reference

A default trait implemenation for PersistentValueMap which uses std::map as a backing map. More...

#include <v8-util.h>

+ Inheritance diagram for v8::StdMapTraits< K, V >:
+ Collaboration diagram for v8::StdMapTraits< K, V >:

Public Types

typedef std::map< K, PersistentContainerValueImpl
 
typedef Impl::iterator Iterator
 

Static Public Member Functions

static bool Empty (Impl *impl)
 
static size_t Size (Impl *impl)
 
static void Swap (Impl &a, Impl &b)
 
static Iterator Begin (Impl *impl)
 
static Iterator End (Impl *impl)
 
static K Key (Iterator it)
 
static PersistentContainerValue Value (Iterator it)
 
static PersistentContainerValue Set (Impl *impl, K key, PersistentContainerValue value)
 
static PersistentContainerValue Get (Impl *impl, K key)
 
static PersistentContainerValue Remove (Impl *impl, K key)
 

Detailed Description

template<typename K, typename V>
class v8::StdMapTraits< K, V >

A default trait implemenation for PersistentValueMap which uses std::map as a backing map.

Users will have to implement their own weak callbacks & dispose traits.

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

Member Typedef Documentation

◆ Impl

template<typename K , typename V >
typedef std::map<K, PersistentContainerValue> v8::StdMapTraits< K, V >::Impl

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

◆ Iterator

template<typename K , typename V >
typedef Impl::iterator v8::StdMapTraits< K, V >::Iterator

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

Member Function Documentation

◆ Begin()

template<typename K , typename V >
static Iterator v8::StdMapTraits< K, V >::Begin ( Impl impl)
inlinestatic

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

45 { return impl->begin(); }

◆ Empty()

template<typename K , typename V >
static bool v8::StdMapTraits< K, V >::Empty ( Impl impl)
inlinestatic

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

42 { return impl->empty(); }

◆ End()

template<typename K , typename V >
static Iterator v8::StdMapTraits< K, V >::End ( Impl impl)
inlinestatic

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

46 { return impl->end(); }

◆ Get()

template<typename K , typename V >
static PersistentContainerValue v8::StdMapTraits< K, V >::Get ( Impl impl,
key 
)
inlinestatic

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

59  {
60  Iterator it = impl->find(key);
61  if (it == impl->end()) return kPersistentContainerNotFound;
62  return it->second;
63  }
Impl::iterator Iterator
Definition: v8-util.h:40
static const uintptr_t kPersistentContainerNotFound
Definition: v8-util.h:22

References v8::kPersistentContainerNotFound.

◆ Key()

template<typename K , typename V >
static K v8::StdMapTraits< K, V >::Key ( Iterator  it)
inlinestatic

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

47 { return it->first; }

◆ Remove()

template<typename K , typename V >
static PersistentContainerValue v8::StdMapTraits< K, V >::Remove ( Impl impl,
key 
)
inlinestatic

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

64  {
65  Iterator it = impl->find(key);
66  if (it == impl->end()) return kPersistentContainerNotFound;
67  PersistentContainerValue value = it->second;
68  impl->erase(it);
69  return value;
70  }
uintptr_t PersistentContainerValue
Definition: v8-util.h:21

References v8::kPersistentContainerNotFound.

◆ Set()

template<typename K , typename V >
static PersistentContainerValue v8::StdMapTraits< K, V >::Set ( Impl impl,
key,
PersistentContainerValue  value 
)
inlinestatic

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

50  {
51  std::pair<Iterator, bool> res = impl->insert(std::make_pair(key, value));
53  if (!res.second) {
54  old_value = res.first->second;
55  res.first->second = value;
56  }
57  return old_value;
58  }

References v8::kPersistentContainerNotFound.

◆ Size()

template<typename K , typename V >
static size_t v8::StdMapTraits< K, V >::Size ( Impl impl)
inlinestatic

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

43 { return impl->size(); }

◆ Swap()

template<typename K , typename V >
static void v8::StdMapTraits< K, V >::Swap ( Impl a,
Impl b 
)
inlinestatic

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

44 { std::swap(a, b); } // NOLINT

◆ Value()

template<typename K , typename V >
static PersistentContainerValue v8::StdMapTraits< K, V >::Value ( Iterator  it)
inlinestatic

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

48 { return it->second; }

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