@revizly/sharp-libvips-dev 1.0.53 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ // Copyright (c) the JPEG XL Project Authors. All rights reserved.
2
+ //
3
+ // Use of this source code is governed by a BSD-style
4
+ // license that can be found in the LICENSE file.
5
+
6
+ /// @addtogroup libjxl_cpp
7
+ /// @{
8
+ ///
9
+ /// @file decode_cxx.h
10
+ /// @brief C++ header-only helper for @ref decode.h.
11
+ ///
12
+ /// There's no binary library associated with the header since this is a header
13
+ /// only library.
14
+
15
+ #ifndef JXL_DECODE_CXX_H_
16
+ #define JXL_DECODE_CXX_H_
17
+
18
+ #include <jxl/decode.h>
19
+ #include <jxl/memory_manager.h>
20
+
21
+ #include <memory>
22
+
23
+ #ifndef __cplusplus
24
+ #error "This a C++ only header. Use jxl/decode.h from C sources."
25
+ #endif
26
+
27
+ /// Struct to call JxlDecoderDestroy from the JxlDecoderPtr unique_ptr.
28
+ struct JxlDecoderDestroyStruct {
29
+ /// Calls @ref JxlDecoderDestroy() on the passed decoder.
30
+ void operator()(JxlDecoder* decoder) { JxlDecoderDestroy(decoder); }
31
+ };
32
+
33
+ /// std::unique_ptr<> type that calls JxlDecoderDestroy() when releasing the
34
+ /// decoder.
35
+ ///
36
+ /// Use this helper type from C++ sources to ensure the decoder is destroyed and
37
+ /// their internal resources released.
38
+ typedef std::unique_ptr<JxlDecoder, JxlDecoderDestroyStruct> JxlDecoderPtr;
39
+
40
+ /// Creates an instance of JxlDecoder into a JxlDecoderPtr and initializes it.
41
+ ///
42
+ /// This function returns a unique_ptr that will call JxlDecoderDestroy() when
43
+ /// releasing the pointer. See @ref JxlDecoderCreate for details on the
44
+ /// instance creation.
45
+ ///
46
+ /// @param memory_manager custom allocator function. It may be NULL. The memory
47
+ /// manager will be copied internally.
48
+ /// @return a @c NULL JxlDecoderPtr if the instance can not be allocated or
49
+ /// initialized
50
+ /// @return initialized JxlDecoderPtr instance otherwise.
51
+ static inline JxlDecoderPtr JxlDecoderMake(
52
+ const JxlMemoryManager* memory_manager) {
53
+ return JxlDecoderPtr(JxlDecoderCreate(memory_manager));
54
+ }
55
+
56
+ #endif // JXL_DECODE_CXX_H_
57
+
58
+ /// @}