@@ -39,12 +39,13 @@ struct BackendOption {
39
39
};
40
40
41
41
/* *
42
- * A template class for storing and managing backend-specific configuration options.
43
- *
44
- * This class provides a type-safe way to store key-value pairs for backend configuration,
45
- * with compile-time capacity limits and runtime type checking. It supports bool, int, and
46
- * const char* value types.
47
- *
42
+ * A template class for storing and managing backend-specific configuration
43
+ * options.
44
+ *
45
+ * This class provides a type-safe way to store key-value pairs for backend
46
+ * configuration, with compile-time capacity limits and runtime type checking.
47
+ * It supports bool, int, and const char* value types.
48
+ *
48
49
* @tparam MaxCapacity The maximum number of options that can be stored
49
50
*/
50
51
template <size_t MaxCapacity>
@@ -57,7 +58,7 @@ class BackendOptions {
57
58
58
59
/* *
59
60
* Returns a const view of all stored options as a Span.
60
- *
61
+ *
61
62
* @return A const Span containing all BackendOption entries
62
63
*/
63
64
executorch::runtime::Span<BackendOption> view () const {
@@ -66,7 +67,7 @@ class BackendOptions {
66
67
67
68
/* *
68
69
* Returns a mutable view of all stored options as a Span.
69
- *
70
+ *
70
71
* @return A mutable Span containing all BackendOption entries
71
72
*/
72
73
executorch::runtime::Span<BackendOption> view () {
@@ -76,64 +77,64 @@ class BackendOptions {
76
77
/* *
77
78
* Sets a boolean option value for the given key.
78
79
* If the key already exists, updates its value. Otherwise, adds a new option.
79
- *
80
+ *
80
81
* @tparam N The length of the key string (automatically deduced)
81
82
* @param key The option key (must be a string literal or array)
82
83
* @param value The boolean value to set
83
84
* @return Error::Ok on success, Error::InvalidArgument if storage is full
84
85
*/
85
86
template <size_t N>
86
87
Error set_option (const char (&key)[N], bool value) noexcept {
87
- static_assert (N <= kMaxOptionKeyLength , " Option key is too long" );
88
+ ET_CHECK_MSG (N <= kMaxOptionKeyLength , " Option key is too long" );
88
89
return set_option_impl (key, value);
89
90
}
90
91
91
92
/* *
92
93
* Sets an integer option value for the given key.
93
94
* If the key already exists, updates its value. Otherwise, adds a new option.
94
- *
95
+ *
95
96
* @tparam N The length of the key string (automatically deduced)
96
97
* @param key The option key (must be a string literal or array)
97
98
* @param value The integer value to set
98
99
* @return Error::Ok on success, Error::InvalidArgument if storage is full
99
100
*/
100
101
template <size_t N>
101
102
Error set_option (const char (&key)[N], int value) noexcept {
102
- static_assert (N <= kMaxOptionKeyLength , " Option key is too long" );
103
+ ET_CHECK_MSG (N <= kMaxOptionKeyLength , " Option key is too long" );
103
104
return set_option_impl (key, value);
104
105
}
105
106
106
107
/* *
107
108
* Sets a string option value for the given key.
108
109
* If the key already exists, updates its value. Otherwise, adds a new option.
109
- *
110
- * Note: The string value must have static storage duration. This class does NOT
111
- * take ownership of the string - it only stores the pointer.
112
- *
110
+ *
111
+ * Note: The string value must have static storage duration. This class does
112
+ * NOT take ownership of the string - it only stores the pointer.
113
+ *
113
114
* @tparam N The length of the key string (automatically deduced)
114
115
* @param key The option key (must be a string literal or array)
115
116
* @param value The string value to set (must have static storage duration)
116
117
* @return Error::Ok on success, Error::InvalidArgument if storage is full
117
118
*/
118
119
template <size_t N>
119
120
Error set_option (const char (&key)[N], const char* value) noexcept {
120
- static_assert (N <= kMaxOptionKeyLength , " Option key is too long" );
121
+ ET_CHECK_MSG (N <= kMaxOptionKeyLength , " Option key is too long" );
121
122
return set_option_impl (key, value);
122
123
}
123
124
124
125
/* *
125
126
* Retrieves an option value by key and type.
126
- *
127
+ *
127
128
* @tparam T The expected type of the option value (bool, int, or const char*)
128
129
* @tparam KeyLen The length of the key string (automatically deduced)
129
130
* @param key The option key to look up
130
131
* @param out Reference to store the retrieved value
131
- * @return Error::Ok if found and type matches, Error::NotFound if key doesn't exist,
132
- * Error::InvalidArgument if type doesn't match
132
+ * @return Error::Ok if found and type matches, Error::NotFound if key doesn't
133
+ * exist, Error::InvalidArgument if type doesn't match
133
134
*/
134
135
template <typename T, size_t KeyLen>
135
136
Error get_option (const char (&key)[KeyLen], T& out) const {
136
- static_assert (KeyLen <= kMaxOptionKeyLength , " Option key is too long" );
137
+ ET_CHECK_MSG (KeyLen <= kMaxOptionKeyLength , " Option key is too long" );
137
138
138
139
for (size_t i = 0 ; i < size_; ++i) {
139
140
if (std::strcmp (options_[i].key , key) == 0 ) {
@@ -154,7 +155,7 @@ class BackendOptions {
154
155
/* *
155
156
* Internal implementation for setting option values.
156
157
* Handles both updating existing options and adding new ones.
157
- *
158
+ *
158
159
* @tparam T The type of the value (bool, int, or const char*)
159
160
* @param key The option key
160
161
* @param value The value to set
0 commit comments