Coverage Report

Created: 2025-12-08 09:28

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