1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
13 #include <sal/config.h>
15 #include <com/sun/star/uno/Sequence.hxx>
16 #include <com/sun/star/io/XInputStream.hpp>
17 #include <unotools/tempfile.hxx>
18 #include <tools/stream.hxx>
19 #include <vcl/dllapi.h>
24 /** Container for the binary data, whose responsibility is to manage the
25 * make it as simple as possible to manage the binary data. The binary
26 * data can be anything, but typically it is a in-memory data from
27 * files (i.e. files of graphic formats).
29 class VCL_DLLPUBLIC BinaryDataContainer final
33 std::shared_ptr
<Impl
> mpImpl
;
35 void ensureSwappedIn() const;
38 BinaryDataContainer() = default;
39 BinaryDataContainer(SvStream
& stream
, size_t size
);
41 BinaryDataContainer(const BinaryDataContainer
& rBinaryDataContainer
) = default;
43 BinaryDataContainer(BinaryDataContainer
&& rBinaryDataContainer
) noexcept
= default;
45 BinaryDataContainer
& operator=(const BinaryDataContainer
& rBinaryDataContainer
) = default;
47 BinaryDataContainer
& operator=(BinaryDataContainer
&& rBinaryDataContainer
) noexcept
= default;
49 size_t getSize() const;
51 const sal_uInt8
* getData() const;
52 css::uno::Sequence
<sal_Int8
> getCopyAsByteSequence() const;
54 // Returns the data as a readonly stream open for reading
55 std::shared_ptr
<SvStream
> getAsStream();
57 // Returns the data as a readonly stream open for reading
58 css::uno::Reference
<css::io::XInputStream
> getAsXInputStream();
60 /// writes the contents to the given stream
61 std::size_t writeToStream(SvStream
& rStream
) const;
63 /// return the in-memory size in bytes as of now.
64 std::size_t getSizeBytes() const;
66 /// swap out to disk for now
69 size_t calculateHash() const;
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */