Stroika Library 3.0d23x
 
Loading...
Searching...
No Matches
ZStd.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_Compression_ZStd_h_
5#define _Stroika_Foundation_DataExchange_Compression_ZStd_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10
11/**
12 * \file
13 *
14 * https://en.wikipedia.org/wiki/Zstd
15 *
16 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
17 */
18
19namespace Stroika::Foundation::DataExchange::Compression::ZStd {
20
21 /**
22 * Check at compile time if ZStd is supported.
23 */
24 constexpr bool kSupported =
25#if qStroika_HasComponent_zstd
26 true
27#else
28 false
29#endif
30 ;
31
32 /**
33 * \par Example Usage
34 * \code
35 * Memory::BLOB kSample1_ = Memory::BLOB::Hex ("aa1234abcd01010102030405");
36 * Memory::BLOB compressed = Compression::ZStd::Compress::New ().Transform (kSample1_);
37 * Assert (kSample1_ == Compression::Compression::ZStd::Decompress::New ().Transform (compressed));
38 * \endcode
39 *
40 * \note if not kSupported, these 'New ()' functions just throw FeatureNotSupportedException{}
41 */
42 namespace Compress {
43 /**
44 * @brief As of Stroika v3.0d22 - options ignored (and no api to train/generate dictionary)
45 *
46 * many other options to consider allowing here
47 */
48 struct Options : Compression::Compress::Options {
49
50 /**
51 * @brief defaults to ZSTD_CStreamInSize
52 */
53 optional<size_t> fInBufSize;
54
55 /**
56 * @brief defaults to ZSTD_CStreamOutSize
57 */
58 optional<size_t> fOutBufSize;
59
60 /**
61 */
62 optional<Memory::BLOB> fDictionary;
63
64 /**
65 * if true, flush after each write (useful for streaming), else ??? define rules for ZSTD_e_flush vs ZSTD_e_continue - NYI
66 */
67 optional<bool> fFlushEachWrite;
68
69 /**
70 */
71 optional<unsigned int> fThreads;
72 };
73 Ptr New (const Options& o = {});
74 }
75 namespace Decompress {
76 /**
77 * @brief As of Stroika v3.0d22 - options ignored
78 */
79 struct Options : Compression::Compress::Options {
80 /**
81 * @brief defaults to ZSTD_DStreamInSize
82 */
83 optional<size_t> fInBufSize;
84
85 /**
86 * @brief defaults to ZSTD_DStreamOutSize
87 */
88 optional<size_t> fOutBufSize;
89
90 /**
91 */
92 optional<Memory::BLOB> fDictionary;
93
94 /**
95 */
96 optional<size_t> fMaxMemory;
97
98 /**
99 */
100 optional<unsigned int> fThreads;
101 };
102 Ptr New (const Options& o = {});
103 }
104
105}
106
107/*
108 ********************************************************************************
109 ***************************** Implementation Details ***************************
110 ********************************************************************************
111 */
112
113#endif /*_Stroika_Foundation_DataExchange_Compression_ZStd_h_*/
As of Stroika v3.0d22 - options ignored (and no api to train/generate dictionary)
Definition ZStd.h:48
optional< size_t > fInBufSize
defaults to ZSTD_CStreamInSize
Definition ZStd.h:53
optional< size_t > fOutBufSize
defaults to ZSTD_CStreamOutSize
Definition ZStd.h:58
optional< size_t > fInBufSize
defaults to ZSTD_DStreamInSize
Definition ZStd.h:83
optional< size_t > fOutBufSize
defaults to ZSTD_DStreamOutSize
Definition ZStd.h:88