302 static inline cxstring cx_strcast_z(const char *str) { |
302 static inline cxstring cx_strcast_z(const char *str) { |
303 return cx_str(str); |
303 return cx_str(str); |
304 } |
304 } |
305 |
305 |
306 /** |
306 /** |
307 * Casts a mutable string to an immutable string. |
307 * Wraps any string into an UCX string. |
308 * |
308 * |
309 * Does nothing for already immutable strings. |
309 * @param str (any supported string type) the string to cast |
310 * |
310 * @return (@c cxstring) the string wrapped as UCX string |
311 * @note This is not seriously a cast. Instead, you get a copy |
311 */ |
312 * of the struct with the desired pointer type. Both structs still |
|
313 * point to the same location, though! |
|
314 * |
|
315 * @param str (@c cxstring or @c cxmutstr) the string to cast |
|
316 * @return (@c cxstring) an immutable copy of the string pointer |
|
317 */ |
|
318 #define cx_strcast(str) _Generic((str), \ |
312 #define cx_strcast(str) _Generic((str), \ |
319 cxmutstr: cx_strcast_m, \ |
313 cxmutstr: cx_strcast_m, \ |
320 cxstring: cx_strcast_c, \ |
314 cxstring: cx_strcast_c, \ |
|
315 const unsigned char*: cx_strcast_z, \ |
|
316 unsigned char *: cx_strcast_z, \ |
321 const char*: cx_strcast_z, \ |
317 const char*: cx_strcast_z, \ |
322 char *: cx_strcast_z) (str) |
318 char *: cx_strcast_z) (str) |
323 #endif |
319 #endif |
324 |
320 |
325 /** |
321 /** |