1.1 --- a/src/ucx/string.h Wed May 16 19:01:21 2018 +0200 1.2 +++ b/src/ucx/string.h Wed May 16 19:27:45 2018 +0200 1.3 @@ -95,25 +95,56 @@ 1.4 1.5 1.6 #ifdef __cplusplus 1.7 +/** 1.8 + * One of two type adjustment functions that return a scstr_t. 1.9 + * 1.10 + * Used <b>internally</b> to convert a UCX string to an immutable UCX string. 1.11 + * 1.12 + * <b>Do not use this function manually.</b> 1.13 + * 1.14 + * @param str some sstr_t 1.15 + * @return an immutable (scstr_t) version of the provided string. 1.16 + */ 1.17 inline scstr_t s2scstr(sstr_t s) { 1.18 scstr_t c; 1.19 c.ptr = s.ptr; 1.20 c.length = s.ptr; 1.21 return c; 1.22 } 1.23 -inline scstr_t s2scstr(scstr_t c) { 1.24 - return c; 1.25 + 1.26 +/** 1.27 + * One of two type adjustment functions that return a scstr_t. 1.28 + * 1.29 + * Used <b>internally</b> to convert a UCX string to an immutable UCX string. 1.30 + * This variant is used, when the string is already immutable and no operation 1.31 + * needs to be performed. 1.32 + * 1.33 + * <b>Do not use this function manually.</b> 1.34 + * 1.35 + * @param str some scstr_t 1.36 + * @return the argument itself 1.37 + */ 1.38 +inline scstr_t s2scstr(scstr_t str) { 1.39 + return str; 1.40 } 1.41 -#define SCSTR s2scstr 1.42 + 1.43 +/** 1.44 + * Converts a UCX string to an immutable UCX string (scstr_t). 1.45 + * @param str some UCX string 1.46 + * @return the an immutable version of the provided string 1.47 + */ 1.48 +#define SCSTR(s) s2scstr(s) 1.49 #else 1.50 1.51 /** 1.52 * One of two type adjustment functions that return a scstr_t. 1.53 * 1.54 - * Used internally to convert a UCX string to an immutable UCX string. 1.55 + * Used <b>internally</b> to convert a UCX string to an immutable UCX string. 1.56 * This variant is used, when the string is already immutable and no operation 1.57 * needs to be performed. 1.58 * 1.59 + * <b>Do not use this function manually.</b> 1.60 + * 1.61 * @param str some scstr_t 1.62 * @return the argument itself 1.63 */ 1.64 @@ -122,7 +153,9 @@ 1.65 /** 1.66 * One of two type adjustment functions that return a scstr_t. 1.67 * 1.68 - * Used internally to convert a UCX string to an immutable UCX string. 1.69 + * Used <b>internally</b> to convert a UCX string to an immutable UCX string. 1.70 + * 1.71 + * <b>Do not use this function manually.</b> 1.72 * 1.73 * @param str some sstr_t 1.74 * @return an immutable (scstr_t) version of the provided string. 1.75 @@ -131,7 +164,7 @@ 1.76 1.77 #if __STDC_VERSION__ >= 201112L 1.78 /** 1.79 - * Casts a UCX string to an immutable UCX string (scstr_t). 1.80 + * Converts a UCX string to an immutable UCX string (scstr_t). 1.81 * @param str some UCX string 1.82 * @return the an immutable version of the provided string 1.83 */ 1.84 @@ -140,7 +173,7 @@ 1.85 #elif defined(__GNUC__) || defined(__clang__) 1.86 1.87 /** 1.88 - * Casts a UCX string to an immutable UCX string (scstr_t). 1.89 + * Converts a UCX string to an immutable UCX string (scstr_t). 1.90 * @param str some UCX string 1.91 * @return the an immutable version of the provided string 1.92 */ 1.93 @@ -152,7 +185,7 @@ 1.94 #elif defined(__sun) 1.95 1.96 /** 1.97 - * Casts a UCX string to an immutable UCX string (scstr_t). 1.98 + * Converts a UCX string to an immutable UCX string (scstr_t). 1.99 * @param str some UCX string 1.100 * @return the an immutable version of the provided string 1.101 */ 1.102 @@ -164,7 +197,7 @@ 1.103 #else /* no generics and no builtins */ 1.104 1.105 /** 1.106 - * Casts a UCX string to an immutable UCX string (scstr_t). 1.107 + * Converts a UCX string to an immutable UCX string (scstr_t). 1.108 * 1.109 * This internal function (ab)uses the C standard an expects one single 1.110 * argument which is then implicitly converted to scstr_t without a warning. 1.111 @@ -174,7 +207,7 @@ 1.112 scstr_t ucx_ss2c_s(); 1.113 1.114 /** 1.115 - * Casts a UCX string to an immutable UCX string (scstr_t). 1.116 + * Converts a UCX string to an immutable UCX string (scstr_t). 1.117 * @param str some UCX string 1.118 * @return the an immutable version of the provided string 1.119 */ 1.120 @@ -612,7 +645,7 @@ 1.121 * @see sstrsplit() 1.122 */ 1.123 #define sstrsplit_a(allocator, string, delim, count) \ 1.124 - scstrsplit_a(allocator, SCSTR(string), SCSTR(delim, count)) 1.125 + scstrsplit_a(allocator, SCSTR(string), SCSTR(delim), count) 1.126 1.127 /** 1.128 * Compares two UCX strings with standard <code>memcmp()</code>.