The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/util: Add a new constructor and a new method to u_string_list

+60
+33
src/xrt/auxiliary/util/u_string_list.cpp
··· 58 58 } 59 59 } 60 60 61 + struct u_string_list * 62 + u_string_list_create_from_array(const char *const *arr, uint32_t size) 63 + { 64 + if (arr == nullptr || size == 0) { 65 + return u_string_list_create(); 66 + } 67 + try { 68 + auto ret = std::make_unique<u_string_list>(xrt::auxiliary::util::StringList{size}); 69 + for (uint32_t i = 0; i < size; ++i) { 70 + ret->list.push_back(arr[i]); 71 + } 72 + return ret.release(); 73 + } catch (std::exception const &) { 74 + return nullptr; 75 + } 76 + } 61 77 62 78 uint32_t 63 79 u_string_list_get_size(const struct u_string_list *usl) ··· 89 105 } 90 106 try { 91 107 usl->list.push_back(str); 108 + return 1; 109 + } catch (std::exception const &) { 110 + return -1; 111 + } 112 + } 113 + 114 + int 115 + u_string_list_append_array(struct u_string_list *usl, const char *const *arr, uint32_t size) 116 + { 117 + 118 + if (usl == nullptr) { 119 + return -1; 120 + } 121 + try { 122 + for (uint32_t i = 0; i < size; ++i) { 123 + usl->list.push_back(arr[i]); 124 + } 92 125 return 1; 93 126 } catch (std::exception const &) { 94 127 return -1;
+27
src/xrt/auxiliary/util/u_string_list.h
··· 49 49 u_string_list_create_from_list(struct u_string_list *usl); 50 50 51 51 /*! 52 + * @brief Create a new string list from an array of suitable strings. 53 + * 54 + * @param arr an array of zero or more non-null, null-terminated string that must live at least as long as the list, 55 + * preferably string literals. 56 + * @param size the number of elements in the array. 57 + * 58 + * @public @memberof u_string_list 59 + */ 60 + struct u_string_list * 61 + u_string_list_create_from_array(const char *const *arr, uint32_t size); 62 + 63 + /*! 52 64 * @brief Retrieve the number of elements in the list 53 65 * 54 66 * @public @memberof u_string_list ··· 76 88 */ 77 89 int 78 90 u_string_list_append(struct u_string_list *usl, const char *str); 91 + 92 + 93 + /*! 94 + * @brief Append an array of new string literals to the list. 95 + * 96 + * @param usl self pointer 97 + * @param arr an array of zero or more non-null, null-terminated string that must live at least as long as the list, 98 + * preferably string literals. 99 + * @param size the number of elements in the array. 100 + * @return 1 if successfully added, negative for errors. 101 + * 102 + * @public @memberof u_string_list 103 + */ 104 + int 105 + u_string_list_append_array(struct u_string_list *usl, const char *const *arr, uint32_t size); 79 106 80 107 /*! 81 108 * @brief Append a new string literal to the list, if it's not the same as a string already in the list.