LibreOffice Module vcl (master)  1
BinaryDataContainer.cxx
Go to the documentation of this file.
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 
12 #include <boost/functional/hash.hpp>
13 
15 
17  : mpData(std::make_shared<std::vector<sal_uInt8>>(nSize))
18 {
19  std::copy(pData, pData + nSize, mpData->data());
20 }
21 
22 BinaryDataContainer::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 
28 {
29  size_t nSeed = 0;
30  boost::hash_combine(nSeed, getSize());
31  for (sal_uInt8 const& rByte : *mpData)
32  boost::hash_combine(nSeed, rByte);
33  return nSeed;
34 }
35 
36 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< T > make_shared(Args &&...args)
constexpr OUStringLiteral aData
size_t calculateHash() const
std::shared_ptr< std::vector< sal_uInt8 > > mpData
unsigned char sal_uInt8