// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_STANDARD_H_ #define MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_STANDARD_H_ #include "mojo/public/cpp/bindings/map.h" #include "mojo/public/cpp/bindings/map_traits.h" namespace mojo { template struct MapTraits> { using Key = K; using Value = V; using Iterator = typename Map::Iterator; using ConstIterator = typename Map::ConstIterator; static bool IsNull(const Map& input) { return input.is_null(); } static void SetToNull(Map* output) { *output = nullptr; } static size_t GetSize(const Map& input) { return input.size(); } static ConstIterator GetBegin(const Map& input) { return input.begin(); } static Iterator GetBegin(Map& input) { return input.begin(); } static void AdvanceIterator(ConstIterator& iterator) { iterator++; } static void AdvanceIterator(Iterator& iterator) { iterator++; } static const K& GetKey(Iterator& iterator) { return iterator->first; } static const K& GetKey(ConstIterator& iterator) { return iterator->first; } static V& GetValue(Iterator& iterator) { return iterator->second; } static const V& GetValue(ConstIterator& iterator) { return iterator->second; } static bool Insert(Map& input, const K& key, V&& value) { input.insert(key, std::forward(value)); return true; } static bool Insert(Map& input, const K& key, const V& value) { input.insert(key, value); return true; } static void SetToEmpty(Map* output) { output->SetToEmpty(); } }; } // namespace mojo #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_TRAITS_STANDARD_H_