bump product version to 7.6.3.2-android
[LibreOffice.git] / include / vcl / BinaryDataContainer.hxx
blob72bd852281ce25c22cf97891e204bb505a5d9d38
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
11 #pragma once
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>
21 #include <vector>
22 #include <memory>
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
31 struct Impl;
33 std::shared_ptr<Impl> mpImpl;
35 void ensureSwappedIn() const;
37 public:
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;
50 bool isEmpty() 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
67 void swapOut() const;
69 size_t calculateHash() const;
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */