1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 */ 10 11 #include <vcl/BinaryDataContainer.hxx> 12 #include <o3tl/hash_combine.hxx> 13 14 BinaryDataContainer::BinaryDataContainer() = default; 15 BinaryDataContainer(const sal_uInt8 * pData,size_t nSize)16BinaryDataContainer::BinaryDataContainer(const sal_uInt8* pData, size_t nSize) 17 : mpData(std::make_shared<std::vector<sal_uInt8>>(nSize)) 18 { 19 std::copy(pData, pData + nSize, mpData->data()); 20 } 21 BinaryDataContainer(std::unique_ptr<std::vector<sal_uInt8>> aData)22BinaryDataContainer::BinaryDataContainer(std::unique_ptr<std::vector<sal_uInt8>> aData) 23 : mpData(std::shared_ptr<std::vector<sal_uInt8>>(aData.release(), aData.get_deleter())) 24 { 25 } 26 calculateHash() const27size_t BinaryDataContainer::calculateHash() const 28 { 29 size_t nSeed = 0; 30 o3tl::hash_combine(nSeed, getSize()); 31 for (sal_uInt8 const& rByte : *mpData) 32 o3tl::hash_combine(nSeed, rByte); 33 return nSeed; 34 } 35 36 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 37