00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CU_WSTRING_H
00019 #define CU_WSTRING_H
00020
00021 #include <cu/fwd.h>
00022 #include <cu/wchar.h>
00023 #include <cuoo/type.h>
00024
00025 CU_BEGIN_DECLARATIONS
00026
00027 extern cuoo_type_t cuP_wstring_type;
00028 extern cu_wstring_t cuP_wstring_empty;
00029
00030
00031
00032
00033
00034 struct cu_wstring
00035 {
00036 CUOO_OBJ
00037 size_t len;
00038 cu_wchar_t const *arr;
00039 };
00040
00041 #ifdef CU_WCHAR_IS_STDC
00042 # define CU_WSTRING_C(s) \
00043 cu_wstring_of_arr(L##s, sizeof(L##s)/sizeof(cu_wchar_t) - 1)
00044 # define CU_WSTRING_C_O(s) \
00045 cu_wstring_of_arr_o(L##s, sizeof(L##s)/sizeof(cu_wchar_t) - 1)
00046 #else
00047 # define CU_WSTRING_C(s) cu_wstring_of_chararr(s, sizeof(s) - 1)
00048 # define CU_WSTRING_C_O(s) cu_wstring_of_chararr_o(s, sizeof(s) - 1)
00049 #endif
00050
00051
00052
00053 CU_SINLINE cuoo_type_t cu_wstring_type()
00054 { return cuP_wstring_type; }
00055
00056
00057 CU_SINLINE size_t cu_wstring_length(cu_wstring_t s) { return s->len; }
00058
00059
00060 CU_SINLINE cu_wchar_t const *cu_wstring_array(cu_wstring_t s)
00061 { return s->arr; }
00062
00063
00064 CU_SINLINE cu_wchar_t cu_wstring_at(cu_wstring_t s, size_t i)
00065 { cu_debug_assert(i < s->len); return s->arr[i]; }
00066
00067
00068 CU_SINLINE cu_wstring_t cu_wstring_empty() { return cuP_wstring_empty; }
00069
00070
00071 cu_wstring_t cu_wstring_of_arr(cu_wchar_t const *arr, size_t len);
00072
00073
00074
00075 cu_wstring_t cu_wstring_of_arr_o(cu_wchar_t const *arr, size_t len);
00076
00077
00078
00079 cu_wstring_t cu_wstring_of_arr_ref(cu_wchar_t const *arr, size_t len);
00080
00081
00082
00083 cu_wstring_t cu_wstring_of_arr_ref_o(cu_wchar_t const *arr, size_t len);
00084
00085
00086
00087 cu_wstring_t cu_wstring_of_chararr(char const *arr, size_t len);
00088
00089 cu_wstring_t cu_wstring_of_chararr_o(char const *arr, size_t len);
00090
00091
00092 cu_wstring_t cu_wstring_of_charstr(char const *str);
00093
00094
00095 cu_wstring_t cu_wstring_cat2(cu_wstring_t sl, cu_wstring_t sr);
00096
00097
00098
00099 cu_wstring_t cu_wstring_cat2_o(cu_wstring_t sl, cu_wstring_t sr);
00100
00101
00102 cu_wstring_t cu_wstring_cat3(cu_wstring_t s0, cu_wstring_t s1,
00103 cu_wstring_t s2);
00104
00105 cu_wstring_t cu_wstring_cat3_o(cu_wstring_t s0, cu_wstring_t s1,
00106 cu_wstring_t s2);
00107
00108
00109 cu_wstring_t cu_wstring_slice(cu_wstring_t s, size_t i, size_t j);
00110
00111
00112
00113 cu_wstring_t cu_wstring_slice_o(cu_wstring_t s, size_t i, size_t j);
00114
00115
00116
00117
00118 int cu_wstring_cmp(cu_wstring_t sl, cu_wstring_t sr);
00119
00120 #if 0
00121
00122
00123
00124
00125
00126 int cu_wstring_coll(cu_wstring_t sl, cu_wstring_t sr);
00127 #endif
00128
00129
00130 cu_wstring_t cu_wstring_image(cu_wstring_t s,
00131 cu_clop(f, cu_wchar_t, cu_wchar_t));
00132
00133
00134
00135 cu_wstring_t cu_wstring_image_o(cu_wstring_t s,
00136 cu_clop(f, cu_wchar_t, cu_wchar_t));
00137
00138
00139
00140
00141 cu_bool_t cu_wstring_forall(cu_wstring_t s, cu_clop(f, cu_bool_t, cu_wchar_t));
00142
00143
00144 CU_END_DECLARATIONS
00145
00146 #endif