Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/BinaryDataContainer.hxx
Line
Count
Source
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 <sal/config.h>
14
15
#include <vcl/dllapi.h>
16
17
#include <memory>
18
#include <vector>
19
20
class SvStream;
21
namespace com::sun::star::io
22
{
23
class XInputStream;
24
}
25
namespace com::sun::star::uno
26
{
27
template <class E> class Sequence;
28
}
29
namespace com::sun::star::uno
30
{
31
template <class interface_type> class Reference;
32
}
33
34
/** Container for the binary data, whose responsibility is to manage the
35
 *  make it as simple as possible to manage the binary data. The binary
36
 *  data can be anything, but typically it is a in-memory data from
37
 *  files (i.e. files of graphic formats).
38
 */
39
class VCL_DLLPUBLIC BinaryDataContainer final
40
{
41
    struct Impl;
42
43
    std::shared_ptr<Impl> mpImpl;
44
45
    SAL_DLLPRIVATE void ensureSwappedIn() const;
46
47
public:
48
58.0k
    BinaryDataContainer() = default;
49
    BinaryDataContainer(SvStream& stream, size_t size);
50
51
70.5k
    BinaryDataContainer(const BinaryDataContainer& rBinaryDataContainer) = default;
52
93.4k
    BinaryDataContainer(BinaryDataContainer&& rBinaryDataContainer) noexcept = default;
53
0
    BinaryDataContainer& operator=(const BinaryDataContainer& rBinaryDataContainer) = default;
54
48.6k
    BinaryDataContainer& operator=(BinaryDataContainer&& rBinaryDataContainer) noexcept = default;
55
56
    size_t getSize() const;
57
    bool isEmpty() const;
58
    const sal_uInt8* getData() const;
59
    SAL_DLLPRIVATE css::uno::Sequence<sal_Int8> getCopyAsByteSequence() const;
60
61
    // Returns the data as a readonly stream open for reading
62
    SAL_DLLPRIVATE std::unique_ptr<SvStream> getAsStream() const;
63
64
    // Returns the data as a readonly stream open for reading
65
    SAL_DLLPRIVATE css::uno::Reference<css::io::XInputStream> getAsXInputStream() const;
66
67
    /// writes the contents to the given stream
68
    std::size_t writeToStream(SvStream& rStream) const;
69
70
    /// return the in-memory size in bytes as of now.
71
    SAL_DLLPRIVATE std::size_t getSizeBytes() const;
72
73
    /// swap out to disk for now
74
    SAL_DLLPRIVATE void swapOut() const;
75
76
    SAL_DLLPRIVATE size_t calculateHash() const;
77
    std::vector<unsigned char> calculateSHA1() const;
78
};
79
80
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */