XRTraits C++ OpenXR Utilities
CastExceptions.h
Go to the documentation of this file.
1 // Copyright 2018-2019, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Header
6  * @author Ryan Pavlik <ryan.pavlik@collabora.com>
7  */
8 
9 #pragma once
10 
11 #ifdef XRTRAITS_USE_EXCEPTIONS
12 // Internal Includes
13 #include "BaseExceptions.h" // IWYU pragma: export
14 
15 // Library Includes
16 // - none
17 
18 // Standard Includes
19 #include <cstddef> // for std::nullptr_t
20 
21 namespace xrtraits {
22 namespace exceptions {
23 
24  /*!
25  * Exception thrown when we can't perform a given tagged cast to
26  * a reference type due to type field mismatch or null input.
27  *
28  * Only thrown on xr_tagged_dynamic_cast or xr_tagged_risky_cast
29  * to a reference type, because a reference is logically never
30  * null so a mismatch can't be handled by returning nullptr.
31  * Input of a nullptr gets a slightly different what() message
32  * but is the same exception as thrown when the input is a
33  * reference to or a non-null pointer to an object with a
34  * non-matching `type` member.
35  *
36  * @ingroup exceptions
37  */
39  {
40  /*!
41  * Constructor used for a tag mismatch with non-null
42  * input.
43  */
44  bad_tagged_cast(XrStructureType destTag,
45  XrStructureType sourceTag,
46  const char* castType);
47 
48  /*!
49  * Constructor used for nullptr input.
50  */
51  bad_tagged_cast(XrStructureType destTag, std::nullptr_t,
52  const char* castType);
53  };
54 
55 } // namespace exceptions
56 } // namespace xrtraits
57 
58 #endif // XRTRAITS_USE_EXCEPTIONS
Main namespace for these C++ OpenXR utilities.
Definition: GetChained.h:26
Definition: BaseExceptions.h:97
Definition: CastExceptions.h:38
bad_tagged_cast(XrStructureType destTag, XrStructureType sourceTag, const char *castType)