Monado OpenXR Runtime
xrt_macro_lists.h
Go to the documentation of this file.
1
// Copyright 2025-2026, NVIDIA CORPORATION.
2
// SPDX-License-Identifier: BSL-1.0
3
/*!
4
* @file
5
* @brief X_macro lists for various XRT enums.
6
* @ingroup xrt_iface
7
*/
8
9
#pragma once
10
11
/*!
12
* @defgroup xrt_macro_lists X_macro Lists
13
* @ingroup xrt_iface
14
* @brief X_macro definitions for XRT enums to facilitate code generation.
15
*
16
* These macros allow you to programmatically iterate over all values in an enum
17
* without manually maintaining lists in multiple places.
18
*
19
* Each enum that has been processed will have a corresponding `<ENUM_NAME>_LIST` macro
20
* defined in the included file.
21
*
22
* @section xrt_macro_usage Usage Examples
23
*
24
* Example 1 - Generate a string conversion function:
25
* @code
26
* const char* xrt_result_to_string(xrt_result_t result) {
27
* switch(result) {
28
* #define CASE_STR(name) case name: return #name;
29
* XRT_RESULT_LIST(CASE_STR)
30
* #undef CASE_STR
31
* default: return "UNKNOWN";
32
* }
33
* }
34
* @endcode
35
*
36
* Example 2 - Generate an array of all enum values:
37
* @code
38
* static const xrt_result_t all_results[] = {
39
* #define ENUM_VALUE(name) name,
40
* XRT_RESULT_LIST(ENUM_VALUE)
41
* #undef ENUM_VALUE
42
* };
43
* @endcode
44
*
45
* Example 3 - Count the number of enum values:
46
* @code
47
* #define COUNT_ONE(name) 1 +
48
* static const int num_results = XRT_RESULT_LIST(COUNT_ONE) 0;
49
* #undef COUNT_ONE
50
* @endcode
51
*
52
* @{
53
*/
54
55
#include "xrt/xrt_macro_lists.h.inc"
56
57
/*!
58
* @}
59
*/
xrt
xrt_macro_lists.h
Generated by
1.9.4