\brief Class representing a component model map, a collection of key/value pairs.
| 444 | /// \brief Class representing a component model map, a collection of key/value |
| 445 | /// pairs. |
| 446 | class 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 | |
| 461 | public: |
| 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 | |
| 477 | class ResourceHost; |
| 478 |