// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "flutter/shell/platform/darwin/common/buffer_conversions.h" namespace flutter { std::vector GetVectorFromNSData(NSData* data) { const uint8_t* bytes = reinterpret_cast(data.bytes); return std::vector(bytes, bytes + data.length); } NSData* GetNSDataFromVector(const std::vector& buffer) { return [NSData dataWithBytes:buffer.data() length:buffer.size()]; } std::unique_ptr GetMappingFromNSData(NSData* data) { return std::make_unique(GetVectorFromNSData(data)); } NSData* GetNSDataFromMapping(std::unique_ptr mapping) { return [NSData dataWithBytes:mapping->GetMapping() length:mapping->GetSize()]; } } // namespace flutter