Skyscraper 2.0
XrToString.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include <openxr/openxr.h>
7#include <openxr/openxr_reflection.h>
8#include <openxr/openxr_platform.h>
9
10#include <string>
11
12// Macro to generate stringify functions for OpenXR enumerations based data provided in openxr_reflection.h
13// clang-format off
14#define ENUM_CASE_STR(name, val) case name: return #name;
15
16// Returns C string pointing to a string literal. Unknown values are returned as 'Unknown <type>'.
17#define MAKE_TO_CSTRING_FUNC(enumType) \
18 constexpr const char* ToCString(enumType e) noexcept { \
19 switch (e) { \
20 XR_LIST_ENUM_##enumType(ENUM_CASE_STR) \
21 default: return "Unknown " #enumType; \
22 } \
23 }
24
25// Returns a STL string. Unknown values are stringified as an integer.
26#define MAKE_TO_STRING_FUNC(enumType) \
27 inline std::string ToString(enumType e) { \
28 switch (e) { \
29 XR_LIST_ENUM_##enumType(ENUM_CASE_STR) \
30 default: return std::to_string(e); \
31 } \
32 }
33
34#define MAKE_TO_STRING_FUNCS(enumType) \
35 MAKE_TO_CSTRING_FUNC(enumType) \
36 MAKE_TO_STRING_FUNC(enumType)
37// clang-format on
38
39namespace xr {
40 MAKE_TO_STRING_FUNCS(XrReferenceSpaceType);
41 MAKE_TO_STRING_FUNCS(XrViewConfigurationType);
42 MAKE_TO_STRING_FUNCS(XrEnvironmentBlendMode);
43 MAKE_TO_STRING_FUNCS(XrSessionState);
45 MAKE_TO_STRING_FUNCS(XrStructureType);
46 MAKE_TO_STRING_FUNCS(XrFormFactor);
47 MAKE_TO_STRING_FUNCS(XrEyeVisibility);
48 MAKE_TO_STRING_FUNCS(XrObjectType);
49 MAKE_TO_STRING_FUNCS(XrActionType);
51 MAKE_TO_STRING_FUNCS(XrHandPoseTypeMSFT);
52 MAKE_TO_CSTRING_FUNC(XrHandJointEXT);
53 MAKE_TO_STRING_FUNCS(XrVisibilityMaskTypeKHR);
54 MAKE_TO_STRING_FUNCS(XrReprojectionModeMSFT);
55 MAKE_TO_STRING_FUNCS(XrSceneComponentTypeMSFT);
56 MAKE_TO_STRING_FUNCS(XrSceneComputeStateMSFT);
57 MAKE_TO_STRING_FUNCS(XrSceneComputeFeatureMSFT);
58 MAKE_TO_STRING_FUNCS(XrSpatialGraphNodeTypeMSFT);
59 MAKE_TO_STRING_FUNCS(XrSceneComputeConsistencyMSFT);
60 MAKE_TO_STRING_FUNCS(XrMeshComputeLodMSFT);
61} // namespace xr
#define MAKE_TO_STRING_FUNCS(enumType)
Definition XrToString.h:34
#define MAKE_TO_CSTRING_FUNC(enumType)
Definition XrToString.h:17
The xr::DispatchTable struct contains all available PFN pointers to xr functions including those in a...