1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2022, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41
42#pragma once
43
44#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
45#include <zlib.h>
46#else
47#include "../contrib/zlib/zlib.h"
48#endif
49
50#include <vector>
51#include <cstddef> // size_t
52
53namespace Assimp {
54
55/// @brief This class provides the decompression of zlib-compressed data.
56class Compression {
57public:
58 static const int MaxWBits = MAX_WBITS;
59
60 /// @brief Describes the format data type
61 enum class Format {
62 InvalidFormat = -1, ///< Invalid enum type.
63 Binary = 0, ///< Binary format.
64 ASCII, ///< ASCII format.
65
66 NumFormats ///< The number of supported formats.
67 };
68
69 /// @brief The supported flush mode, used for blocked access.
70 enum class FlushMode {
71 InvalidFormat = -1, ///< Invalid enum type.
72 NoFlush = 0, ///< No flush, will be done on inflate end.
73 Block, ///< Assists in combination of compress.
74 Tree, ///< Assists in combination of compress and returns if stream is finish.
75 SyncFlush, ///< Synced flush mode.
76 Finish, ///< Finish mode, all in once, no block access.
77
78 NumModes ///< The number of supported modes.
79 };
80
81 /// @brief The class constructor.
82 Compression();
83
84 /// @brief The class destructor.
85 ~Compression();
86
87 /// @brief Will open the access to the compression.
88 /// @param[in] format The format type
89 /// @param[in] flush The flush mode.
90 /// @param[in] windowBits The windows history working size, shall be between 8 and 15.
91 /// @return true if close was successful, false if not.
92 bool open(Format format, FlushMode flush, int windowBits);
93
94 /// @brief Will return the open state.
95 /// @return true if the access is opened, false if not.
96 bool isOpen() const;
97
98 /// @brief Will close the decompress access.
99 /// @return true if close was successful, false if not.
100 bool close();
101
102 /// @brief Will decompress the data buffer in one step.
103 /// @param[in] data The data to decompress
104 /// @param[in] in The size of the data.
105 /// @param[out uncompressed A std::vector containing the decompressed data.
106 size_t decompress(const void *data, size_t in, std::vector<char> &uncompressed);
107
108 /// @brief Will decompress the data buffer block-wise.
109 /// @param[in] data The compressed data
110 /// @param[in] in The size of the data buffer
111 /// @param[out] out The output buffer
112 /// @param[out] availableOut The upper limit of the output buffer.
113 /// @return The size of the decompressed data buffer.
114 size_t decompressBlock(const void *data, size_t in, char *out, size_t availableOut);
115
116private:
117 struct impl;
118 impl *mImpl;
119};
120
121} // namespace Assimp
122

source code of qtquick3d/src/3rdparty/assimp/src/code/Common/Compression.h