MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / Map

Class Map

crates/c-api/include/wasmtime/component/val.hh:446–475  ·  view source on GitHub ↗

\brief Class representing a component model map, a collection of key/value pairs.

Source from the content-addressed store, hash-verified

444/// \brief Class representing a component model map, a collection of key/value
445/// pairs.
446class Map {
447 friend class Val;
448
449 VAL_REPR(Map, wasmtime_component_valmap_t);
450
451 static void transfer(Raw &&from, Raw &to) {
452 to = from;
453 from.size = 0;
454 from.data = nullptr;
455 }
456
457 void copy(const Raw &other) { wasmtime_component_valmap_copy(&raw, &other); }
458
459 void destroy() { wasmtime_component_valmap_delete(&raw); }
460
461public:
462 /// Creates a new map from the key/value pairs provided.
463 Map(std::vector<std::pair<Val, Val>> entries);
464
465 /// \brief Returns the number of entries in the map.
466 size_t size() const { return raw.size; }
467
468 /// \brief Returns an iterator to the beginning of the map entries.
469 const MapEntry *begin() const { return MapEntry::from_capi(raw.data); }
470
471 /// \brief Returns an iterator to the end of the map entries.
472 const MapEntry *end() const {
473 return MapEntry::from_capi(raw.data + raw.size);
474 }
475};
476
477class ResourceHost;
478

Callers 2

fromMethod · 0.50
fromMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected