StormByte-Config 3.0.0
C++26 configuration-document 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-Config.
5 *
6 * StormByte-Config 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-Config source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository (including everything under
22 * thirdparty/, and in particular the bundled StormByte-String tree and
23 * the StormByte Base tree it vendors), which remains under its own license.
24 *
25 * Neither license grants any patent rights. Any patent licenses required
26 * to use this software or third-party components must be obtained separately
27 * from the patent holders.
28 *
29 * StormByte-Config is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public License
35 * version 3 along with StormByte-Config. If not, see
36 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
37 *
38 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
39 */
40
41#pragma once
42
43#include <StormByte/exception.hxx>
45
46#include <string_view>
47#include <utility>
48
53 namespace StormByte {
58 namespace Config {
66 public:
71 struct Path {
72 std::string_view segments;
73
78 explicit constexpr Path(std::string_view segments) noexcept: segments(segments) {}
79 };
80
87 template <typename... Args>
88 requires (sizeof...(Args) >= 1)
89 Exception(std::string_view pattern, Args&&... args)
90 : StormByte::Exception(StormByte::Exception::Path{"Config"}, pattern, std::forward<Args>(args)...) {}
91
96 explicit Exception(std::string_view message);
97
103 Exception(Path path, std::string_view message);
104
109 Exception(const Exception& other) = default;
110
115 Exception(Exception&& other) noexcept = default;
116
120 ~Exception() noexcept override;
121
127 Exception& operator=(const Exception& other) = default;
128
134 Exception& operator=(Exception&& other) noexcept = default;
135 };
136
142 public:
144
148 ~WrongValueTypeConversion() noexcept override;
149 };
150
156 public:
158
162 ~ValueFailure() noexcept override;
163 };
164
170 public:
172
176 ~InvalidName() noexcept override;
177 };
178
184 public:
186
190 ~InvalidPath() noexcept override;
191 };
192
198 public:
200
204 ~ParseError() noexcept override;
205 };
206
212 public:
214
218 ~ItemNotFound() noexcept override;
219 };
220
226 public:
228
232 ~ItemAlreadyExists() noexcept override;
233 };
234
240 public:
242
246 ~ItemNameAlreadyExists() noexcept override;
247 };
248
254 public:
256
260 ~OutOfBounds() noexcept override;
261 };
262 }
263 }
Exception(const Exception &other)=default
Copy constructor.
Exception(std::string_view message)
Format a plain message under StormByte.Config.
Exception(Path path, std::string_view message)
Plain message under an additional Config path.
~Exception() noexcept override
Destructor.
Exception(Exception &&other) noexcept=default
Move constructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when an invalid name is used for an item.
Definition exception.hxx:169
~InvalidName() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when an invalid path is used for an item.
Definition exception.hxx:183
~InvalidPath() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when attempting to add an item that already exists.
Definition exception.hxx:225
~ItemAlreadyExists() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when an item's name conflicts with an existing name.
Definition exception.hxx:239
~ItemNameAlreadyExists() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when an item cannot be found by its path or name.
Definition exception.hxx:211
~ItemNotFound() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when an index is out of bounds.
Definition exception.hxx:253
~OutOfBounds() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when a parsing error occurs in a configuration file.
Definition exception.hxx:197
~ParseError() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when setting a value fails due to type mismatch.
Definition exception.hxx:155
~ValueFailure() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Thrown when a value is converted to an incorrect type.
Definition exception.hxx:141
~WrongValueTypeConversion() noexcept override
Destructor.
Exception(std::string_view pattern, Args &&... args)
Replace literal {} under StormByte.Config.
Definition exception.hxx:89
Config module of the StormByte suite.
Definition alias.hxx:51
Root namespace of the StormByte suite.
Additional path segments nested below StormByte.Config.
Definition exception.hxx:71
constexpr Path(std::string_view segments) noexcept
Wraps additional path segments.
Definition exception.hxx:78
std::string_view segments
Additional dotted path segments.
Definition exception.hxx:72
#define STORMBYTE_CONFIG_PUBLIC
Definition visibility.h:53