/src/libheif/libheif/error.h
Line | Count | Source |
1 | | /* |
2 | | * HEIF codec. |
3 | | * Copyright (c) 2017 Dirk Farin <dirk.farin@gmail.com> |
4 | | * |
5 | | * This file is part of libheif. |
6 | | * |
7 | | * libheif is free software: you can redistribute it and/or modify |
8 | | * it under the terms of the GNU Lesser General Public License as |
9 | | * published by the Free Software Foundation, either version 3 of |
10 | | * the License, or (at your option) any later version. |
11 | | * |
12 | | * libheif is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | * GNU Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public License |
18 | | * along with libheif. If not, see <http://www.gnu.org/licenses/>. |
19 | | */ |
20 | | |
21 | | #ifndef LIBHEIF_ERROR_H |
22 | | #define LIBHEIF_ERROR_H |
23 | | |
24 | | #include <cinttypes> |
25 | | #include <cstddef> |
26 | | |
27 | | #include <vector> |
28 | | #include <string> |
29 | | #include <memory> |
30 | | #include <limits> |
31 | | #include <istream> |
32 | | #include <ostream> |
33 | | #include <sstream> |
34 | | |
35 | | #include "libheif/heif.h" |
36 | | #include <cassert> |
37 | | #include <variant> |
38 | | #include <utility> |
39 | | |
40 | | |
41 | | extern const heif_error heif_error_null_pointer_argument; |
42 | | |
43 | | // Predefined errors with string-literal messages (static storage, no allocation). |
44 | | // Safe to return from a std::bad_alloc handler, where the allocator must not be used. |
45 | | extern const heif_error heif_error_out_of_memory; |
46 | | extern const heif_error heif_error_internal_exception; |
47 | | |
48 | | |
49 | | class ErrorBuffer |
50 | | { |
51 | | public: |
52 | 87.2k | ErrorBuffer() = default; |
53 | | |
54 | | void set_success() |
55 | 40.9k | { |
56 | 40.9k | m_error_message = c_success; |
57 | 40.9k | } |
58 | | |
59 | | void set_error(const std::string& err) |
60 | 17.9k | { |
61 | 17.9k | m_buffer = err; |
62 | 17.9k | m_error_message = m_buffer.c_str(); |
63 | 17.9k | } |
64 | | |
65 | | const char* get_error() const |
66 | 58.8k | { |
67 | 58.8k | return m_error_message; |
68 | 58.8k | } |
69 | | |
70 | | private: |
71 | | constexpr static const char* c_success = "Success"; |
72 | | std::string m_buffer; |
73 | | const char* m_error_message = c_success; |
74 | | }; |
75 | | |
76 | | |
77 | | // The clang static analyzer reports a garbage value assigned in the implicit copy constructor |
78 | | // when an Error is copied out of the std::variant inside Result<T>. All members have default |
79 | | // initializers, so this is a false positive of its variant modeling. |
80 | | class Error // NOLINT(clang-analyzer-core.uninitialized.Assign) |
81 | | { |
82 | | public: |
83 | | heif_error_code error_code = heif_error_Ok; |
84 | | heif_suberror_code sub_error_code = heif_suberror_Unspecified; |
85 | | std::string message; |
86 | | |
87 | | Error(); |
88 | | |
89 | | Error(heif_error_code c, |
90 | | heif_suberror_code sc = heif_suberror_Unspecified, |
91 | | const std::string& msg = ""); |
92 | | |
93 | | static Error from_heif_error(const heif_error&); |
94 | | |
95 | | static const Error Ok; |
96 | | |
97 | | static const Error InternalError; |
98 | | |
99 | | static const char kSuccess[]; |
100 | | |
101 | 635k | bool operator==(const Error& other) const { return error_code == other.error_code; } |
102 | | |
103 | 301k | bool operator!=(const Error& other) const { return !(*this == other); } |
104 | | |
105 | 4.03k | Error operator||(const Error& other) const { |
106 | 4.03k | if (error_code != heif_error_Ok) { |
107 | 0 | return *this; |
108 | 0 | } |
109 | 4.03k | else { |
110 | 4.03k | return other; |
111 | 4.03k | } |
112 | 4.03k | } |
113 | | |
114 | | // 'explicit' so that an Error can only be tested in a boolean context (if/!/&&/...). |
115 | | // Without it, `int x = err;` or `return err;` from an int function silently compile |
116 | | // and yield 0/1 instead of the intended value. |
117 | 16.5M | explicit operator bool() const { return error_code != heif_error_Ok; } |
118 | | |
119 | | static const char* get_error_string(heif_error_code err); |
120 | | |
121 | | static const char* get_error_string(heif_suberror_code err); |
122 | | |
123 | | heif_error error_struct(ErrorBuffer* error_buffer) const; |
124 | | }; |
125 | | |
126 | | |
127 | | inline std::ostream& operator<<(std::ostream& ostr, const Error& err) |
128 | 0 | { |
129 | 0 | ostr << err.error_code << "/" << err.sub_error_code; |
130 | 0 | return ostr; |
131 | 0 | } |
132 | | |
133 | | |
134 | | template <typename T> class Result |
135 | | { |
136 | | public: |
137 | 77.5k | Result() = default; Result<std::__1::shared_ptr<HeifPixelImage> >::Result() Line | Count | Source | 137 | 77.5k | Result() = default; |
Unexecuted instantiation: Result<Encoder::CodedImageData>::Result() Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_uncompressed> >::Result() Unexecuted instantiation: Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::Result() Unexecuted instantiation: Result<bool>::Result() |
138 | | |
139 | 529k | Result(T v) : m_data(std::move(v)) {}Unexecuted instantiation: Result<std::__1::shared_ptr<Box_udes> >::Result(std::__1::shared_ptr<Box_udes>) Result<std::__1::shared_ptr<Box_imir> >::Result(std::__1::shared_ptr<Box_imir>) Line | Count | Source | 139 | 243 | Result(T v) : m_data(std::move(v)) {} |
Result<std::__1::shared_ptr<Box_irot> >::Result(std::__1::shared_ptr<Box_irot>) Line | Count | Source | 139 | 43 | Result(T v) : m_data(std::move(v)) {} |
Result<std::__1::shared_ptr<Box_clap> >::Result(std::__1::shared_ptr<Box_clap>) Line | Count | Source | 139 | 143 | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_other> >::Result(std::__1::shared_ptr<Box_other>) Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::Result(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >) Line | Count | Source | 139 | 83.2k | Result(T v) : m_data(std::move(v)) {} |
Result<std::__1::shared_ptr<HeifPixelImage> >::Result(std::__1::shared_ptr<HeifPixelImage>) Line | Count | Source | 139 | 93.1k | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > > >::Result(std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > >) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Grid> >::Result(std::__1::shared_ptr<ImageItem_Grid>) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Overlay> >::Result(std::__1::shared_ptr<ImageItem_Overlay>) Unexecuted instantiation: Result<unsigned long>::Result(unsigned long) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Tiled> >::Result(std::__1::shared_ptr<ImageItem_Tiled>) Unexecuted instantiation: Result<DataExtent>::Result(DataExtent) Unexecuted instantiation: Result<std::__1::shared_ptr<HeifPixelImage const> >::Result(std::__1::shared_ptr<HeifPixelImage const>) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_uncompressed> >::Result(std::__1::shared_ptr<ImageItem_uncompressed>) Result<std::__1::shared_ptr<Decoder> >::Result(std::__1::shared_ptr<Decoder>) Line | Count | Source | 139 | 279k | Result(T v) : m_data(std::move(v)) {} |
Result<std::__1::optional<ImageSize> >::Result(std::__1::optional<ImageSize>) Line | Count | Source | 139 | 31.1k | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<Encoder::CodedImageData>::Result(Encoder::CodedImageData) Result<std::__1::unique_ptr<unc_decoder, std::__1::default_delete<unc_decoder> > >::Result(std::__1::unique_ptr<unc_decoder, std::__1::default_delete<unc_decoder> >) Line | Count | Source | 139 | 1.06k | Result(T v) : m_data(std::move(v)) {} |
Result<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >::Result(std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >) Line | Count | Source | 139 | 1.06k | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<std::__1::unique_ptr<unc_encoder const, std::__1::default_delete<unc_encoder const> > >::Result(std::__1::unique_ptr<unc_encoder const, std::__1::default_delete<unc_encoder const> >) Result<Fraction>::Result(Fraction) Line | Count | Source | 139 | 1.92k | Result(T v) : m_data(std::move(v)) {} |
Result<Box_clap::Crop>::Result(Box_clap::Crop) Line | Count | Source | 139 | 143 | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<heif_tai_timestamp_packet>::Result(heif_tai_timestamp_packet) Unexecuted instantiation: Result<std::__1::shared_ptr<RegionItem> >::Result(std::__1::shared_ptr<RegionItem>) Result<unsigned int>::Result(unsigned int) Line | Count | Source | 139 | 3.08k | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem> >::Result(std::__1::shared_ptr<ImageItem>) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_elng> >::Result(std::__1::shared_ptr<Box_elng>) Unexecuted instantiation: Result<std::__1::shared_ptr<Track> >::Result(std::__1::shared_ptr<Track>) Unexecuted instantiation: Result<std::__1::shared_ptr<Track const> >::Result(std::__1::shared_ptr<Track const>) Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Visual> >::Result(std::__1::shared_ptr<Track_Visual>) Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Metadata> >::Result(std::__1::shared_ptr<Track_Metadata>) Unexecuted instantiation: Result<std::__1::shared_ptr<TextItem> >::Result(std::__1::shared_ptr<TextItem>) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_infe> >::Result(std::__1::shared_ptr<Box_infe>) Unexecuted instantiation: Result<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Result(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) Unexecuted instantiation: Result<RegionCoordinateTransform>::Result(RegionCoordinateTransform) Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*>::Result(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) Line | Count | Source | 139 | 34.0k | Result(T v) : m_data(std::move(v)) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<SEIMessage> >::Result(std::__1::shared_ptr<SEIMessage>) Unexecuted instantiation: Result<heif_raw_sequence_sample*>::Result(heif_raw_sequence_sample*) Unexecuted instantiation: Result<bool>::Result(bool) |
140 | | |
141 | 103k | Result(const Error& e) : m_data(e) {}Unexecuted instantiation: Result<std::__1::shared_ptr<Box_udes> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_imir> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_irot> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_clap> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_other> >::Result(Error const&) Result<std::__1::shared_ptr<Decoder> >::Result(Error const&) Line | Count | Source | 141 | 4.78k | Result(const Error& e) : m_data(e) {} |
Result<std::__1::shared_ptr<HeifPixelImage> >::Result(Error const&) Line | Count | Source | 141 | 71.2k | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<Encoder::CodedImageData>::Result(Error const&) Unexecuted instantiation: Result<std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > > >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Grid> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Overlay> >::Result(Error const&) Unexecuted instantiation: Result<unsigned long>::Result(Error const&) Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::Result(Error const&) Line | Count | Source | 141 | 15.3k | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Tiled> >::Result(Error const&) Unexecuted instantiation: Result<DataExtent>::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<HeifPixelImage const> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_uncompressed> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::unique_ptr<unc_decoder, std::__1::default_delete<unc_decoder> > >::Result(Error const&) Unexecuted instantiation: Result<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >::Result(Error const&) Unexecuted instantiation: Result<std::__1::unique_ptr<unc_encoder const, std::__1::default_delete<unc_encoder const> > >::Result(Error const&) Result<Fraction>::Result(Error const&) Line | Count | Source | 141 | 250 | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<Box_clap::Crop>::Result(Error const&) Unexecuted instantiation: Result<heif_tai_timestamp_packet>::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<RegionItem> >::Result(Error const&) Result<unsigned int>::Result(Error const&) Line | Count | Source | 141 | 323 | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_elng> >::Result(Error const&) Result<std::__1::shared_ptr<Track> >::Result(Error const&) Line | Count | Source | 141 | 7 | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<Track const> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<TextItem> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::shared_ptr<Box_infe> >::Result(Error const&) Unexecuted instantiation: Result<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Result(Error const&) Unexecuted instantiation: Result<RegionCoordinateTransform>::Result(Error const&) Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*>::Result(Error const&) Line | Count | Source | 141 | 11.9k | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<std::__1::shared_ptr<SEIMessage> >::Result(Error const&) Result<std::__1::optional<ImageSize> >::Result(Error const&) Line | Count | Source | 141 | 194 | Result(const Error& e) : m_data(e) {} |
Unexecuted instantiation: Result<heif_raw_sequence_sample*>::Result(Error const&) Unexecuted instantiation: Result<bool>::Result(Error const&) |
142 | | |
143 | | // True if the Result holds a value, false if it holds an error. |
144 | | // 'explicit' so that the value can only be extracted with operator*: `id = result;` must |
145 | | // not compile, because it would store the boolean (this bug shipped several times, see |
146 | | // https://github.com/strukturag/libheif/pull/1885). |
147 | 1.35M | explicit operator bool() const { return std::holds_alternative<T>(m_data); }Result<std::__1::shared_ptr<HeifPixelImage> >::operator bool() const Line | Count | Source | 147 | 343k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_udes> >::operator bool() const Result<unsigned int>::operator bool() const Line | Count | Source | 147 | 3.25k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<std::__1::shared_ptr<Box_imir> >::operator bool() const Line | Count | Source | 147 | 486 | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<std::__1::shared_ptr<Box_irot> >::operator bool() const Line | Count | Source | 147 | 86 | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<std::__1::shared_ptr<Box_clap> >::operator bool() const Line | Count | Source | 147 | 286 | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<Box_clap::Crop>::operator bool() const Line | Count | Source | 147 | 715 | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_other> >::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem> >::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Overlay> >::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Grid> >::operator bool() const Unexecuted instantiation: Result<Encoder::CodedImageData>::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<Box_infe> >::operator bool() const Result<std::__1::shared_ptr<Decoder> >::operator bool() const Line | Count | Source | 147 | 564k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > > >::operator bool() const Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::operator bool() const Line | Count | Source | 147 | 236k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<unsigned long>::operator bool() const Unexecuted instantiation: Result<DataExtent>::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<HeifPixelImage const> >::operator bool() const Unexecuted instantiation: Result<std::__1::unique_ptr<unc_encoder const, std::__1::default_delete<unc_encoder const> > >::operator bool() const Result<std::__1::unique_ptr<unc_decoder, std::__1::default_delete<unc_decoder> > >::operator bool() const Line | Count | Source | 147 | 2.12k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >::operator bool() const Line | Count | Source | 147 | 1.06k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*>::operator bool() const Line | Count | Source | 147 | 124k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Result<Fraction>::operator bool() const Line | Count | Source | 147 | 3.61k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_elng> >::operator bool() const Result<std::__1::shared_ptr<Track> >::operator bool() const Line | Count | Source | 147 | 14 | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Track const> >::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_uncompressed> >::operator bool() const Result<std::__1::optional<ImageSize> >::operator bool() const Line | Count | Source | 147 | 71.0k | explicit operator bool() const { return std::holds_alternative<T>(m_data); } |
Unexecuted instantiation: Result<std::__1::shared_ptr<SEIMessage> >::operator bool() const Unexecuted instantiation: Result<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator bool() const Unexecuted instantiation: Result<heif_tai_timestamp_packet>::operator bool() const Unexecuted instantiation: Result<bool>::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Visual> >::operator bool() const Unexecuted instantiation: Result<heif_raw_sequence_sample*>::operator bool() const Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Metadata> >::operator bool() const |
148 | | |
149 | | //void set(const T& v) { m_data = v; } |
150 | | |
151 | | // Pointer-like access for `r->member` |
152 | | T* operator->() |
153 | 92.6k | { |
154 | 92.6k | assert(*this); // Uses the operator bool() above |
155 | 92.5k | return &std::get<T>(m_data); |
156 | 92.6k | } Result<Box_clap::Crop>::operator->() Line | Count | Source | 153 | 572 | { | 154 | 572 | assert(*this); // Uses the operator bool() above | 155 | 572 | return &std::get<T>(m_data); | 156 | 572 | } |
Unexecuted instantiation: Result<Encoder::CodedImageData>::operator->() Unexecuted instantiation: Result<std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > > >::operator->() Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::operator->() Line | Count | Source | 153 | 60.9k | { | 154 | 60.9k | assert(*this); // Uses the operator bool() above | 155 | 60.9k | return &std::get<T>(m_data); | 156 | 60.9k | } |
Result<std::__1::optional<ImageSize> >::operator->() Line | Count | Source | 153 | 31.0k | { | 154 | 31.0k | assert(*this); // Uses the operator bool() above | 155 | 31.0k | return &std::get<T>(m_data); | 156 | 31.0k | } |
|
157 | | |
158 | | // Dereference access for `*r` |
159 | | T& operator*() |
160 | 557k | { |
161 | 557k | assert(*this); |
162 | 557k | return std::get<T>(m_data); |
163 | 557k | } Result<std::__1::shared_ptr<HeifPixelImage> >::operator*() Line | Count | Source | 160 | 100k | { | 161 | 100k | assert(*this); | 162 | 100k | return std::get<T>(m_data); | 163 | 100k | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_udes> >::operator*() Result<unsigned int>::operator*() Line | Count | Source | 160 | 3.08k | { | 161 | 3.08k | assert(*this); | 162 | 3.08k | return std::get<T>(m_data); | 163 | 3.08k | } |
Result<std::__1::shared_ptr<Box_imir> >::operator*() Line | Count | Source | 160 | 243 | { | 161 | 243 | assert(*this); | 162 | 243 | return std::get<T>(m_data); | 163 | 243 | } |
Result<std::__1::shared_ptr<Box_irot> >::operator*() Line | Count | Source | 160 | 43 | { | 161 | 43 | assert(*this); | 162 | 43 | return std::get<T>(m_data); | 163 | 43 | } |
Result<std::__1::shared_ptr<Box_clap> >::operator*() Line | Count | Source | 160 | 143 | { | 161 | 143 | assert(*this); | 162 | 143 | return std::get<T>(m_data); | 163 | 143 | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_other> >::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem> >::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Overlay> >::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Grid> >::operator*() Unexecuted instantiation: Result<Encoder::CodedImageData>::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<Box_infe> >::operator*() Result<std::__1::shared_ptr<Decoder> >::operator*() Line | Count | Source | 160 | 279k | { | 161 | 279k | assert(*this); | 162 | 279k | return std::get<T>(m_data); | 163 | 279k | } |
Unexecuted instantiation: Result<std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > > >::operator*() Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::operator*() Line | Count | Source | 160 | 62.9k | { | 161 | 62.9k | assert(*this); | 162 | 62.9k | return std::get<T>(m_data); | 163 | 62.9k | } |
Unexecuted instantiation: Result<unsigned long>::operator*() Unexecuted instantiation: Result<DataExtent>::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<HeifPixelImage const> >::operator*() Unexecuted instantiation: Result<std::__1::unique_ptr<unc_encoder const, std::__1::default_delete<unc_encoder const> > >::operator*() Result<std::__1::unique_ptr<unc_decoder, std::__1::default_delete<unc_decoder> > >::operator*() Line | Count | Source | 160 | 1.06k | { | 161 | 1.06k | assert(*this); | 162 | 1.06k | return std::get<T>(m_data); | 163 | 1.06k | } |
Result<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >::operator*() Line | Count | Source | 160 | 1.06k | { | 161 | 1.06k | assert(*this); | 162 | 1.06k | return std::get<T>(m_data); | 163 | 1.06k | } |
Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*>::operator*() Line | Count | Source | 160 | 67.0k | { | 161 | 67.0k | assert(*this); | 162 | 67.0k | return std::get<T>(m_data); | 163 | 67.0k | } |
Result<Fraction>::operator*() Line | Count | Source | 160 | 1.53k | { | 161 | 1.53k | assert(*this); | 162 | 1.53k | return std::get<T>(m_data); | 163 | 1.53k | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Track> >::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<Track const> >::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_uncompressed> >::operator*() Result<std::__1::optional<ImageSize> >::operator*() Line | Count | Source | 160 | 39.9k | { | 161 | 39.9k | assert(*this); | 162 | 39.9k | return std::get<T>(m_data); | 163 | 39.9k | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<SEIMessage> >::operator*() Unexecuted instantiation: Result<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator*() Unexecuted instantiation: Result<heif_tai_timestamp_packet>::operator*() Unexecuted instantiation: Result<bool>::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Visual> >::operator*() Unexecuted instantiation: Result<heif_raw_sequence_sample*>::operator*() Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Metadata> >::operator*() |
164 | | |
165 | 35.7k | [[nodiscard]] bool is_error() const { |
166 | 35.7k | return std::holds_alternative<Error>(m_data); |
167 | 35.7k | } Result<unsigned int>::is_error() const Line | Count | Source | 165 | 3.41k | [[nodiscard]] bool is_error() const { | 166 | 3.41k | return std::holds_alternative<Error>(m_data); | 167 | 3.41k | } |
Result<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >::is_error() const Line | Count | Source | 165 | 1.06k | [[nodiscard]] bool is_error() const { | 166 | 1.06k | return std::holds_alternative<Error>(m_data); | 167 | 1.06k | } |
Result<std::__1::optional<ImageSize> >::is_error() const Line | Count | Source | 165 | 31.3k | [[nodiscard]] bool is_error() const { | 166 | 31.3k | return std::holds_alternative<Error>(m_data); | 167 | 31.3k | } |
Unexecuted instantiation: Result<bool>::is_error() const |
168 | | |
169 | | // Accessor for the error, if it exists |
170 | | [[nodiscard]] const Error& error() const |
171 | 161k | { |
172 | 161k | if (*this) { |
173 | 73.9k | return Error::Ok; |
174 | 73.9k | } |
175 | | |
176 | 87.7k | return std::get<Error>(m_data); |
177 | 161k | } Unexecuted instantiation: Result<Encoder::CodedImageData>::error() const Unexecuted instantiation: Result<std::__1::shared_ptr<Box_infe> >::error() const Unexecuted instantiation: Result<std::__1::shared_ptr<Decoder> >::error() const Unexecuted instantiation: Result<std::__1::vector<std::__1::shared_ptr<Box>, std::__1::allocator<std::__1::shared_ptr<Box> > > >::error() const Result<std::__1::shared_ptr<HeifPixelImage> >::error() const Line | Count | Source | 171 | 134k | { | 172 | 134k | if (*this) { | 173 | 73.9k | return Error::Ok; | 174 | 73.9k | } | 175 | | | 176 | 61.0k | return std::get<Error>(m_data); | 177 | 134k | } |
Unexecuted instantiation: Result<Box_clap::Crop>::error() const Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::error() const Line | Count | Source | 171 | 14.3k | { | 172 | 14.3k | if (*this) { | 173 | 0 | return Error::Ok; | 174 | 0 | } | 175 | | | 176 | 14.3k | return std::get<Error>(m_data); | 177 | 14.3k | } |
Result<unsigned int>::error() const Line | Count | Source | 171 | 164 | { | 172 | 164 | if (*this) { | 173 | 0 | return Error::Ok; | 174 | 0 | } | 175 | | | 176 | 164 | return std::get<Error>(m_data); | 177 | 164 | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem> >::error() const Unexecuted instantiation: Result<unsigned long>::error() const Unexecuted instantiation: Result<DataExtent>::error() const Unexecuted instantiation: Result<std::__1::shared_ptr<HeifPixelImage const> >::error() const Unexecuted instantiation: Result<std::__1::unique_ptr<unc_encoder const, std::__1::default_delete<unc_encoder const> > >::error() const Unexecuted instantiation: Result<std::__1::unique_ptr<unc_decoder, std::__1::default_delete<unc_decoder> > >::error() const Unexecuted instantiation: Result<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >::error() const Result<std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*>::error() const Line | Count | Source | 171 | 11.9k | { | 172 | 11.9k | if (*this) { | 173 | 0 | return Error::Ok; | 174 | 0 | } | 175 | | | 176 | 11.9k | return std::get<Error>(m_data); | 177 | 11.9k | } |
Result<Fraction>::error() const Line | Count | Source | 171 | 161 | { | 172 | 161 | if (*this) { | 173 | 0 | return Error::Ok; | 174 | 0 | } | 175 | | | 176 | 161 | return std::get<Error>(m_data); | 177 | 161 | } |
Result<std::__1::shared_ptr<Track> >::error() const Line | Count | Source | 171 | 14 | { | 172 | 14 | if (*this) { | 173 | 0 | return Error::Ok; | 174 | 0 | } | 175 | | | 176 | 14 | return std::get<Error>(m_data); | 177 | 14 | } |
Result<std::__1::optional<ImageSize> >::error() const Line | Count | Source | 171 | 194 | { | 172 | 194 | if (*this) { | 173 | 0 | return Error::Ok; | 174 | 0 | } | 175 | | | 176 | 194 | return std::get<Error>(m_data); | 177 | 194 | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<SEIMessage> >::error() const Unexecuted instantiation: Result<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::error() const Unexecuted instantiation: Result<heif_tai_timestamp_packet>::error() const Unexecuted instantiation: Result<bool>::error() const Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Visual> >::error() const |
178 | | |
179 | | // Directly get the C error struct. |
180 | | heif_error error_struct(ErrorBuffer* error_buffer) const |
181 | 13.8k | { |
182 | 13.8k | if (*this) { |
183 | 0 | return heif_error_success; |
184 | 0 | } |
185 | | |
186 | 13.8k | return std::get<Error>(m_data).error_struct(error_buffer); |
187 | 13.8k | } Result<std::__1::shared_ptr<HeifPixelImage> >::error_struct(ErrorBuffer*) const Line | Count | Source | 181 | 13.8k | { | 182 | 13.8k | if (*this) { | 183 | 0 | return heif_error_success; | 184 | 0 | } | 185 | | | 186 | 13.8k | return std::get<Error>(m_data).error_struct(error_buffer); | 187 | 13.8k | } |
Unexecuted instantiation: Result<std::__1::shared_ptr<Box_udes> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<unsigned int>::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<Box_other> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Overlay> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_Grid> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<ImageItem_uncompressed> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<heif_raw_sequence_sample*>::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Visual> >::error_struct(ErrorBuffer*) const Unexecuted instantiation: Result<std::__1::shared_ptr<Track_Metadata> >::error_struct(ErrorBuffer*) const |
188 | | |
189 | | std::variant<T, Error> m_data; |
190 | | }; |
191 | | |
192 | | #endif |