Implement map key exists in mgp (#1336)

This commit is contained in:
Matija Pintarić
2023-10-23 15:29:41 +02:00
committed by GitHub
parent aec4c3dd2b
commit 97ed912ab6
5 changed files with 31 additions and 0 deletions

View File

@@ -630,6 +630,9 @@ class Map {
/// @brief Returns the value at the given `key`.
Value const At(std::string_view key) const;
/// @brief Returns true if the given `key` exists.
bool KeyExists(std::string_view key) const;
class Iterator {
public:
friend class Map;
@@ -2573,6 +2576,8 @@ inline const Value Map::At(std::string_view key) const {
return Value();
}
inline bool Map::KeyExists(std::string_view key) const { return mgp::key_exists(ptr_, key.data()); }
inline Map::Iterator::Iterator(mgp_map_items_iterator *map_items_iterator) : map_items_iterator_(map_items_iterator) {
if (map_items_iterator_ == nullptr) return;
if (mgp::map_items_iterator_get(map_items_iterator_) == nullptr) {