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 <o3tl/hash_combine.hxx>
13
15{
16 auto pBuffer = std::make_shared<std::vector<sal_uInt8>>(size);
17 if (stream.ReadBytes(pBuffer->data(), pBuffer->size()) == size)
18 mpData = std::move(pBuffer);
19}
20
22{
23 size_t nSeed = 0;
24 if (mpData)
25 {
27 for (sal_uInt8 const& rByte : *mpData)
28 o3tl::hash_combine(nSeed, rByte);
29 }
30 return nSeed;
31}
32
34{
35 return SvMemoryStream(mpData ? mpData->data() : nullptr, getSize(), StreamMode::READ);
36}
37
38/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvMemoryStream getMemoryStream()
BinaryDataContainer()=default
std::shared_ptr< std::vector< sal_uInt8 > > mpData
size_t calculateHash() const
Reference< XOutputStream > stream
size
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)
unsigned char sal_uInt8