LibreOffice Module vcl (master) 1
BinaryDataContainer.hxx
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
11#pragma once
12
13#include <vcl/dllapi.h>
14#include <vector>
15#include <memory>
16
23{
24private:
25 // the binary data
26 std::shared_ptr<std::vector<sal_uInt8>> mpData;
27
28public:
30 BinaryDataContainer(const sal_uInt8* pData, size_t nSize);
31 BinaryDataContainer(std::unique_ptr<std::vector<sal_uInt8>> rData);
32
33 BinaryDataContainer(const BinaryDataContainer& rBinaryDataContainer)
34 : mpData(rBinaryDataContainer.mpData)
35 {
36 }
37
38 BinaryDataContainer(BinaryDataContainer&& rBinaryDataContainer) noexcept
39 : mpData(std::move(rBinaryDataContainer.mpData))
40 {
41 }
42
44 {
45 mpData = rBinaryDataContainer.mpData;
46 return *this;
47 }
48
49 BinaryDataContainer& operator=(BinaryDataContainer&& rBinaryDataContainer) noexcept
50 {
51 mpData = std::move(rBinaryDataContainer.mpData);
52 return *this;
53 }
54
55 size_t getSize() const { return mpData ? mpData->size() : 0; }
56 bool isEmpty() const { return !mpData || mpData->empty(); }
57 const sal_uInt8* getData() const { return mpData ? mpData->data() : nullptr; }
58
59 size_t calculateHash() const;
60
61 auto cbegin() const { return mpData->cbegin(); }
62
63 auto cend() const { return mpData->cend(); }
64};
65
66/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
std::shared_ptr< std::vector< sal_uInt8 > > mpData
BinaryDataContainer & operator=(const BinaryDataContainer &rBinaryDataContainer)
BinaryDataContainer(const BinaryDataContainer &rBinaryDataContainer)
BinaryDataContainer & operator=(BinaryDataContainer &&rBinaryDataContainer) noexcept
BinaryDataContainer(BinaryDataContainer &&rBinaryDataContainer) noexcept
const sal_uInt8 * getData() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
unsigned char sal_uInt8