StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
Loading...
Searching...
No Matches
exception.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Multimedia.
5 *
6 * StormByte-Multimedia original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Multimedia source in this
20 * file. Third-party components — including FFmpeg and embedded trained data —
21 * remain under their own licenses and are not covered by the commercial grant.
22 *
23 * A written StormByte commercial agreement may license this original source
24 * on terms other than the LGPL, including specific use, distribution or
25 * linking arrangements such as static linking, as stated in that agreement.
26 * It does not grant rights to dependencies or waive their license conditions.
27 * Enabling WITH_GPL or WITH_NONFREE may include components with separate
28 * obligations for modification, linking (static or dynamic), redistribution
29 * or works that incorporate them. The person modifying, linking, packaging or
30 * distributing the resulting work is responsible for determining and meeting
31 * all applicable requirements, including any needed patent permissions.
32 * A StormByte commercial agreement does not provide those rights for GPL or
33 * nonfree components.
34 *
35 * Neither license grants any patent rights. Any patent licenses required
36 * to use this software or third-party components must be obtained separately
37 * from the patent holders.
38 *
39 * StormByte-Multimedia is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 * GNU Lesser General Public License for more details.
43 *
44 * You should have received a copy of the GNU Lesser General Public License
45 * version 3 along with StormByte-Multimedia. If not, see
46 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
47 *
48 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
49 */
50
51#pragma once
52
53#include <StormByte/exception.hxx>
55#include <StormByte/safe/string.hxx>
56
57#include <string_view>
58#include <utility>
59
64namespace StormByte {
69 namespace Multimedia {
87 public:
92 struct Path {
93 std::string_view segments;
94
99 explicit constexpr Path(std::string_view segments = {}) noexcept: segments(segments) {}
100 };
101
108 template <typename... Args>
109 requires (sizeof...(Args) >= 1)
110 explicit Exception(std::string_view pattern, Args&&... args)
111 : StormByte::Exception(StormByte::Exception::Path{"Multimedia"}, pattern, std::forward<Args>(args)...) {}
112
117 explicit Exception(std::string_view message);
118
126 template <typename... Args>
127 requires (sizeof...(Args) >= 1)
128 explicit Exception(Path path, std::string_view pattern, Args&&... args)
129 : Exception(path, static_cast<std::string_view>(StormByte::Safe::String::ReplaceToken(pattern, std::forward<Args>(args)...))) {}
130
136 explicit Exception(Path path, std::string_view message);
137
142 Exception(const Exception& other);
143
148 Exception(Exception&& other) noexcept;
149
153 ~Exception() noexcept override;
154
160 Exception& operator=(const Exception& other);
161
167 Exception& operator=(Exception&& other) noexcept;
168 };
169
175 public:
180 explicit CodecNotFoundException(std::string_view codec):
181 Exception(Path{"Codec"}, "codec '{}' not found", codec) {}
182
188
194
198 ~CodecNotFoundException() noexcept override;
199
206
212 CodecNotFoundException& operator=(CodecNotFoundException&& other) noexcept;
213 };
214
220 public:
225 explicit ContainerNotFoundException(std::string_view container):
226 Exception(Path{"Container"}, "container '{}' not found", container) {}
227
233
239
243 ~ContainerNotFoundException() noexcept override;
244
251
258 };
259
265 public:
270 explicit FileOpenException(std::string_view message):
271 Exception(Path{"File"}, message) {}
272
278
284
288 ~FileOpenException() noexcept override;
289
295 FileOpenException& operator=(const FileOpenException& other);
296
302 FileOpenException& operator=(FileOpenException&& other) noexcept;
303 };
304
310 public:
316 explicit FilePathOpenException(std::string_view path, std::string_view reason):
317 FileOpenException(static_cast<std::string_view>(StormByte::Safe::String::ReplaceToken(
318 "failed to open '{}': {}", path, reason))) {}
319
325
331
335 ~FilePathOpenException() noexcept override;
336
343
349 FilePathOpenException& operator=(FilePathOpenException&& other) noexcept;
350 };
351
357 public:
362 explicit FileBufferOpenException(std::string_view reason):
363 FileOpenException(static_cast<std::string_view>(StormByte::Safe::String::ReplaceToken(
364 "failed to open buffer: {}", reason))) {}
365
371
377
381 ~FileBufferOpenException() noexcept override;
382
389
396 };
397
403 public:
408 explicit TranscodeException(std::string_view message):
409 Exception(Path{"Transcode"}, message) {}
410
416
422
426 ~TranscodeException() noexcept override;
427
433 TranscodeException& operator=(const TranscodeException& other);
434
440 TranscodeException& operator=(TranscodeException&& other) noexcept;
441 };
442 }
443}
CodecNotFoundException(CodecNotFoundException &&other) noexcept
Move constructor.
CodecNotFoundException(const CodecNotFoundException &other)
Copy constructor.
~CodecNotFoundException() noexcept override
Destructor.
CodecNotFoundException(std::string_view codec)
Constructs the exception for codec.
Definition exception.hxx:180
~ContainerNotFoundException() noexcept override
Destructor.
ContainerNotFoundException(const ContainerNotFoundException &other)
Copy constructor.
ContainerNotFoundException(std::string_view container)
Constructs the exception for container.
Definition exception.hxx:225
ContainerNotFoundException(ContainerNotFoundException &&other) noexcept
Move constructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Multimedia.
Definition exception.hxx:110
Exception(std::string_view message)
Copy a borrowed plain message under StormByte.Multimedia.
Exception(const Exception &other)
Copy constructor.
Exception(Exception &&other) noexcept
Move constructor.
Exception(Path path, std::string_view message)
Copy a borrowed plain message under an additional Multimedia path.
~Exception() noexcept override
Destructor.
Exception(Path path, std::string_view pattern, Args &&... args)
Replace literal {} under an additional Multimedia path.
Definition exception.hxx:128
~FileBufferOpenException() noexcept override
Destructor.
FileBufferOpenException(std::string_view reason)
Constructs the exception.
Definition exception.hxx:362
FileBufferOpenException(const FileBufferOpenException &other)
Copy constructor.
FileBufferOpenException(FileBufferOpenException &&other) noexcept
Move constructor.
FileOpenException(const FileOpenException &other)
Copy constructor.
FileOpenException(std::string_view message)
Constructs the exception with a finished message.
Definition exception.hxx:270
FileOpenException(FileOpenException &&other) noexcept
Move constructor.
~FileOpenException() noexcept override
Destructor.
FilePathOpenException(std::string_view path, std::string_view reason)
Constructs the exception for path.
Definition exception.hxx:316
FilePathOpenException(const FilePathOpenException &other)
Copy constructor.
FilePathOpenException(FilePathOpenException &&other) noexcept
Move constructor.
~FilePathOpenException() noexcept override
Destructor.
~TranscodeException() noexcept override
Destructor.
TranscodeException(std::string_view message)
Constructs the exception with a finished message.
Definition exception.hxx:408
TranscodeException(const TranscodeException &other)
Copy constructor.
TranscodeException(TranscodeException &&other) noexcept
Move constructor.
static String ReplaceToken(std::string_view text, Args &&... args)
Multimedia module of the StormByte suite.
@ String
Free text.
Definition encoder_info.hxx:93
Root namespace of the StormByte C++ suite.
STL namespace.
Additional path segments nested below StormByte.Multimedia.
Definition exception.hxx:92
constexpr Path(std::string_view segments={}) noexcept
Wraps additional path segments.
Definition exception.hxx:99
std::string_view segments
Additional dotted path segments.
Definition exception.hxx:93
#define STORMBYTE_MULTIMEDIA_PUBLIC
Definition visibility.h:61