Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_path_store.h
Go to the documentation of this file.
1// Copyright 2019-2020, Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Path store structure and functions.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup oxr_main
9 */
10
11#pragma once
12
13#include "oxr_extension_support.h"
14
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20struct u_hashset;
21struct oxr_logger;
22struct oxr_path;
23
24
25/*!
26 * Path store structure for managing path storage and lookup.
27 *
28 * @ingroup oxr_main
29 */
31{
32 //! Path store, for looking up paths.
34 //! Mapping from ID to path.
36 //! Total length of path array.
38 //! Number of paths in the array (0 is always null).
39 size_t path_num;
40};
41
42/*!
43 * Initialize the path store.
44 * @public @memberof oxr_path_store
45 */
46XrResult
47oxr_path_store_init(struct oxr_path_store *store);
48
49/*!
50 * Destroy the path store and all paths.
51 * @public @memberof oxr_path_store
52 */
53void
54oxr_path_store_fini(struct oxr_path_store *store);
55
56/*!
57 * Check if a path ID is valid.
58 * @public @memberof oxr_path_store
59 */
60bool
61oxr_path_store_is_valid(struct oxr_logger *log, const struct oxr_path_store *store, XrPath xr_path);
62
63/*!
64 * Get the path for the given string if it exists, or create it if it does not.
65 * @public @memberof oxr_path_store
66 */
67XrResult
68oxr_path_store_get_or_create(struct oxr_path_store *store, const char *str, size_t length, XrPath *out_path);
69
70/*!
71 * Only get the path for the given string if it exists.
72 * @public @memberof oxr_path_store
73 */
74void
75oxr_path_store_only_get(const struct oxr_path_store *store, const char *str, size_t length, XrPath *out_path);
76
77/*!
78 * Get a pointer and length of the internal string.
79 *
80 * The pointer has the same life time as the store. The length is the number
81 * of valid characters, not including the null termination character (but an
82 * extra null byte is always reserved at the end so can strings can be given
83 * to functions expecting null terminated strings).
84 *
85 * @public @memberof oxr_path_store
86 */
87XrResult
88oxr_path_store_get_string(const struct oxr_path_store *store, XrPath path, const char **out_str, size_t *out_length);
89
90#ifdef __cplusplus
91}
92#endif
Logger struct that lives on the stack, one for each call client call.
Definition oxr_logger.h:44
Path store structure for managing path storage and lookup.
Definition oxr_path_store.h:31
size_t path_num
Number of paths in the array (0 is always null).
Definition oxr_path_store.h:39
struct u_hashset * path_store
Path store, for looking up paths.
Definition oxr_path_store.h:33
size_t path_array_length
Total length of path array.
Definition oxr_path_store.h:37
struct oxr_path ** path_array
Mapping from ID to path.
Definition oxr_path_store.h:35
Internal representation of a path, item follows this struct in memory and that in turn is followed by...
Definition oxr_path_store.c:32
Kind of bespoke hashset implementation, where the user is responsible for allocating and freeing the ...
Definition u_hashset.cpp:26